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

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: pgsql-general(at)postgresql(dot)org
Cc: Jeff Amiel <becauseimjeff(at)yahoo(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: empty string causes planner to avoid index. Makes me sad.
Date: 2009-11-27 22:50:54
Message-ID: 200911272350.54263.guillaume@lelarge.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le vendredi 27 novembre 2009 à 23:32:14, Jeff Amiel a écrit :
> --- 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.
>
> Aggregate (cost=231884.57..231884.57 rows=1 width=0)
>
> versus
>
> Aggregate (cost=34.83..34.83 rows=1 width=0)
>

But in the first example (the empty string one), it fetched 170468 rows from
the index, and in the second one (the 17-spaces string), it fetched only 18
rows. It seems quite normal that the first one is costier then the second one.

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Erickson 2009-11-27 22:55:30 Re: Cannot allocate memory for output buffer
Previous Message Jeff Amiel 2009-11-27 22:32:14 Re: empty string causes planner to avoid index. Makes me sad.