May 2018
Intermediate to advanced
576 pages
30h 25m
English
PostgreSQL can choose between two techniques available to compute the SQL count(*) function. Both are available in all the currently supported versions.
The first is called sequential scan. We access every data block in the table one after the other, reading the number of rows in each block. If the table is on the disk, it will cause a beneficial disk access pattern, and the statement will be fairly fast.
The other technique is known as index-only scan. It requires an index on the table, and it covers a more general case than optimizing SQL queries with count(*), so we will cover it in more detail in Chapter 10, Performance and Concurrency.
Some people think that the count SQL statement is a good test of the performance of ...