Skip to content

RecordArtifactHit runs a synchronous non-HOT UPDATE artifacts in its own transaction on every hit #322

Description

@pinguinfuss

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions