perf(db): tune sqlite pool and add maintenance scheduler

This commit is contained in:
2026-02-07 12:53:43 +08:00
parent d77e439712
commit ff67a9bbab
5 changed files with 170 additions and 11 deletions

View File

@@ -18,6 +18,17 @@ SESSION_COOKIE_SECURE=false # 使用HTTPS时设为true
# ==================== 数据库配置 ====================
DB_FILE=data/app_data.db
DB_POOL_SIZE=5
DB_CONNECT_TIMEOUT_SECONDS=10
DB_BUSY_TIMEOUT_MS=10000
DB_CACHE_SIZE_KB=8192
DB_WAL_AUTOCHECKPOINT_PAGES=1000
DB_MMAP_SIZE_MB=256
DB_LOCK_RETRY_COUNT=3
DB_LOCK_RETRY_BASE_MS=50
DB_PRAGMA_OPTIMIZE_INTERVAL_SECONDS=21600
DB_ANALYZE_INTERVAL_SECONDS=86400
DB_WAL_CHECKPOINT_INTERVAL_SECONDS=43200
DB_WAL_CHECKPOINT_MODE=PASSIVE
# ==================== 并发控制配置 ====================
MAX_CONCURRENT_GLOBAL=2