Revert "feat(search): try to deal with huge dbs, might need to squash later"

This reverts commit 37d0136c50.
This commit is contained in:
perf3ct
2025-09-02 19:24:46 +00:00
parent f529ddc601
commit 0afb8a11c8
6 changed files with 277 additions and 207 deletions

View File

@@ -44,9 +44,6 @@ async function initDbConnection() {
await migrationService.migrateIfNecessary();
// Initialize optimized SQLite pragmas for FTS and large database performance
initializeFTSPragmas();
sql.execute('CREATE TEMP TABLE "param_list" (`paramId` TEXT NOT NULL PRIMARY KEY)');
sql.execute(`
@@ -188,42 +185,6 @@ function setDbAsInitialized() {
}
}
/**
* Initialize SQLite pragmas optimized for FTS5 and large databases
*/
function initializeFTSPragmas() {
if (config.General.readOnly) {
return;
}
try {
log.info("Setting SQLite pragmas for FTS5 and large database optimization...");
sql.executeScript(`
-- Memory Management (Critical for FTS performance with millions of notes)
PRAGMA cache_size = -262144; -- 256MB cache for better query performance
PRAGMA temp_store = MEMORY; -- Use memory for temporary tables and indices
PRAGMA mmap_size = 536870912; -- 512MB memory-mapped I/O for better read performance
-- Write Optimization (Better for concurrent operations)
PRAGMA synchronous = NORMAL; -- Balance safety and performance (FULL is too slow for large operations)
PRAGMA journal_mode = WAL; -- Write-Ahead Logging for better concurrency
PRAGMA wal_autocheckpoint = 1000; -- Checkpoint every 1000 pages for memory management
-- Query Optimization (Essential for complex FTS queries)
PRAGMA automatic_index = ON; -- Allow SQLite to create automatic indexes when beneficial
-- FTS-Specific Optimizations
PRAGMA threads = 4; -- Use multiple threads for FTS operations if available
`);
log.info("FTS pragmas initialized successfully");
} catch (error) {
log.error(`Failed to initialize FTS pragmas: ${error}`);
// Don't throw - continue with default settings
}
}
function optimize() {
if (config.General.readOnly) {
return;