index
Covering
Payload columns can make an index cover a query. PostgreSQL index-only scans also depend on visibility information; coverage alone does not guarantee the plan. Target: PostgreSQL 17. Use a disposable database; plan selection is not guaranteed.
Formal Syntax & Structure
sql syntaxsql
CREATE INDEX ix ON items(category) INCLUDE (price)Working Example
Example Snippetsql
CREATE TABLE items(id integer primary key, category integer, price integer, name text, active integer); INSERT INTO items VALUES (1,1,10,'Alpha',1),(2,1,20,'Beta',0),(3,2,30,'Gamma',1);CREATE INDEX ix ON items(category) INCLUDE (price);SELECT price FROM items WHERE category=2;