PEP-219: индекс events(session_id, type) — доска не перебирает все события на каждую сессию
listSessions считает переключения подписки подзапросом по events для каждой сессии; без индекса это полный просмотр ~40 000 строк × 746 сессий (4,4 с на копии живой базы, 0,008 с с индексом). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b47e95f91f
commit
7189fd2457
1
packages/db/migrations/0024_events_session_type.sql
Normal file
1
packages/db/migrations/0024_events_session_type.sql
Normal file
@ -0,0 +1 @@
|
||||
CREATE INDEX `events_session_type` ON `events` (`session_id`,`type`);
|
||||
4613
packages/db/migrations/meta/0024_snapshot.json
Normal file
4613
packages/db/migrations/meta/0024_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -169,6 +169,13 @@
|
||||
"when": 1794919319811,
|
||||
"tag": "0023_curious_steel_serpent",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 24,
|
||||
"version": "6",
|
||||
"when": 1795017454043,
|
||||
"tag": "0024_events_session_type",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -492,7 +492,7 @@ export const events = sqliteTable(
|
||||
actorClientId: text("actor_client_id"),
|
||||
createdAt: createdAt(),
|
||||
},
|
||||
(t) => [index("events_created_at").on(t.createdAt)],
|
||||
(t) => [index("events_created_at").on(t.createdAt), index("events_session_type").on(t.sessionId, t.type)],
|
||||
);
|
||||
|
||||
/** Small key/value store for service state (Telegram offset, pairing, binding). */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user