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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>, "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 02:08:34
Message-ID: 28300.1194574114@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

I wrote:
> I did do some experimentation and found that among the ASCII characters
> (ie, codes 32-126), nearly all the non-C locales on my Fedora machine
> sort Z last and z next-to-last or vice versa. Most of the remainder
> sort digits last and z or Z as the last non-digit character. Since Z is
> not that close to the end of the sort order in C locale, however, z
> seems the best bet.

With still further experimentation, it seems that doesn't work very
well, because the locales that sort digits last also seem not to
discriminate against digits in their first pass. What did seem to work
was:

* Determine which of the strings "Z", "z", "y", "9" is seen as largest
by strcoll().

* Append this string to the given input.

* Search (using the CVS-HEAD make_greater_string logic) for a string
greater than that.

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...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tommy 2007-11-09 02:22:05 How to determine if psql returns ZERO to the "shell" and finished successfully?
Previous Message Trevor Talbot 2007-11-09 01:46:08 Re: New tzdata available

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2007-11-09 07:08:56 Re: Help understanding stat numbers
Previous Message Tom Lane 2007-11-09 00:42:31 Re: Join performance