Re: How to add locale support for each column?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: How to add locale support for each column?
Date: 2004-09-19 19:24:33
Message-ID: 20788.1095621873@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Greg Stark <gsstark(at)mit(dot)edu> writes:
> I don't see how this is relevant though. One way or another postgres is going
> to have to sort strings in varying locales chosen at run-time. Comparing
> against strcoll's execution time without changing changing locales is a straw
> man.

No, it's not, because if we were to do our own implementation we could
avoid the need to do setlocale per se at all (inside the loop that is).
The trick is to expose the different locales as objects (pointed-to
structs) that can be passed to the strcoll function. The fundamental
difficulty is not so much with the libc innards as with the lousy API.

> I see no reason to think Postgres's implementation of looking up xfrm rules
> for the specified locale will be any faster than the OS's.

The point is that we can move that lookup out of the inner loop.

> An order of magnitude change in the cost for strcoll isn't really relevant
> unless the cost for strcoll is significant to begin with. I suspect strcoll
> costs are currently dwarfed by the palloc costs to evaluate the expression
> already.

I don't have numbers for that at my fingertips, but I have measured it
in the past, and the comparison function *is* a significant part of the
total CPU cost in sorts.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dennis Bjorklund 2004-09-19 19:25:31 Re: How to add locale support for each column?
Previous Message Stephan Szabo 2004-09-19 19:22:57 Re: How to add locale support for each column?

Browse pgsql-patches by date

  From Date Subject
Next Message Dennis Bjorklund 2004-09-19 19:25:31 Re: How to add locale support for each column?
Previous Message Stephan Szabo 2004-09-19 19:22:57 Re: How to add locale support for each column?