<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ashraf</title>
    <description>The latest articles on DEV Community by Ashraf (@ash_mse).</description>
    <link>https://dev.to/ash_mse</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2538854%2F5fe07d14-0ff3-4e12-9494-7b2a7683295b.jpg</url>
      <title>DEV Community: Ashraf</title>
      <link>https://dev.to/ash_mse</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ash_mse"/>
    <language>en</language>
    <item>
      <title>Why I don't trust AI with my query plans</title>
      <dc:creator>Ashraf</dc:creator>
      <pubDate>Sat, 14 Feb 2026 10:26:55 +0000</pubDate>
      <link>https://dev.to/ash_mse/why-i-dont-trust-ai-with-my-query-plans-1aed</link>
      <guid>https://dev.to/ash_mse/why-i-dont-trust-ai-with-my-query-plans-1aed</guid>
      <description>&lt;p&gt;I got tired of EXPLAIN tools that sent my query plans to AI services or hallucinated index suggestions. So I built something different.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Last month I was debugging a slow query at work. The EXPLAIN output was &lt;strong&gt;400 lines of JSON&lt;/strong&gt;. I tried three different "AI-powered" analyzers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Two suggested adding an index that &lt;strong&gt;already existed&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;One hallucinated a table name that &lt;strong&gt;wasn't in my database&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I just wanted to know: &lt;strong&gt;where did the time actually go?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The realization
&lt;/h2&gt;

&lt;p&gt;Current tools fall into two camps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AI wrappers&lt;/strong&gt; – Send your plan to OpenAI, get generic advice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visualizers&lt;/strong&gt; – Pretty graphs, but you still interpret them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Neither tells you &lt;em&gt;"4.5 seconds were spent in triggers, 0.03ms in the scan."&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://plancheck.dev" rel="noopener noreferrer"&gt;&lt;strong&gt;PlanCheck&lt;/strong&gt;&lt;/a&gt; is a client-side PostgreSQL &lt;code&gt;EXPLAIN&lt;/code&gt; analyzer with one rule: &lt;strong&gt;truth only&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; No AI. No API calls. No "smart" suggestions.&lt;/li&gt;
&lt;li&gt; 100% client-side. Your query plans &lt;strong&gt;never leave the browser&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; Hardcoded rules based on actual PostgreSQL behavior.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  18 edge cases I tested
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Issue&lt;/th&gt;
&lt;th&gt;What it looks like&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Trigger amplification&lt;/td&gt;
&lt;td&gt;4.5s in triggers, 0.03ms in scan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JIT overhead&lt;/td&gt;
&lt;td&gt;700ms compilation to save 100ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bitmap recheck failure&lt;/td&gt;
&lt;td&gt;Index returns 15K rows, all discarded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recursive CTE runaway&lt;/td&gt;
&lt;td&gt;100K iterations with 99.9% filter rejection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Partition pruning failure&lt;/td&gt;
&lt;td&gt;53M rows scanned, 1 returned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;... plus 13 more&lt;/td&gt;
&lt;td&gt;(too many to list, but you get the idea)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The technical challenge
&lt;/h2&gt;

&lt;p&gt;Parsing &lt;code&gt;EXPLAIN&lt;/code&gt; output in the browser sounds easy. It's not.&lt;/p&gt;

&lt;p&gt;PostgreSQL has &lt;strong&gt;40+ node types&lt;/strong&gt;. Each has different fields, metrics, and edge cases. I had to handle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;TEXT&lt;/code&gt; format (messy indentation, inconsistent fields)&lt;/li&gt;
&lt;li&gt;JSON with &lt;code&gt;null&lt;/code&gt; values (missing timing data)&lt;/li&gt;
&lt;li&gt;"Never executed" nodes that shouldn't be flagged&lt;/li&gt;
&lt;li&gt;Deep nesting (4+ levels of nested loops)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All while keeping the bundle &lt;strong&gt;under 200KB&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What "truth only" actually means
&lt;/h2&gt;

&lt;p&gt;When a tool suggests &lt;em&gt;"add an index,"&lt;/em&gt; it's guessing your intent. Maybe you want that full table scan for analytics. Maybe the index exists but PostgreSQL chose not to use it.&lt;/p&gt;

&lt;p&gt;So PlanCheck only reports &lt;strong&gt;measurable facts&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Scanned 1M rows sequentially"&lt;/li&gt;
&lt;li&gt;"Trigger took 4.5s, scan took 0.03ms"&lt;/li&gt;
&lt;li&gt;"Index returned 15k rows, recheck discarded all"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;You decide what to fix.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://plancheck.dev" rel="noopener noreferrer"&gt;&lt;strong&gt;plancheck.dev&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Paste your &lt;code&gt;EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)&lt;/code&gt; output. No signup. No data collection.&lt;/p&gt;

&lt;h2&gt;
  
  
  What should I add next?
&lt;/h2&gt;

&lt;p&gt;I'm looking for edge cases I haven't tested yet. If you have a query plan that breaks it, &lt;strong&gt;I want to see it&lt;/strong&gt;. Drop a comment or reach out!&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>database</category>
      <category>performance</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
