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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user