<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Query Store on Rudi Bruchez</title><link>https://www.pachadata.com/en/tags/query-store/</link><description>Recent content in Query Store on Rudi Bruchez</description><generator>Hugo</generator><language>en</language><lastBuildDate>Wed, 21 Oct 2026 19:34:11 +0200</lastBuildDate><atom:link href="https://www.pachadata.com/en/tags/query-store/index.xml" rel="self" type="application/rss+xml"/><item><title>Analyzing the Query Store with an AI agent</title><link>https://www.pachadata.com/en/docs/articles/sql-server/performance/query-store-agent/</link><pubDate>Wed, 21 Oct 2026 00:00:00 +0000</pubDate><guid>https://www.pachadata.com/en/docs/articles/sql-server/performance/query-store-agent/</guid><description>&lt;p&gt;&lt;em&gt;Co-written with Claude, who ran the lab tests and part of the research.&lt;/em&gt;&lt;/p&gt;&#10;&lt;div class="alert alert-success" role="alert"&gt;&lt;div class="h4 alert-heading" role="heading"&gt;TL;DR&lt;/div&gt;&#10;&lt;p&gt;Searching the Query Store by hand, query by query, takes hours. A command-line agent (Claude Code, Codex) does it on its own if it has &lt;code&gt;sqlcmd&lt;/code&gt; and a dedicated login that holds only &lt;code&gt;VIEW DATABASE STATE&lt;/code&gt; in each database: it reads the query texts, the plans and the runtime statistics, and gets error 229 on any table. For more caution, &lt;code&gt;DBCC CLONEDATABASE&lt;/code&gt; produces a copy without data that contains the Query Store, to restore on another instance.&lt;/p&gt;&#10;&lt;p&gt;The Query Store does not keep everything. In &lt;code&gt;AUTO&lt;/code&gt; capture mode, an ad hoc query is only recorded from 30 executions or a certain cost onward: in my measurements, a read of the whole &lt;code&gt;Contact.Contact&lt;/code&gt; table (120,140 rows) split into 25 queries left no trace. A query run from &lt;code&gt;master&lt;/code&gt; or &lt;code&gt;tempdb&lt;/code&gt; is recorded nowhere, and a &lt;code&gt;TRUNCATE TABLE&lt;/code&gt; never is. The agent only finds what the Query Store kept.&lt;/p&gt;&#10;&lt;/div&gt;</description></item><item><title>Query Store capture modes</title><link>https://www.pachadata.com/en/docs/articles/sql-server/performance/query-store-capture-modes/</link><pubDate>Wed, 21 Oct 2026 00:00:00 +0000</pubDate><guid>https://www.pachadata.com/en/docs/articles/sql-server/performance/query-store-capture-modes/</guid><description>&lt;p&gt;&lt;em&gt;Co-written with Claude, who ran the lab tests and part of the research.&lt;/em&gt;&lt;/p&gt;&#10;&lt;div class="alert alert-success" role="alert"&gt;&lt;div class="h4 alert-heading" role="heading"&gt;TL;DR&lt;/div&gt;&#10;&lt;p&gt;In &lt;code&gt;AUTO&lt;/code&gt; mode, the default since SQL Server 2019, the Query Store records a query only when it reaches 30 executions, one second of compile CPU or 100 ms of execution CPU. The executions before that point are not counted in the Query Store. Queries inside stored procedures are captured from their first execution, but since SQL Server 2022 cursors are subject to the thresholds, contrary to what the documentation says. &lt;code&gt;ALL&lt;/code&gt; records everything, including thousands of ad hoc queries that never run again.&lt;/p&gt;&#10;&lt;/div&gt;</description></item><item><title>What the Query Store records</title><link>https://www.pachadata.com/en/docs/articles/sql-server/performance/query-store-collection/</link><pubDate>Wed, 21 Oct 2026 00:00:00 +0000</pubDate><guid>https://www.pachadata.com/en/docs/articles/sql-server/performance/query-store-collection/</guid><description>&lt;p&gt;&lt;em&gt;Co-written with Claude, who ran the lab tests and part of the research.&lt;/em&gt;&lt;/p&gt;&#10;&lt;div class="alert alert-success" role="alert"&gt;&lt;div class="h4 alert-heading" role="heading"&gt;TL;DR&lt;/div&gt;&#10;&lt;p&gt;The Query Store keeps the text, the plans and the runtime statistics of the queries it captures, but not who ran them, nor the parameter values beyond compilation. Even in &lt;code&gt;ALL&lt;/code&gt; mode, it sees neither &lt;code&gt;TRUNCATE TABLE&lt;/code&gt;, nor &lt;code&gt;CREATE TABLE&lt;/code&gt;, nor &lt;code&gt;ALTER TABLE&lt;/code&gt;, nor &lt;code&gt;DBCC CHECKTABLE&lt;/code&gt;, nor ad hoc queries run from &lt;code&gt;master&lt;/code&gt; or &lt;code&gt;tempdb&lt;/code&gt;. A query that fails or that the client cancels is recorded, a session ended by &lt;code&gt;KILL&lt;/code&gt; leaves only its text and its plan, and a hard shutdown of the instance erases the statistics not yet written to disk.&lt;/p&gt;&#10;&lt;/div&gt;</description></item></channel></rss>