Re: Re: Query not using index

From: Chris Jones <chris(at)mt(dot)sri(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: ryan(at)paymentalliance(dot)net, pgsql-general(at)postgresql(dot)org
Subject: Re: Re: Query not using index
Date: 2001-05-10 21:34:18
Message-ID: 20010510153418.G26743@mt.sri.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, May 10, 2001 at 05:22:07PM -0400, Tom Lane wrote:

> ryan(at)paymentalliance(dot)net writes:
> > No the query usually returns between 0 and 5 rows. Usually not zero -
> > most often 1.
>
> Ah. You must have a few values that are far more frequent (like tens of
> thousands of occurrences?) and these are throwing off the planner's
> statistics.

I had a similar situation, where I had a lot of rows with 0's in
them. Changing those to NULLs worked wonders. The planner (or
statistics gatherer, or something) apparently takes notice of the
distribution of non-NULL values.

Chris

--
chris(at)mt(dot)sri(dot)com -----------------------------------------------------
Chris Jones SRI International, Inc.
www.sri.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-05-10 21:43:15 Re: Re: Query not using index
Previous Message John Coers 2001-05-10 21:30:36 Re: COPY locking