<story><title>PostgreSQL Count(*) Performance Improvements</title><url>https://www.cybertec-postgresql.com/en/count-made-fast/</url></story><parent_chain></parent_chain><comment><author>shay_ker</author><text>The headline makes it sound like they did work to &lt;i&gt;improve&lt;/i&gt; the performance of count(*) in the postgres code, when that&amp;#x27;s not at all what the article is about.&lt;p&gt;This post from Citus is far more informative:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.citusdata.com&amp;#x2F;blog&amp;#x2F;2016&amp;#x2F;10&amp;#x2F;12&amp;#x2F;count-performance&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.citusdata.com&amp;#x2F;blog&amp;#x2F;2016&amp;#x2F;10&amp;#x2F;12&amp;#x2F;count-performance&amp;#x2F;&lt;/a&gt;</text></comment>
<story><title>PostgreSQL Count(*) Performance Improvements</title><url>https://www.cybertec-postgresql.com/en/count-made-fast/</url></story><parent_chain></parent_chain><comment><author>BenMorganIO</author><text>Given the title, I expected this to be about how PG improved their counting. This is not what it was about.&lt;p&gt;I remember working over half a billion records and having problems when I needed a count. I used count(id) but that was mainly from internet mantra. I did not see an improvement. Using Citus gave me a significant improvement from 7 minutes to 1. And that was just a single coordinator, two workers on the same host. It could become much much better.&lt;p&gt;If the data is very stagnant and writes are very low the triggers are great. Usually the &amp;quot;close enough&amp;quot; with pages is good if you have over 100k since paging - please correct me if I&amp;#x27;m wrong - is sometimes 1k off.&lt;p&gt;My preference is Citus as a catch all, but a trigger, a Redis cache managed at the app level, or using page counts are all . really useful for stickier situations.</text></comment>