Optimize database batch operations with prepared statements

- Add prepared statements to all batch operations for better performance
- Fix database lock contention by properly batching operations
- Update SQLite settings for extreme performance (8GB cache, sync OFF)
- Add proper error handling for statement closing
- Update tests to properly track batch operations
This commit is contained in:
2025-07-28 17:21:40 +02:00
parent b9b0792df9
commit 40d7f0185b
8 changed files with 721 additions and 49 deletions
+3 -5
View File
@@ -144,11 +144,9 @@ func (h *ASHandler) flushBatchLocked() {
}
}
for asn, ts := range asnMap {
_, err := h.db.GetOrCreateASN(asn, ts)
if err != nil {
h.logger.Error("Failed to get/create ASN", "asn", asn, "error", err)
}
// Process all ASNs in a single batch transaction
if err := h.db.GetOrCreateASNBatch(asnMap); err != nil {
h.logger.Error("Failed to process ASN batch", "error", err, "count", len(asnMap))
}
// Clear batch