public inbox for [email protected]  
help / color / mirror / Atom feed
From: Peter Eisentraut <[email protected]>
To: Tom Lane <[email protected]>
Cc: [email protected]
Subject: Re: pattern matching indexing
Date: Thu, 27 Dec 2012 08:34:19 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-docs>

On Mon, 2012-12-24 at 10:12 -0500, Tom Lane wrote:
> Peter Eisentraut <[email protected]> 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 ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



view thread (4+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pattern matching indexing
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox