Skip to content
Nov 3, 2026 - Version 2026.10 has been released
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Optimize your top queries

Surface the queries consuming the most time and resources, then act on them.

Ask the assistant to rank the heaviest queries on an instance, explain why they are expensive, and turn that into concrete tuning actions.

Animated replay of a chat with an AI assistant, condensed from a real session of about seven minutes. The user asks: Drill into the slowest queries on prod-eu-2 around 10 a.m. this morning. The assistant confirms the window 09:40-10:20 local, reads the platform through the Datasentinel tools (workload, top queries, query details, blocking scenarios, top tables, table details), then returns a workload analysis: four key points, four key findings each with evidence, an action and the expected gain, a captured execution plan with its sequential scans highlighted, the table scan context, and a menu of next steps.
One prompt, from the question to the tuning actions: a real session of about seven minutes, condensed into one

The assistant can also retrieve the execution plans of these queries when the pg_store_plans extension is installed on the monitored instance. Plans are collected automatically alongside query statistics, so the recommendations can point at the actual scan, join, or sort step to fix. To get the plan the planner would choose right now instead, for a statement you paste or for the query on screen, see Explain execution plans.

Example prompts:

  • Rank and drill down:

    • "Drill into the slowest queries on prod-eu-2 around 10 a.m. this morning."

    • "Show me all the metrics of the heaviest delete on prod-eu-1 today."

    • "Which query spills the most to temp files on prod-eu-1?"

  • Execution plans:

    • "Show me the captured execution plan of the slowest query on prod-eu-1 this morning."

    • "Did the execution plan of the heaviest select on prod-eu-1 change today?"

Continue from the menu. Once the ranking is on screen, the next-step menu lets you drill into one query (full SQL, wait events, execution plan), check the tables it hammers, or ask the assistant to prove a finding before you act on it. Pick an option to keep the investigation going without retyping the context.

Last updated