Skip to content

Query Store backfill: the candidate database list aggregates up to four days of raw rows per server per tick #4662

Closed

Description

@erikdarlingdata

The Query Store backfill worker lists its candidate databases for each server on every tick with SELECT DISTINCT database_name FROM query_store_stats WHERE server_id = $1 AND collection_time > $2 ORDER BY database_name (QueryStoreBackfill.CandidateSql). $2 reaches back up to the raw tier's horizon, about four days. So each call aggregates up to four days of one server's raw Query Store rows, including compressed chunks, to return a handful of names.

Measured

On one production store, pg_stat_statements over four days: 47,599 calls, 96 ms mean, 4,563 s total, and 5.65 billion shared blocks hit (about 118,000 per call), plus 88 M read.

Expected

The same database list, from a read that doesn't aggregate the whole window. For example, a loose index scan down the existing (server_id, database_name, …) index, one probe per database. The result must be identical to today's, including databases known only through a pending backfill hole.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions