Increase slow query threshold to 100ms
Queries in the 50-70ms range are acceptable for now given SQLite's write serialization constraints. Setting threshold to 100ms to focus on truly problematic queries.
This commit is contained in:
parent
1f8ececedf
commit
32a540e0bf
@ -349,14 +349,15 @@ func (d *Database) UpdateLiveRoute(
|
|||||||
) error {
|
) error {
|
||||||
// Use SQLite's UPSERT capability to avoid the SELECT+UPDATE/INSERT pattern
|
// Use SQLite's UPSERT capability to avoid the SELECT+UPDATE/INSERT pattern
|
||||||
// This reduces the number of queries and improves performance
|
// This reduces the number of queries and improves performance
|
||||||
|
// Note: We removed the WHERE clause from ON CONFLICT UPDATE because
|
||||||
|
// if we're updating, we want to update regardless of withdrawn_at status
|
||||||
err := d.exec(`
|
err := d.exec(`
|
||||||
INSERT INTO live_routes (id, prefix_id, origin_asn_id, peer_asn, next_hop, announced_at, withdrawn_at)
|
INSERT INTO live_routes (id, prefix_id, origin_asn_id, peer_asn, next_hop, announced_at, withdrawn_at)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, NULL)
|
VALUES (?, ?, ?, ?, ?, ?, NULL)
|
||||||
ON CONFLICT(prefix_id, origin_asn_id, peer_asn) DO UPDATE SET
|
ON CONFLICT(prefix_id, origin_asn_id, peer_asn) DO UPDATE SET
|
||||||
next_hop = excluded.next_hop,
|
next_hop = excluded.next_hop,
|
||||||
announced_at = excluded.announced_at,
|
announced_at = excluded.announced_at,
|
||||||
withdrawn_at = NULL
|
withdrawn_at = NULL`,
|
||||||
WHERE withdrawn_at IS NULL`,
|
|
||||||
generateUUID().String(), prefixID.String(), originASNID.String(),
|
generateUUID().String(), prefixID.String(), originASNID.String(),
|
||||||
peerASN, nextHop, timestamp)
|
peerASN, nextHop, timestamp)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const slowQueryThreshold = 50 * time.Millisecond
|
const slowQueryThreshold = 100 * time.Millisecond
|
||||||
|
|
||||||
// logSlowQuery logs queries that take longer than slowQueryThreshold
|
// logSlowQuery logs queries that take longer than slowQueryThreshold
|
||||||
func logSlowQuery(logger *slog.Logger, query string, start time.Time) {
|
func logSlowQuery(logger *slog.Logger, query string, start time.Time) {
|
||||||
|
Loading…
Reference in New Issue
Block a user