<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sql on My New Hugo Project</title><link>https://example.org/en/tags/sql/</link><description>Recent content in Sql on My New Hugo Project</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2026 Blog Author</copyright><lastBuildDate>Sat, 15 Aug 2026 09:00:00 +0800</lastBuildDate><atom:link href="https://example.org/en/tags/sql/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Query Performance Tuning</title><link>https://example.org/en/db/sql-tuning/</link><pubDate>Sat, 15 Aug 2026 09:00:00 +0800</pubDate><guid>https://example.org/en/db/sql-tuning/</guid><description>&lt;h2 class="relative group"&gt;Finding slow queries&#10; &lt;div id="finding-slow-queries" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#finding-slow-queries" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Enable the slow-query log: &lt;code&gt;log_min_duration_statement&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Analyze plans with &lt;code&gt;EXPLAIN ANALYZE&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;Watch &lt;code&gt;pg_stat_statements&lt;/code&gt; for the most frequent SQL&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&#10;&lt;h2 class="relative group"&gt;Common performance killers&#10; &lt;div id="common-performance-killers" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#common-performance-killers" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Full table scans&lt;/strong&gt;: missing indexes or conditions that can&amp;rsquo;t use them&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Implicit type casts&lt;/strong&gt;: functions on indexed columns disable the index&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;N+1 queries&lt;/strong&gt;: querying row-by-row inside a loop&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Large-offset pagination&lt;/strong&gt;: &lt;code&gt;OFFSET 1000000&lt;/code&gt; gets slower as you page&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&#10;&lt;h2 class="relative group"&gt;Fixes&#10; &lt;div id="fixes" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#fixes" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Rewrite SQL: drive big tables with small result sets (join order)&lt;/li&gt;&#10;&lt;li&gt;Use indexes wisely: covering and composite indexes&lt;/li&gt;&#10;&lt;li&gt;Denormalize judiciously: precomputed summary tables&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&#10;&lt;h2 class="relative group"&gt;Summary&#10; &lt;div id="summary" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#summary" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h2&gt;&#10;&lt;p&gt;SQL tuning is about &lt;strong&gt;understanding the execution plan&lt;/strong&gt;. Locate the bottleneck first, then fix it — don&amp;rsquo;t blindly add indexes.&lt;/p&gt;</description></item></channel></rss>