pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gregory Stark <stark@enterprisedb.com>
To: Guillaume Smet <guillaume.smet@gmail.com>
To: pgsql-performance <pgsql-performance@postgresql.org>
To: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] Estimation problem with a LIKE clause containing a /
Date: Thu, 08 Nov 2007 21:08:34 -0500
Message-ID: <28300.1194574114@sss.pgh.pa.us> (raw)
In-Reply-To: <25287.1194568820@sss.pgh.pa.us>
References: <1d4e0c10711070453q214f089cpd144cbb5193d3c4f@mail.gmail.com>
	<17767.1194453292@sss.pgh.pa.us>
	<11467.1194477248@sss.pgh.pa.us>
	<1d4e0c10711080208n6c9875b4tf5882da3ced18532@mail.gmail.com>
	<27405.1194542548@sss.pgh.pa.us>
	<87prykpc3q.fsf@oxford.xeocode.com>
	<25287.1194568820@sss.pgh.pa.us>

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



view thread (21+ messages)  latest in thread

Message-ID: <28300.1194574114@sss.pgh.pa.us>
Permalink:  ../28300.1194574114@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28300.1194574114@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, stark@enterprisedb.com, guillaume.smet@gmail.com, pgsql-hackers@postgresql.org
  Subject: Re: [HACKERS] Estimation problem with a LIKE clause containing a /
  In-Reply-To: <28300.1194574114@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox