Skip to content

Query Store collector never collects on Azure SQL Database #1836

Description

@erikdarlingdata

Spun out of #1833's triage (the reporter's other empty grid). Verified in source, not yet reproduced live on Azure.

query_store_stats is one of two database-scoped collectors that never opted into the Azure per-database connection path (RunsPerDatabase); #1833's fix handles the other one (procedure_stats), but Query Store is design-sized rather than a one-line override, because the collector is built on BuildEnumerationQuery + BuildPerItemQuery while the Azure per-database branch drives BuildQuery.

What happens today on Azure SQL DB:

  • The collector runs once on the server entry's own connection (catalog defaults to master when the entry's Database field is blank).
  • Its Azure enumeration cursors candidate databases and probes each via QUOTENAME(@db) + N'.sys.sp_executesql' (QueryStoreCollector.cs:255-261) — a cross-database three-part reference, which Azure SQL DB rejects for every database, from master or from any user database alike (the repo already documents this behavior class at RunningJobsCollector.cs:148-150).
  • Every probe fails into an empty CATCH, the result list comes back empty, and the run logs SUCCESS with 0 rows.

So even with the Database field set correctly, Query Store data on Azure is never collected — and on a logical server with several databases, a correct fix collects each database's Query Store, which the single-connection shape can't do at all.

Sketch:

  1. An Azure per-database BuildQuery variant that does the sys.database_query_store_options eligibility check inline against the current database (actual_state IN (1, 2, 4) AND readonly_reason & 8 = 0, same predicates as the on-prem probe) and returns the per-item payload for DB_NAME().
  2. RunsPerDatabase => target.IsAzureSqlDb, with the enumeration/per-item pair remaining the on-prem path.
  3. The empty CATCH at QueryStoreCollector.cs:260-261 should record probe failures somewhere visible even on-prem — a database that always fails its probe is currently indistinguishable from a database with Query Store off.

Darling runs the identical shared definition and has the same gap.

🤖 Generated with Claude Code

Activity

  1. added a commit that references this issue on Jul 30, 2026
  2. erikdarlingdata commented on Jul 31, 2026

    @erikdarlingdata
    OwnerAuthor

    Shipped in #1844 (merged to dev; auto-close does not fire on non-default-branch merges). Query Store now runs per database on Azure SQL DB with the eligibility gate inline; live-Azure validation is tracked by #1848.

  3. added a commit that references this issue on Aug 7, 2026
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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions