Tom Lane wrote:

It seemed reasonable to me that a select on the first element of an
array column could use an index on the column, but, as seen in this
example, I can't get it to do so:

Nope.  The operators that go along with a btree index are equality,
less than, etc on the whole indexed column.  btree knows nothing
about extracting array elements.

I guess I was working by analogy with queries like this:

  select * from someTable where textColumn like 'foo%';

This will happily use an ordinary btree index on textColumn, right? (Although I know it's only for the C locale with the default op class.) Anyway, I guess this is a far more common case than matching the prefix of an array. Like another poster suggested, I can have an additional expression index on the first element of my array column.

- John Burger
  MITRE

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

              http://archives.postgresql.org/

Reply via email to