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

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jeff Amiel <becauseimjeff(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: empty string causes planner to avoid index. Makes me sad.
Date: 2009-11-30 20:24:22
Message-ID: 4B1429F6.2060903@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> Jeff Amiel <becauseimjeff(at)yahoo(dot)com> writes:
>
>> Ok...third try. The cost when passing in an empty string is SIGNIFICANTLY higher than when not.
>>
>
> That just reflects the fact that it's expecting a lot more rows matching
> that query. I suppose this is because the statistics show you've got a
> lot more rows containing the empty string than other values.
If you believe the statistics the planner is using are not a useful
approximation of your data, you can try raising the
default_statistics_target. IIRC, it was 10 in that version of PG but has
been raised to 100 in the latest version as the improvement due to
additional data available to the planner seems to typically outweigh the
overhead of collecting/storing/processing the additional stats.

Also, are you sure that the table is being analyzed either by autovacuum
or manually (if you analyze your table, does the explain change
significantly?).

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Smith 2009-11-30 20:29:30 Re: READ ONLY & I/O ERROR
Previous Message umut orhan 2009-11-30 19:24:06 setting the block size to a value greater than 32KB