I Tested PostgreSQL on 5 Million Rows, Here’s What Actually Makes Queries Fast

TL;DR AI
2 min readKey summary
On a 5-million-row PostgreSQL table, a forced sequential scan took about 277 ms, while a primary-key index scan answered the same lookup in about 0.05 ms.
The article explains why: table rows live in heap pages, and B+ tree indexes point to those heap rows for fast retrieval.
It also notes that index-only scans can be even faster when the needed columns are covered and MVCC visibility checks allow PostgreSQL to skip heap access.
Bottom line: query performance in PostgreSQL depends heavily on the access path, and the right index can turn a multi-hundred-millisecond scan into an almost instant lookup.

