.db3 files) to store millions of chess games efficiently. This guide covers optimization techniques for maximum performance.
Database Architecture
Storage Format
Obsidian Chess Studio uses a custom SQLite schema optimized for chess data:Available Databases
Obsidian Chess Studio provides several pre-optimized databases:Lumbra's Gigabase
9.5M+ games • 526K players • 2.6 GBComprehensive collection of high-quality games.
Caissabase 2024
5.4M+ games • 321K players • 1.2 GBCurated database of notable games.
Position Cache
Pre-calculated statistics • 628 MBAccelerates position searches across major databases.
MillionBase
3.4M+ games • 284K players • 744 MBCompact yet comprehensive database.
Indexing Strategies
Automatic Indexing
Obsidian Chess Studio automatically creates indexes when importing databases. For optimal performance, ensure databases are fully indexed before querying.
Index Types
The backend creates indexes on key fields:- Player Indexes: Fast player name lookups
- Date Indexes: Efficient date range queries
- ELO Indexes: Quick rating-based filtering
- Position Indexes: Accelerated position searches
- Tournament Indexes: Fast tournament game retrieval
Checking Index Status
Query Optimization
Efficient Filtering
Range Normalization
Range Normalization
Avoid unnecessary filters by normalizing ELO ranges:Impact: Reduces query complexity by removing redundant filters.
Skip Count Optimization
Skip Count Optimization
For pagination, skip total count calculation when not needed:Performance Gain: 2-3x faster for large result sets.
Limit Game Details
Limit Game Details
Restrict the number of full game records retrieved:Best Practice: Set to 100-1000 for position searches to balance detail and performance.
Optimal Sort Fields
Optimal Sort Fields
Choose appropriate sort fields based on use case:
| Sort Field | Best For | Performance |
|---|---|---|
id | Sequential browsing | ⚡️ Fastest |
date | Chronological order | ⚡️ Fast |
averageElo | Quality games | 🔶 Moderate |
ply_count | Game length | 🔶 Moderate |
whiteElo, blackElo | Player strength | 🔶 Moderate |
Position Search Optimization
- Use Exact Matching when possible (faster than partial/material matching)
- Apply Date Filters to narrow search scope
- Limit Game Details to 500-1000 games
- Use Position Cache database for frequently searched positions
Cache Management
Position Cache Database
The Position Cache database stores pre-calculated statistics:Automatic Integration
The cache is automatically used for position searches across supported databases.
The Position Cache covers:
- Lumbra’s Gigabase
- Caissabase 2024
- Ajedrez Data (Correspondence & OTB)
- MillionBase
In-Memory Caching
Obsidian Chess Studio implements intelligent caching at multiple levels:Query Result Cache
Query Result Cache
Recent query results are cached in memory using
@tanstack/react-query:Opening Cache
Opening Cache
Opening statistics are cached for the current session to avoid redundant calculations.
Database Info Cache
Database Info Cache
Database metadata (game count, player count, etc.) is cached to reduce file system access.
Clearing Cache
To clear cached data:- In-App: Settings → Advanced → Clear Cache
- Manual: Delete
AppData/cachedirectory - Selective: Use React Query Devtools to clear specific queries
Performance Tuning
Database File Optimization
VACUUM Command
VACUUM Command
Periodically vacuum databases to reclaim space and improve performance:Benefits:
- Removes fragmentation
- Reclaims deleted space
- Optimizes index structures
- Improves query speed by 10-30%
File Location
File Location
Store databases on fast storage:
| Storage Type | Random Read | Impact |
|---|---|---|
| NVMe SSD | < 0.1 ms | ⚡️ Best |
| SATA SSD | < 0.5 ms | ⚡️ Excellent |
| HDD | 10-15 ms | 🔶 Acceptable |
| Network | Varies | ❌ Not recommended |
Query Performance Monitoring
Key metrics to monitor:- Query Time: Target < 500ms for most queries
- Result Set Size: Larger = slower; use pagination
- Cache Hit Rate: Higher = better performance
- Database Size: Impacts memory usage
Concurrent Query Management
Advanced Techniques
Opening Precaching
Pre-calculate opening statistics for faster analysis:- 5-10x faster opening explorer
- Reduced database load
- Smoother user experience
Batch Operations
When performing bulk operations:Transaction Batching
Group multiple writes into single transactions for 10-100x speedup.
Async Processing
Use background workers for large imports to keep UI responsive.
Incremental Updates
Update only changed records rather than full re-imports.
Deferred Indexing
Create indexes after bulk inserts, not during.
ChessBase Online Integration
For cloud-based searches:ChessBase searches have a 30-second timeout and support cancellation for better performance.
Troubleshooting
Slow Query Performance
Slow Query Performance
Symptoms: Queries taking > 5 secondsSolutions:
- Check if database is fully indexed
- Verify database file is on fast storage (SSD)
- Reduce
game_details_limitto 500-1000 - Enable
skipCount: truefor pagination - Use Position Cache database
- Run VACUUM to defragment
High Memory Usage
High Memory Usage
Symptoms: Application using excessive RAMSolutions:
- Reduce concurrent query limit
- Clear query cache: Settings → Clear Cache
- Lower
pageSizein query options - Restart application to clear memory
- Close unused board tabs
Database Corruption
Database Corruption
Symptoms: “corrupted database” error messagesSolutions:
- Re-download the database from a trusted source
- Check disk health (run
chkdskorfsck) - Ensure sufficient disk space during operations
- Avoid force-closing during write operations
Missing Tables
Missing Tables
Symptoms: “no such table” errors
- Database may be incompatible format
- Re-import from PGN source
- Download fresh copy from Databases page
Best Practices Summary
Use Position Cache
Download and use the Position Cache database for 10-50x faster position searches.
Optimize Queries
Use
skipCount, normalize ranges, and limit game details for faster results.Fast Storage
Store databases on SSD for best performance, especially for large databases.
Regular Maintenance
Periodically vacuum databases and clear cache to maintain optimal performance.
Monitor Performance
Enable performance monitoring to identify slow queries and bottlenecks.
Precache Openings
Use opening precaching for frequently analyzed opening positions.
Related Resources
Database Management
Learn about importing and managing databases
Position Search
Advanced position search techniques
Customization
Configure database and performance settings
