Overview - Index-only scans mental model
What is it?
An index-only scan is a way PostgreSQL can answer a query using just the data stored in an index, without reading the full table rows. It happens when all the requested columns are available in the index itself. This makes the query faster because it avoids extra work reading the main table data. It is a special optimization that saves time and resources.
Why it matters
Without index-only scans, PostgreSQL must read both the index and the table data to answer queries, which takes more time and slows down applications. Index-only scans reduce disk reads and speed up queries, especially on large tables. This means users get faster responses and servers handle more work efficiently.
Where it fits
Before learning index-only scans, you should understand basic indexing and how PostgreSQL uses indexes to find data. After this, you can explore query planning and execution details, and advanced indexing techniques like covering indexes and bitmap index scans.