checkCache -> recordCacheHit -> UPDATE artifacts SET hit_count = hit_count + 1, last_accessed_at = ?, updated_at = ? on the request path, autocommit. idx_artifacts_last_accessed moves on every hit, so the update is non-HOT (pg_stat_user_tables: 11,563 updates, 1,235 HOT); ~4.8 commits per request in total. The counters exist only for LRU eviction and the UI.
Suggestion: buffer hits in a channel and flush every few seconds as one UPDATE ... SET hit_count = hit_count + $n, last_accessed_at = $t per artifact (keep the index, eviction orders by it), plus a flush on shutdown.
checkCache->recordCacheHit->UPDATE artifacts SET hit_count = hit_count + 1, last_accessed_at = ?, updated_at = ?on the request path, autocommit.idx_artifacts_last_accessedmoves on every hit, so the update is non-HOT (pg_stat_user_tables: 11,563 updates, 1,235 HOT); ~4.8 commits per request in total. The counters exist only for LRU eviction and the UI.Suggestion: buffer hits in a channel and flush every few seconds as one
UPDATE ... SET hit_count = hit_count + $n, last_accessed_at = $tper artifact (keep the index, eviction orders by it), plus a flush on shutdown.