SQL fundamentals learning path Level 3 This level · 4 of 6
Medium sql database

How does this differ in PostgreSQL?

PostgreSQL stores every index separately from the table heap: all indexes are secondary indexes. It supports INCLUDE non-key columns and index-only scans, so a covering index can sometimes avoid heap fetches. Visibility information can still require a heap visit, so an index-only scan does not always eliminate every heap access.

CREATE INDEX orders_customer_id_total
  ON orders (customer_id) INCLUDE (total);
-- every PostgreSQL index is secondary; an index-only scan may still visit the heap for visibility
Sources (2)
  1. PostgreSQL documentation — index-only scans and covering indexespostgresql.org
  2. PostgreSQL documentation — CREATE INDEX and INCLUDEpostgresql.org
Previous
Next