jrajasekera/claude-skills/sqlite-optimization
Claude Code and agent skill by jrajasekera/claude-skills
- community
Checking that the SKILL.md file is still in the repository.
Optimize SQLite database performance through configuration, schema design, indexing, and query tuning. Use when users ask to improve SQLite speed, reduce latency, optimize queries, configure PRAGMAs, fix slow queries, handle concurrency, optimize writes/inserts, or tune SQLite for production. Triggers on mentions of SQLite performance, slow queries, PRAGMA settings, WAL mode, indexing strategies, bulk inserts, or database maintenance (VACUUM, ANALYZE).
Install
npx vskill@latest install jrajasekera/claude-skills/sqlite-optimizationSKILL.md
SQLite Performance Optimization
Quick Start: Baseline Configuration
Set these PRAGMAs on every connection for most applications:
Run periodically:
Optimization Workflow
1. Diagnose with EXPLAIN QUERY PLAN
Key indicators:
SCAN TABLE→ Full table scan (O(N)) — needs index or query rewriteSEARCH TABLE USING INDEX→ Index lookup (O(log N)) — goodCOVERING INDEX→ Index-only scan, no table lookup — optimalUSE TEMP B-TREE→ Sorting not covered by index — consider index with ORDER BY columns
2. Schema Design
Use INTEGER PRIMARY KEY for rowid alias:
Choose appropriate types:
INTEGERfor IDs, counters, booleansREALfor floatsTEXTfor strings- Avoid large BLOBs in hot tables; use separate table or external files
WITHOUT ROWID for junction tables:
3. Indexing Strategy
Create indexes for real query patterns:
Covering indexes eliminate table lookups:
Partial indexes for subsets:
Expression indexes:
Avoid indexing:
- Small tables (< hundreds of rows)
- Low-cardinality columns alone (booleans)
- Columns rarely in WHERE/JOIN/ORDER BY
4. Write Optimization
Always batch writes in transactions:
Throughput jumps from ~50 inserts/sec (autocommit) to 50,000+ inserts/sec.
Use prepared statements:
Optimal batch size: 1,000–10,000 rows balances throughput vs memory.
5. Concurrency Configuration
WAL mode enables concurrent readers + one writer:
- Readers don't block writers
- Writers don't block readers
- Uses
.waland.shmfiles alongside main DB
Handle contention:
Architecture pattern: Single writer thread/process + many reader connections.
6. Maintenance
VACUUM after large deletes:
- Run during maintenance windows (blocking operation)
- Requires free disk space ≈ DB size
Auto-vacuum for incremental reclaim:
Keep statistics fresh:
Reference Files
- [pragma-reference.md](references/pragma-reference.md) — Complete PRAGMA settings with tradeoffs
- [indexing-guide.md](references/indexing-guide.md) — Advanced indexing patterns and diagnostics
- [architecture.md](references/architecture.md) — SQLite internals: B-trees, VDBE, Pager, concurrency mechanics
Common Anti-Patterns
| Problem | Solution | |
|---|---|---|
SELECT * | List only needed columns | |
| Loop with single inserts | Batch in transaction | |
| Correlated subquery per row | Rewrite as JOIN | |
| Index on every column | Index only queried columns | |
No busy_timeout | Set appropriate timeout | |
| Rollback journal mode | Switch to WAL | |
| Never running ANALYZE | Run PRAGMA optimize periodically |
Environment-Specific Notes
Mobile (iOS/Android):
- WAL +
synchronous = NORMAL - Background maintenance jobs for VACUUM
- Local storage only (not SD card)
Server/Desktop:
- Centralize writes in single thread if possible
- Set PRAGMAs immediately after connection open
- Consider connection pooling with writer serialization
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/sqlite-optimization/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 3
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 23 Mar 2026, 8 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jrajasekera/claude-skills/sqlite-optimization)