Re: query against large table not using sensible index to find very small amount of data

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Shaun Thomas <sthomas(at)optionshouse(dot)com>
Cc: "Andrew W(dot) Gibbs" <awgibbs(at)awgibbs(dot)com>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: query against large table not using sensible index to find very small amount of data
Date: 2014-04-08 22:51:46
Message-ID: CAMkU=1wXAoZFdNmh43B+RvmsG4RfmPXaMLqi+imU81WWFSw_cA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, Apr 8, 2014 at 6:39 AM, Shaun Thomas <sthomas(at)optionshouse(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message uher dslij 2014-04-09 00:16:30 Re: Performance regressions in PG 9.3 vs PG 9.0
Previous Message Tom Lane 2014-04-08 21:26:37 Re: Performance regressions in PG 9.3 vs PG 9.0