Re: empty string causes planner to avoid index. Makes me sad.

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Jeff Amiel <becauseimjeff(at)yahoo(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: empty string causes planner to avoid index. Makes me sad.
Date: 2009-11-27 23:07:43
Message-ID: 20091127145258.K69561@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 27 Nov 2009, Jeff Amiel wrote:

> --- On Fri, 11/27/09, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> > You didn't show us any evidence of that, either. Both
> > of your test
> > cases are using the index.
>
> Ok...third try. The cost when passing in an empty string is
> SIGNIFICANTLY higher than when not. Wouldn't seem that the planner is
> using the index effectively.

But it's also estimating that it's aggregating over around 10000 times as
many rows presumably because it thinks empty string is alot more common.
That might not be the case in the actual data, but the estimated
difference is the likely cause of the plan differences. What are the
actual runtimes and rowcounts for the queries with different values you're
trying? Explain analyze output would be useful for that.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-11-27 23:10:31 Re: empty string causes planner to avoid index. Makes me sad.
Previous Message Scott Marlowe 2009-11-27 22:58:37 Re: vacuumdb -z do a reindex?