<?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: Haleh</title>
    <description>The latest articles on DEV Community by Haleh (@bright98).</description>
    <link>https://dev.to/bright98</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1022391%2F8207cf80-c94f-4bf4-b1f0-e2f4dcaeaf0c.jpeg</url>
      <title>DEV Community: Haleh</title>
      <link>https://dev.to/bright98</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bright98"/>
    <language>en</language>
    <item>
      <title>gotracer: Turn Go Execution Traces into Actionable Findings</title>
      <dc:creator>Haleh</dc:creator>
      <pubDate>Thu, 28 May 2026 18:00:26 +0000</pubDate>
      <link>https://dev.to/bright98/gotracer-turn-go-execution-traces-into-actionable-findings-42l8</link>
      <guid>https://dev.to/bright98/gotracer-turn-go-execution-traces-into-actionable-findings-42l8</guid>
      <description>&lt;p&gt;&lt;code&gt;go tool trace&lt;/code&gt; provides a browser UI for exploring Go execution traces. It works well for manual&lt;br&gt;
investigation, but it doesn't fit into scripts or CI pipelines — you can't grep the output, set&lt;br&gt;
thresholds, or fail a build based on what the trace contains.&lt;/p&gt;


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

&lt;p&gt;Go execution traces contain detailed runtime events: GC pauses, goroutine scheduling delays, mutex&lt;br&gt;
waits, syscall blocks, heap growth, and more. These don't appear in application logs or metrics —&lt;br&gt;
they're only visible inside the trace.&lt;/p&gt;

&lt;p&gt;Without a way to set thresholds or run checks automatically, there's no practical path to catching&lt;br&gt;
these issues in CI. You can't fail a build because a GC pause exceeded 20ms or flag a goroutine&lt;br&gt;
count that keeps growing across releases.&lt;/p&gt;

&lt;p&gt;Teams often end up investigating traces only when something is already slow in production.&lt;/p&gt;


&lt;h2&gt;
  
  
  Introducing gotracer
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/bright98/gotracer" rel="noopener noreferrer"&gt;gotracer&lt;/a&gt; reads a Go execution trace, applies a set of&lt;br&gt;
rules, and outputs findings — to the terminal, as JSON, or as an HTML report.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/bright98/gotracer/cmd/gotracer@latest

curl &lt;span class="nt"&gt;-o&lt;/span&gt; trace.out &lt;span class="s2"&gt;"http://localhost:6060/debug/pprof/trace?seconds=5"&lt;/span&gt;
gotracer analyze trace.out
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SEVERITY  RULE                   TIMESTAMP  MESSAGE
--------  ----                   ---------  -------
ERROR     GCPauseSpike           1.204s     GC pause of 45ms exceeds Error threshold (20ms)
WARN      HighSchedulingLatency  300ms      goroutine 42 waited 18ms to be scheduled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Eight rules are included: GC pauses, scheduling latency, mutex contention, syscall blocks, goroutine&lt;br&gt;
leak growth, heap spikes, processor starvation, and GC mark assist waits. Each finding includes a&lt;br&gt;
timestamp and a suggested fix; repeated occurrences are grouped with a count.&lt;/p&gt;


&lt;h2&gt;
  
  
  CI integration
&lt;/h2&gt;

&lt;p&gt;gotracer exits &lt;code&gt;1&lt;/code&gt; on any Warn or Error finding, so it can be used as a CI gate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gotracer analyze trace.out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If one code path triggers the same rule many times, &lt;code&gt;--top N&lt;/code&gt; limits findings per rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gotracer analyze trace.out &lt;span class="nt"&gt;--top&lt;/span&gt; 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;When used as a Go library, each rule's thresholds are configurable. This is useful when different&lt;br&gt;
services have different latency requirements — a batch job and a low-latency API don't share the&lt;br&gt;
same acceptable GC pause.&lt;/p&gt;




&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;gotracer is built on &lt;code&gt;golang.org/x/exp/trace&lt;/code&gt;, the structured trace reader introduced in Go 1.22.&lt;br&gt;
Each rule processes the event stream once, so memory usage stays low even on large traces.&lt;/p&gt;




&lt;p&gt;Source and docs: &lt;strong&gt;&lt;a href="https://github.com/bright98/gotracer" rel="noopener noreferrer"&gt;github.com/bright98/gotracer&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>cli</category>
      <category>tooling</category>
    </item>
    <item>
      <title>Stop Reading EXPLAIN Plans by Hand: Introducing pgexplain and pgwatch 🐘</title>
      <dc:creator>Haleh</dc:creator>
      <pubDate>Wed, 20 May 2026 09:15:52 +0000</pubDate>
      <link>https://dev.to/bright98/stop-reading-explain-plans-by-hand-introducing-pgexplain-and-pgwatch-2j97</link>
      <guid>https://dev.to/bright98/stop-reading-explain-plans-by-hand-introducing-pgexplain-and-pgwatch-2j97</guid>
      <description>&lt;p&gt;PostgreSQL gives you a detailed execution plan for every query. Reading it is a skill — interpreting it correctly under pressure, at scale, or across dozens of slow queries is another thing entirely. Most developers either skip the plan entirely or paste it into an online visualizer and hope for the best.&lt;/p&gt;

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

