<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Postgresql on Brian Faust</title><link>https://vacua.dev/tags/postgresql/</link><description>Recent content in Postgresql on Brian Faust</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Mon, 01 Jan 0001 00:00:00 +0000</lastBuildDate><atom:link href="https://vacua.dev/tags/postgresql/rss.xml" rel="self" type="application/rss+xml"/><item><title>An Index Must Serve a Real Query</title><link>https://vacua.dev/thoughts/an-index-must-serve-a-real-query/</link><pubDate>Sun, 01 Oct 2017 00:00:00 +0000</pubDate><guid>https://vacua.dev/thoughts/an-index-must-serve-a-real-query/</guid><description>&lt;p&gt;A production query needed a small page of recent records requiring operational
attention. The table already had an index which looked relevant. The measured
scan still discarded 84,003 historical index entries and recorded 122,936
shared-buffer reads before finding 83 eligible rows.&lt;/p&gt;
&lt;p&gt;The missing index was not “an index on the table.” It was an index for this
query:&lt;/p&gt;
&lt;figure class="code-figure"&gt;
 &lt;div class="code-block" data-copy-code&gt;
 &lt;button class="copy-code" type="button" aria-label="Copy code"&gt;copy&lt;/button&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;one tenant
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;active records with zero price
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;created during the last three months
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;newest creation time first
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;stable identifier as the tie-breaker
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;first page only&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
 &lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;Indexing starts with the access path, not with a list of columns which sound
important.&lt;/p&gt;</description></item></channel></rss>