Menu

PostgreSQL Redundant Indexes: Is an Index on (a) Redundant When You Have (a, b)?
📰

PostgreSQL Redundant Indexes: Is an Index on (a) Redundant When You Have (a, b)?

DEV Community: postgres·Son Tran·7 days ago
#UhKMJjay
#devtopostgresql#devto#dev#index#redundant
Long article (2166 words) — no AI summary yet.
Reading 0:00
15s threshold

Disclosure: I build Schemity , a desktop ERD tool - this post is from our blog and uses it for the examples.

TL;DR: A plain b-tree index on (a) is redundant when another b-tree index starts with a , such as (a, b) : PostgreSQL 18.3 served the same lookup from the wider index with the same number of heap reads. Do not drop it on that rule if it is UNIQUE , uses a different operator class or has INCLUDE columns the wider one lacks, and judge a partial or hash index on its own. Usage counters will not tell you which one to drop.

You can usually drop a PostgreSQL index on (a) once a b-tree index on (a, b) exists, because the wider index finds the same rows for every lookup on a .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.