Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id BB74D1337B9D for ; Thu, 13 Jan 2011 12:18:13 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 59282-09 for ; Thu, 13 Jan 2011 16:18:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.yitter.info (mail.yitter.info [208.86.224.201]) by mail.postgresql.org (Postfix) with ESMTP id 78FCD1337B98 for ; Thu, 13 Jan 2011 12:18:05 -0400 (AST) Received: from crankycanuck.ca (69-196-144-230.dsl.teksavvy.com [69.196.144.230]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.yitter.info (Postfix) with ESMTPSA id 5EA4B1ECB41F for ; Thu, 13 Jan 2011 16:18:04 +0000 (UTC) Date: Thu, 13 Jan 2011 11:18:02 -0500 From: Andrew Sullivan To: pgsql-general@postgresql.org Subject: Re: Case Sensitivity Message-ID: <20110113161801.GZ26731@shinkuro.com> Mail-Followup-To: Andrew Sullivan , pgsql-general@postgresql.org References: <20110113152528.218550@gmx.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201101/316 X-Sequence-Number: 171675 On Thu, Jan 13, 2011 at 03:29:03PM -0000, Phillip Smith wrote: > modifying user inputted data is not an option for me. I need to > maintain the original data. I had read about indexing on a lower > function. This all seems a bit of a bodgy workaround to me. A clean > Case Insensitive collation setting is cleaner. Is this supported in > postgreSQL 9? There isn't such a collation setting as far as I know, and it's actually not as clean as you think. It turns out to work reasonably well in ASCII-land, but not very well in other circumstances. In general, the case-insensitive but case-preserving technique that English-speaking computer users have come to find normal is a bad fit for a wide variety of languages. (Even "Latin" characterset-using languages have trouble, because of historic ways of handling accents. Is the capital version of é E or É? Well, both, it turns out, depending on whom you believe. I could bore you about the effects of this in the DNS all day long, but I'll resist the temptation.) Putting an index on lower(column) and then doing all your comparisons with lower(datum) works fairly well, and I don't see how it's any more bodgy than a database-wide case insensitive collation. For instance, I can assure you that customers named Leblanc and LeBlanc care about whether those two compare equally. In your customer name field, if you have a database-wide collation setting, you can't make the distinction. A -- Andrew Sullivan ajs@crankycanuck.ca