Skip to content

Leading/left-most on compound index? #10

@jeremyisatrecharm

Description

@jeremyisatrecharm

I have a query that uses a compound index like (customer_id, is_premium). The index advisor wants me to add an index for customer_id but Postgres is using the compoound index (as confirmed by EXPLAIN) and note that the docs say:

A multicolumn B-tree index can be used with query conditions that involve any subset of the index's columns, but the index is most efficient when there are constraints on the leading (leftmost) column

https://www.postgresql.org/docs/current/indexes-multicolumn.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions