Learn VisualLearn DB Visual
JA

Compare the Work, Not the Label

A sequential scan reads table pages in order, while an index scan follows keys to candidate rows and then fetches rows. The index uses a tree structure called a B-tree; the next lesson covers how it works. The planner estimates both paths. In a 5,000-row table, matching only 1 row means the index path reads just 2 pages, but a query returning most rows or a small table still touches nearly every page even with an index, so a sequential scan is cheaper.

Does creating an index force PostgreSQL to use it?