Re: [HACKERS] Estimation problem with a LIKE clause containing a /

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Guillaume Smet" <guillaume(dot)smet(at)gmail(dot)com>, "pgsql-performance" <pgsql-performance(at)postgresql(dot)org>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Estimation problem with a LIKE clause containing a /
Date: 2007-11-09 09:21:56
Message-ID: 87hcjvpydn.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> This rule works for all the locales I have installed ... but I don't
> have any Far Eastern locales installed. Also, my test cases are only
> covering ASCII characters, and I believe many locales have some non-ASCII
> letters that sort after 'Z'. I'm not sure how hard we need to try to
> cover those corner cases, though. It is ultimately only an estimate...

If I understand correctly what we're talking about it's generating estimates
for LIKE 'foo%' using the algorithm which makes sense for C locale which means
generating the next range of values which start with 'foo%'.

It seems to me the problematic situations is when the most-frequent-values
come into play. Being off slightly in the histogram isn't going to generate
very inaccurate estimates but including or not a most-frequent-value could
throw off the estimate severely.

Could we not use the bogus range to calculate the histogram estimate but apply
the LIKE pattern directly to the most-frequent-values instead of applying the
bogus range? Or would that be too much code re-organization for now?

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2007-11-09 09:23:36 Re: Free Space Map thoughts
Previous Message Magnus Hagander 2007-11-09 09:17:05 Re: New tzdata available

Browse pgsql-performance by date

  From Date Subject
Next Message Florian Weimer 2007-11-09 11:30:33 Re: dell versus hp
Previous Message Guillaume Smet 2007-11-09 07:52:49 Re: [HACKERS] Estimation problem with a LIKE clause containing a /