mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
perf(database): run PRAGMA optimize before closing connections
SQLite's recommended approach for keeping query plans current: cheap when nothing needs analyzing, runs incremental ANALYZE on tables/indexes that have grown significantly since the last run. Wrapped in try/catch since optimize is advisory and must never block connection close. Applied to both the main connection and the EPG worker connection. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 3d6901072049
This commit is contained in:
1 parent
69d106bdb3
commit
eedfc498e7
2 files changed
+12
No files matched your search
@@ -100,6 +100,12 @@ export function closeWorkerDatabase(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
sqlite.pragma('optimize');
|
||||
} catch {
|
||||
// Optimize is advisory; never block close on it.
|
||||
}
|
||||
|
||||
sqlite.close();
|
||||
|
||||
if (isSqlTraceEnabled()) {
|
||||
|
||||
@@ -573,6 +573,12 @@ export async function getReadOnlyDatabase(): Promise<DatabaseInstance> {
|
||||
*/
|
||||
export function closeDatabase(): void {
|
||||
if (sqlite) {
|
||||
try {
|
||||
sqlite.pragma('optimize');
|
||||
} catch {
|
||||
// Optimize is advisory; never block close on it.
|
||||
}
|
||||
|
||||
sqlite.close();
|
||||
|
||||
if (isSqlTraceEnabled()) {
|
||||
|
||||
Reference in new issue
Block a user