Re: query against large table not using sensible index to find very small amount of data - Mailing list pgsql-performance

From Jeff Janes
Subject Re: query against large table not using sensible index to find very small amount of data
Date
Msg-id CAMkU=1wXAoZFdNmh43B+RvmsG4RfmPXaMLqi+imU81WWFSw_cA@mail.gmail.com
Whole thread Raw
In response to Re: query against large table not using sensible index to find very small amount of data  (Shaun Thomas <sthomas@optionshouse.com>)
List pgsql-performance
On Tue, Apr 8, 2014 at 6:39 AM, Shaun Thomas <sthomas@optionshouse.com> wrote:

> Other possibly relevant pieces of information...  The entity type
> column has a cardinality in the neighborhood of a couple dozen.
> Meanwhile, for some of the entity types there is a large and ongoing
> number of events, and for other entity types there is a smaller and
> more sporadic number of events.  Every now and again a new entity
> type shows up.

With that as the case, I have two questions for you:

1. Why do you have a low cardinality column as the first column in an index?

Because if he didn't have it, the planner would never be able to use it.  Remember, the problem is when the planner chooses NOT to use that index.

Cheers,

Jeff

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Performance regressions in PG 9.3 vs PG 9.0
Next
From: uher dslij
Date:
Subject: Re: Performance regressions in PG 9.3 vs PG 9.0