Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToDbQ-0003uR-IJ for pgsql-docs@arkaria.postgresql.org; Thu, 27 Dec 2012 13:34:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1ToDbP-0004Ua-IJ for pgsql-docs@arkaria.postgresql.org; Thu, 27 Dec 2012 13:34:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToDbO-0004UU-QT for pgsql-docs@postgresql.org; Thu, 27 Dec 2012 13:34:26 +0000 Received: from mout.gmx.net ([212.227.17.20]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ToDbM-0006E0-3r for pgsql-docs@postgresql.org; Thu, 27 Dec 2012 13:34:26 +0000 Received: from mailout-de.gmx.net ([10.1.76.35]) by mrigmx.server.lan (mrigmx001) with ESMTP (Nemesis) id 0M1Tap-1SvYgB433Z-00tRlq for ; Thu, 27 Dec 2012 14:34:23 +0100 Received: (qmail invoked by alias); 27 Dec 2012 13:34:22 -0000 Received: from pool-108-52-108-60.phlapa.fios.verizon.net (EHLO [192.168.1.10]) [108.52.108.60] by mail.gmx.net (mp035) with SMTP; 27 Dec 2012 14:34:22 +0100 X-Authenticated: #495269 X-Provags-ID: V01U2FsdGVkX186YCMGVZg64DfVXTCoN5+zjIIrXU7vXyrnno/Pkz BNzLa0TnSD2EPv Message-ID: <1356615259.13340.4.camel@vanquo.pezone.net> Subject: Re: pattern matching indexing From: Peter Eisentraut To: Tom Lane Cc: pgsql-docs@postgresql.org Date: Thu, 27 Dec 2012 08:34:19 -0500 In-Reply-To: <4603.1356361965@sss.pgh.pa.us> References: <1356360300.5854.2.camel@vanquo.pezone.net> <4603.1356361965@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.4.4-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org On Mon, 2012-12-24 at 10:12 -0500, Tom Lane wrote: > Peter Eisentraut writes: > > To index pattern matching, you can use the _pattern_ops operator > > classes, or you can set the column collation in the index to "C". The > > latter option doesn't appear to be documented (unless you read very deep > > between the lines). Is that intentional? > > It is stated at > http://www.postgresql.org/docs/devel/static/indexes-opclass.html > that you don't need the special pattern opclasses in C locale. > Feel free to rephrase or document elsewhere if you find that too > obscure. What it doesn't make very clear is that you can also override the locale in the index definition itself. So instead of the recommended CREATE INDEX test_index ON test_table (col varchar_pattern_ops); you can write nearly equivalently CREATE INDEX test_index ON test_table (col COLLATE "C"); I'm also wondering whether the latter wouldn't be a preferable recommendation going forward. I suppose it's also a matter of taste, but such an index can also be used for other things (e.g. ORDER BY col COLLATE "C"), and it uses less obscure and magic functionality. -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs