Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PostgreSQLQueryStoreSqlText — Query Store SQL Text

The full SQL text for each Queryid, so runtime and wait stats can be made human-readable. Join to PostgreSQLFlexQueryStoreRuntime or PostgreSQLFlexQueryStoreWaitStats on Queryid_str_s.

No rows were present in the my-la-workspace workspace at the time of writing — fields below are per Microsoft's schema.

Kusto query

let server = "my-pg-prd-1";
AzureDiagnostics
| where Category == "PostgreSQLQueryStoreSqlText" and LogicalServerName_s == server
| project Queryid_str_s, Dbid_d, Userid_d, Query_sql_text_s

Fields

  • Queryid_d (number) — query fingerprint (prefer Queryid_str_s).
  • Queryid_str_s (string) — string form of the fingerprint (join key).
  • Query_sql_text_s (string) — the normalized/captured SQL text.
  • Dbid_d (number) — database OID.
  • Userid_d (number) — role OID.

Use cases — troubleshooting

  • Make runtime/wait stats readable — resolve a Queryid_str_s to its actual SQL when investigating a slow or heavy query.
  • Identify the offending statement — turn a top-by-Total_time_d fingerprint into the real query to optimize/index.
  • Detect un-parameterized SQL — spot near-duplicate texts that should be using bind parameters.
  • Audit / review — see exactly which statements a given Userid_d or Dbid_d runs.