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.
This commit is contained in:
Priyash 2024-08-06 05:08:23 +05:30 • committed by GitHub
parent d9ca1c7c65
commit e93ce84cd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 14 additions and 1 deletions

View file

@ -28,6 +28,8 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
constructor(private readonly ide: IDE) {}
private static async _createTables(db: DatabaseConnection) {
await db.exec("PRAGMA journal_mode=WAL;");
await db.exec(`CREATE TABLE IF NOT EXISTS code_snippets (
id INTEGER PRIMARY KEY,
path TEXT NOT NULL,

View file

@ -20,6 +20,8 @@ export class FullTextSearchCodebaseIndex implements CodebaseIndex {
artifactId = "sqliteFts";
private async _createTables(db: DatabaseConnection) {
await db.exec("PRAGMA journal_mode=WAL;");
await db.exec(`CREATE VIRTUAL TABLE IF NOT EXISTS fts USING fts5(
path,
content,

View file

@ -46,6 +46,8 @@ export class LanceDbIndex implements CodebaseIndex {
}
private async createSqliteCacheTable(db: DatabaseConnection) {
await db.exec("PRAGMA journal_mode=WAL;");
await db.exec(`CREATE TABLE IF NOT EXISTS lance_db_cache (
uuid TEXT PRIMARY KEY,
cacheKey TEXT NOT NULL,

View file

@ -24,6 +24,8 @@ export class ChunkCodebaseIndex implements CodebaseIndex {
}
private async _createTables(db: DatabaseConnection) {
await db.exec("PRAGMA journal_mode=WAL;");
await db.exec(`CREATE TABLE IF NOT EXISTS chunks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
cacheKey TEXT NOT NULL,

View file

@ -476,7 +476,8 @@ export default class DocsService {
await runSqliteMigrations(db);
db.exec(`CREATE TABLE IF NOT EXISTS ${DocsService.sqlitebTableName} (
await db.exec("PRAGMA journal_mode=WAL;");
await db.exec(`CREATE TABLE IF NOT EXISTS ${DocsService.sqlitebTableName} (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title STRING NOT NULL,
startUrl STRING NOT NULL UNIQUE,

View file

@ -23,6 +23,8 @@ export class SqliteDb {
static db: DatabaseConnection | null = null;
private static async createTables(db: DatabaseConnection) {
await db.exec("PRAGMA journal_mode=WAL;");
await db.exec(
`CREATE TABLE IF NOT EXISTS tag_catalog (
id INTEGER PRIMARY KEY AUTOINCREMENT,

View file

@ -8,6 +8,8 @@ export class DevDataSqliteDb {
static db: DatabaseConnection | null = null;
private static async createTables(db: DatabaseConnection) {
await db.exec("PRAGMA journal_mode=WAL;");
await db.exec(
`CREATE TABLE IF NOT EXISTS tokens_generated (
id INTEGER PRIMARY KEY AUTOINCREMENT,