Switch language한국어
Back to the list

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

TL;DR AI

Key summary

2 min read
  1. 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.

  2. The article explains why: table rows live in heap pages, and B+ tree indexes point to those heap rows for fast retrieval.

  3. 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.

  4. 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.

Read the original