Skip site navigation (1) Skip section navigation (2)

Re: arrays and indexes

From: Greg Stark <gsstark(at)mit(dot)edu>
To: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: arrays and indexes
Date: 2004-07-26 06:27:20
Message-ID: 87acxnwaev.fsf@stark.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-performance
"Ross J. Reedstrom" <reedstrm(at)rice(dot)edu> writes:

> In the new schema, the same thing is:
> 
> SELECT * from content where 42 = ANY (authors);
> 
> Works fine, but for the life of me I can't find nor figure out how to
> build an index that will be used to speed this along. Any ideas?

Well that's basically the problem with denormalized data like this.

Have you resolved what you're going to do if two sessions try to add a user to
the same group at the same time? Or how you'll go about removing a user from
all his groups in one shot?

Basically, if you denormalize in this fashion it becomes hard to use the
groups as anything but single monolithic objects. Whereas normalized data can
be queried and updated from other points of view like in the case you name
above.

Postgres does have a way to do what you ask, though. It involves GiST indexes
and the operators from the contrib/intarray directory from the Postgres
source.

However I warn you in advance that this is fairly esoteric stuff and will take
some time to get used to. And at least in my case I found the indexes didn't
actually help much for my data sets, probably because they just weren't big
enough to benefit.

-- 
greg


In response to

Responses

pgsql-performance by date

Next:From: Gaetano MendolaDate: 2004-07-26 14:01:15
Subject: Re: hardware raid suggestions
Previous:From: Ross J. ReedstromDate: 2004-07-26 04:57:10
Subject: arrays and indexes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group