&lt;p&gt;You run a slow query. PostgreSQL hands you this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Plan"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Node Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hash Join"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Actual Rows"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;923847&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Actual Loops"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Plans"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"Node Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Seq Scan"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"Relation Name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"orders"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"Actual Rows"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1000000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"Node Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"Batches"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"Memory Usage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4096&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Execution Time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;1243.821&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now what? The plan is telling you something. A sequential scan on a million-row table. A hash join that spilled across 8 batches. But connecting those dots to a concrete action — add an index here, raise &lt;code&gt;work_mem&lt;/code&gt; there — takes experience that not everyone has, and time that no one has enough of.&lt;/p&gt;

&lt;h2&gt;
  
  
  pgexplain: automated plan analysis
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/bright98/pgexplain" rel="noopener noreferrer"&gt;&lt;strong&gt;pgexplain&lt;/strong&gt;&lt;/a&gt; is a Go library and CLI that parses &lt;code&gt;EXPLAIN (ANALYZE, FORMAT JSON)&lt;/code&gt; output and surfaces actionable findings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pgexplain plan.json

&lt;span class="o"&gt;[&lt;/span&gt;WARN]  sequential scan on &lt;span class="s2"&gt;"orders"&lt;/span&gt; discards 8332x more rows than it returns
  node:       Seq Scan &lt;span class="o"&gt;(&lt;/span&gt;ID 1&lt;span class="o"&gt;)&lt;/span&gt;
  detail:     PostgreSQL &lt;span class="nb"&gt;read &lt;/span&gt;100000 rows from &lt;span class="s2"&gt;"orders"&lt;/span&gt; but only 12 matched
              &lt;span class="o"&gt;(&lt;/span&gt;customer_id &lt;span class="o"&gt;=&lt;/span&gt; 42&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;8332 rows discarded per row returned&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
  suggestion: Add an index on &lt;span class="s2"&gt;"orders"&lt;/span&gt; to support the filter &lt;span class="o"&gt;(&lt;/span&gt;customer_id &lt;span class="o"&gt;=&lt;/span&gt; 42&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
              Run EXPLAIN &lt;span class="o"&gt;(&lt;/span&gt;ANALYZE, BUFFERS&lt;span class="o"&gt;)&lt;/span&gt; after adding the index to confirm it is used.

1 finding: 0 error&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt;, 1 warning&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt;, 0 info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of staring at a wall of JSON, you get a ranked list of what's wrong and what to do about it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Supported rules
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;th&gt;What it catches&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SeqScan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sequential scan that discards far more rows than it returns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;RowEstimateMismatch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Planner estimates off by 10× or more&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;HashJoinSpill&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Hash joins that spill to disk&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NestedLoopLarge&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Nested loops with large outer input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;MissingIndexOnlyScan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Heap fetches defeating an index-only scan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SortSpill&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sort operations that spill to disk&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;TopNHeapsort&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;LIMIT queries using slow heapsort&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ParallelNotLaunched&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Parallel plans where workers never started&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;MergeJoinUnsortedInputs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Merge Join with explicit Sort children&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;HighTempBlockIO&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;High temp block I/O from aggregations, window functions, CTEs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Use it in CI
&lt;/h3&gt;

&lt;p&gt;pgexplain exits with code &lt;code&gt;1&lt;/code&gt; if any &lt;code&gt;Warn&lt;/code&gt; or &lt;code&gt;Error&lt;/code&gt; findings are found, which makes it a drop-in CI gate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;psql &lt;span class="nt"&gt;-U&lt;/span&gt; myuser &lt;span class="nt"&gt;-d&lt;/span&gt; mydb &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"EXPLAIN (ANALYZE, FORMAT JSON) SELECT * FROM orders WHERE customer_id = 42"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | pgexplain &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Gate your pull requests on query plan quality, not just correctness.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use it as a library
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;explainJSON&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;adv&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;advisor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;rules&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SeqScan&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="n"&gt;rules&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RowEstimateMismatch&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="n"&gt;rules&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HashJoinSpill&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="c"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;adv&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Analyze&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"[%s] %s&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;  → %s&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Severity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Suggestion&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Embed it in your own slow query logger, migration runner, or developer CLI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/bright98/pgexplain/cmd/pgexplain@latest
&lt;span class="c"&gt;# or as a library&lt;/span&gt;
go get github.com/bright98/pgexplain
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  pgwatch: continuous slow query monitoring
&lt;/h2&gt;

&lt;p&gt;Catching bad plans during development is only half the battle. On a live server, slow queries happen continuously — and most teams only notice them after a user complains.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/bright98/pgwatch" rel="noopener noreferrer"&gt;&lt;strong&gt;pgwatch&lt;/strong&gt;&lt;/a&gt; is a daemon that tails your PostgreSQL log file, extracts the &lt;code&gt;auto_explain&lt;/code&gt; plans that PostgreSQL writes for every slow query, and feeds them through pgexplain automatically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PostgreSQL log file
      │
      ▼
pgwatch  ←─── tails &amp;amp; parses auto_explain JSON blocks
      │
      ▼
pgexplain rule engine  ←─── detects the real problems
      │
      ▼
terminal / JSON / HTML report
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No database connection required. It's a pure log reader — it never executes &lt;code&gt;EXPLAIN&lt;/code&gt; itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the output looks like
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=== pgwatch report — Wed, 13 May 2026 14:00:00 UTC ===

#1  2026-05-10 14:23:01 UTC  myuser@mydb  duration=1243.82ms  [auto_explain]
    [ERROR] node=1 (Hash Join) — hash batch spill to disk
             Inner side wrote 42 MB to temp files across 8 batches.
             → Increase work_mem or reduce the join input size.

#2  2026-05-10 14:31:44 UTC  myuser@mydb  duration=891.10ms  [auto_explain]
    [WARN] node=2 (Seq Scan) — sequential scan discards 5000x more rows than it returns
             → Add an index on "events" to support the filter (user_id = 99).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Quick start
&lt;/h3&gt;

&lt;p&gt;Enable &lt;code&gt;auto_explain&lt;/code&gt; in &lt;code&gt;postgresql.conf&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="py"&gt;shared_preload_libraries&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'auto_explain'&lt;/span&gt;
&lt;span class="py"&gt;auto_explain.log_min_duration&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;1000   # ms&lt;/span&gt;
&lt;span class="py"&gt;auto_explain.log_format&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;json&lt;/span&gt;
&lt;span class="py"&gt;auto_explain.log_analyze&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;on&lt;/span&gt;
&lt;span class="py"&gt;log_line_prefix&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'%m [%p] %q%u@%d '&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/bright98/pgwatch/cmd/pgwatch@latest

&lt;span class="nb"&gt;cp &lt;/span&gt;pgwatch.example.yaml pgwatch.yaml
&lt;span class="c"&gt;# set log_file to your PostgreSQL log path&lt;/span&gt;

pgwatch run &lt;span class="nt"&gt;-c&lt;/span&gt; pgwatch.yaml      &lt;span class="c"&gt;# daemon mode — flushes a report every hour&lt;/span&gt;
pgwatch report &lt;span class="nt"&gt;-c&lt;/span&gt; pgwatch.yaml   &lt;span class="c"&gt;# one-shot — read the log once and exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output formats
&lt;/h3&gt;

&lt;p&gt;pgwatch supports three output formats — &lt;code&gt;terminal&lt;/code&gt; (default), &lt;code&gt;json&lt;/code&gt;, and &lt;code&gt;html&lt;/code&gt;. The HTML report is self-contained with no external dependencies: collapsible plan JSON, color-coded severity badges, and sortable findings.&lt;/p&gt;




&lt;h2&gt;
  
  
  How they fit together
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;When to use it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;pgexplain&lt;/code&gt; (CLI)&lt;/td&gt;
&lt;td&gt;Analyzes a single plan file or psql pipe&lt;/td&gt;
&lt;td&gt;During development, in CI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;pgexplain&lt;/code&gt; (library)&lt;/td&gt;
&lt;td&gt;Embeds plan analysis into your own Go tool&lt;/td&gt;
&lt;td&gt;Custom tooling, migration runners&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pgwatch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Continuously monitors production slow query logs&lt;/td&gt;
&lt;td&gt;Staging and production servers&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;pgexplain&lt;/strong&gt; in development and CI to catch bad plans before they ship.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;pgwatch&lt;/strong&gt; in production to know which queries are hurting you right now, with suggestions attached.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/bright98/pgexplain" rel="noopener noreferrer"&gt;pgexplain on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/bright98/pgwatch" rel="noopener noreferrer"&gt;pgwatch on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both are written in Go, require no extensions beyond &lt;code&gt;auto_explain&lt;/code&gt; (which ships with PostgreSQL), and are MIT licensed. Feedback and contributions are welcome.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>go</category>
      <category>cli</category>
      <category>database</category>
    </item>
  </channel>
</rss>
