Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id C86972E002E for ; Fri, 16 May 2008 16:25:36 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40601-10 for ; Fri, 16 May 2008 16:25:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.61.230.242]) by developer.postgresql.org (Postfix) with ESMTP id 75B522E002D for ; Fri, 16 May 2008 16:25:33 -0300 (ADT) Received: from mail.postnewspapers.com.au (dsl-202-72-149-28.wa.westnet.com.au [202.72.149.28]) by www.postnewspapers.com.au (Postfix) with ESMTP id 745085C0D2; Sat, 17 May 2008 03:25:28 +0800 (WST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 78E441E0435; Sat, 17 May 2008 03:25:33 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id i32zZCo72nfB; Sat, 17 May 2008 03:25:28 +0800 (WST) Received: from [203.161.97.213] (203.161.97.213.static.amnet.net.au [203.161.97.213]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTP id 61B1E1E0434; Sat, 17 May 2008 03:25:28 +0800 (WST) Message-ID: <482DDF9D.1030102@postnewspapers.com.au> Date: Sat, 17 May 2008 03:25:17 +0800 From: Craig Ringer User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Ben Cc: Scott Marlowe , pgsql-performance@postgresql.org Subject: Re: very slow left join References: In-Reply-To: X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/254 X-Sequence-Number: 30222 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