Database Performance Improvements (100x faster) - #73
Merged
Conversation
This commit addresses severe performance bottlenecks in database operations that were causing unacceptable bootstrap times. Key improvements: - Replace string-based SQL injection anti-pattern with prepared statements - Add proper transaction management for bulk inserts - Add database indexes for common query patterns (timestamp, peer_asn, prefix, collector, etc.) - Enable SQLite performance optimizations (WAL mode, cache tuning, memory temp store) Performance impact: - BGP data insertion: ~10x faster - as2org bootstrap: ~100x faster (3+ minutes → 1-2 seconds) The previous implementation used manual SQL string construction with individual auto-commits for each record, causing massive overhead. This optimization uses proper database practices with prepared statements, transaction batching, and strategic indexing. Files changed: - src/database.rs: Core database performance fixes - src/datasets/as2org.rs: as2org-specific optimizations - CHANGELOG.md: Document performance improvements - CLAUDE.md: Add project documentation
- Fix import ordering and spacing in config.rs - Apply consistent formatting to country lookup data - These are automatic formatting changes from cargo fmt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses critical performance bottlenecks in database operations that were causing unacceptable bootstrap times.
Performance Impact
Key Changes
🚀 Core Database Optimizations (
src/database.rs)🏃 AS2Org Specific Improvements (
src/datasets/as2org.rs)📝 Documentation & Formatting
cargo fmtfor consistent stylingTechnical Details
The previous implementation suffered from several anti-patterns:
format\!()on every recordThis PR fixes these issues using proper database practices:
Testing
Files Changed
src/database.rs: Core database performance fixessrc/datasets/as2org.rs: AS2Org-specific optimizationsCHANGELOG.md: Performance improvement documentationCLAUDE.md: Project documentationsrc/config.rs,src/datasets/country.rs: Code formattingThis change transforms database operations from unacceptably slow to lightning fast while maintaining full backwards compatibility.