Re: Indexes on array columns

From: karly(at)kipshouse(dot)org
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Indexes on array columns
Date: 2006-03-16 06:30:13
Message-ID: 20060315223013.A4976@kipshouse.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Mar 15, 2006 at 09:36:04AM -0700, Brendan Duddridge wrote:
> Hi,
>
> Is it possible to put an index on an array column?

Apparently yes (I just did it as a test). However, consider the
following from the manual.

Tip: Arrays are not sets; searching for specific array elements
may be a sign of database misdesign. Consider using a separate
table with a row for each item that would be an array element. This
will be easier to search, and is likely to scale up better to large
numbers of elements.[1]

Arrays are attractive, but it seems they most often aren't the best
solution. FOr instance, I beleive I read somewhere that the index
will be on the whole array, and the individual elements are not
indexed, so

WHERE ary = {foo,bar}

might benefit from your index, but

WHERE 'foo' = ANY(ary)

probably wouldn't. At least that's the impression I got from
reading the archives of this list. I haven't done any testing of
it.

-karl

1. http://www.postgresql.org/docs/8.0/interactive/arrays.html#AEN5491

>
> Thanks,
>
> ____________________________________________________________________
> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan(at)clickspace(dot)com
>
> ClickSpace Interactive Inc.
> Suite L100, 239 - 10th Ave. SE
> Calgary, AB T2G 0V9
>
> http://www.clickspace.com
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Harald Armin Massa 2006-03-16 06:30:36 Re: What's a good default encoding?
Previous Message Michael Glaesemann 2006-03-16 06:13:42 Re: invalid UTF-8 byte sequence detected