Skip to content

Commit e93ce84

Browse files
authored
feat: enable WAL (Write-Ahead Logging) for improved performance and stability (#1885)
Enable Write-Ahead Logging (WAL) mode for the SQLite database. This change is intended to enhance both the performance and stability of database operations, particularly when handling concurrent transactions and large volumes of data.
1 parent d9ca1c7 commit e93ce84

File tree

7 files changed

+14
-1
lines changed

7 files changed

+14
-1
lines changed

core/indexing/CodeSnippetsIndex.ts

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
2828
constructor(private readonly ide: IDE) {}
2929

3030
private static async _createTables(db: DatabaseConnection) {
31+
await db.exec("PRAGMA journal_mode=WAL;");
32+
3133
await db.exec(`CREATE TABLE IF NOT EXISTS code_snippets (
3234
id INTEGER PRIMARY KEY,
3335
path TEXT NOT NULL,

core/indexing/FullTextSearch.ts

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export class FullTextSearchCodebaseIndex implements CodebaseIndex {
2020
artifactId = "sqliteFts";
2121

2222
private async _createTables(db: DatabaseConnection) {
23+
await db.exec("PRAGMA journal_mode=WAL;");
24+
2325
await db.exec(`CREATE VIRTUAL TABLE IF NOT EXISTS fts USING fts5(
2426
path,
2527
content,

core/indexing/LanceDbIndex.ts

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export class LanceDbIndex implements CodebaseIndex {
4646
}
4747

4848
private async createSqliteCacheTable(db: DatabaseConnection) {
49+
await db.exec("PRAGMA journal_mode=WAL;");
50+
4951
await db.exec(`CREATE TABLE IF NOT EXISTS lance_db_cache (
5052
uuid TEXT PRIMARY KEY,
5153
cacheKey TEXT NOT NULL,

core/indexing/chunk/ChunkCodebaseIndex.ts

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
2424
}
2525

2626
private async _createTables(db: DatabaseConnection) {
27+
await db.exec("PRAGMA journal_mode=WAL;");
28+
2729
await db.exec(`CREATE TABLE IF NOT EXISTS chunks (
2830
id INTEGER PRIMARY KEY AUTOINCREMENT,
2931
cacheKey TEXT NOT NULL,

core/indexing/docs/DocsService.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ export default class DocsService {
476476

477477
await runSqliteMigrations(db);
478478

479-
db.exec(`CREATE TABLE IF NOT EXISTS ${DocsService.sqlitebTableName} (
479+
await db.exec("PRAGMA journal_mode=WAL;");
480+
await db.exec(`CREATE TABLE IF NOT EXISTS ${DocsService.sqlitebTableName} (
480481
id INTEGER PRIMARY KEY AUTOINCREMENT,
481482
title STRING NOT NULL,
482483
startUrl STRING NOT NULL UNIQUE,

core/indexing/refreshIndex.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export class SqliteDb {
2323
static db: DatabaseConnection | null = null;
2424

2525
private static async createTables(db: DatabaseConnection) {
26+
await db.exec("PRAGMA journal_mode=WAL;");
27+
2628
await db.exec(
2729
`CREATE TABLE IF NOT EXISTS tag_catalog (
2830
id INTEGER PRIMARY KEY AUTOINCREMENT,

core/util/devdataSqlite.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export class DevDataSqliteDb {
88
static db: DatabaseConnection | null = null;
99

1010
private static async createTables(db: DatabaseConnection) {
11+
await db.exec("PRAGMA journal_mode=WAL;");
12+
1113
await db.exec(
1214
`CREATE TABLE IF NOT EXISTS tokens_generated (
1315
id INTEGER PRIMARY KEY AUTOINCREMENT,

0 commit comments

Comments
 (0)