Re: very slow left join

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Ben <bench(at)silentmedia(dot)com>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: very slow left join
Date: 2008-05-16 19:25:17
Message-ID: 482DDF9D.1030102@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Ben wrote:
> On Fri, 16 May 2008, Scott Marlowe wrote:
>
>> Well, I'm guessing that you aren't in locale=C and that the text
>
> Correct, I am not. And my understanding is that by moving to the C
> locale, I would loose utf8 validation, so I don't want to go there.
> Though, it's news to me that I would get any kind of select performance
> boost with locale=C. Why would it help?

As far as I know the difference is that in the "C" locale PostgreSQL can
use simple byte-ordinal-oriented rules for sorting, character access,
etc. It can ignore the possibility of a character being more than one
byte in size. It can also avoid having to consider pairs of characters
where the ordinality of the numeric byte value of the characters is not
the same as the ordinality of the characters in the locale (ie they
don't sort in byte-value order).

If I've understood it correctly ( I don't use "C" locale databases
myself and I have not tested any of this ) that means that two UTF-8
encoded strings stored in a "C" locale database might not compare how
you expect. They might sort in a different order to what you expect,
especially if one is a 2-byte or more char and the other is only 1 byte.
They might compare non-equal even though they contain the same sequence
of Unicode characters because one is in a decomposed form and one is in
a precomposed form. The database neither knows the encoding of the
strings nor cares about it; it's just treating them as byte sequences
without any interest in their meaning.

If you only ever work with 7-bit ASCII, that might be OK. Ditto if you
never rely on the database for text sorting and comparison.

Someone please yell at me if I've mistaken something here.

--
Craig Ringer

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Alvaro Herrera 2008-05-16 20:15:28 Re: I/O on select count(*)
Previous Message Ben 2008-05-16 18:43:12 Re: very slow left join