pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: Achilleus Mantzios <achill@matrix.gatewaynet.com>
Cc: Greg Stark <gsstark@mit.edu>
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Gist indexes on int arrays
Date: 04 Mar 2003 10:28:06 -0500
Message-ID: <87smu3kv7d.fsf@stark.dyndns.tv> (raw)
In-Reply-To: <Pine.LNX.4.44.0303040934040.26498-100000@matrix.gatewaynet.com>
References: <Pine.LNX.4.44.0303040934040.26498-100000@matrix.gatewaynet.com>


Achilleus Mantzios <achill@matrix.gatewaynet.com> writes:

> Moreover if your array element positions that you want to compare
> against(e.g attr_a[1], or attr_b[n], where n is the last element) are
> known, then you could have a function "first" that returns
> the first element ...

Except that's precisely what I'm *not* doing. I'm treating the arrays as sets
and looking for records where the set contains a given value. This is a
denormalized table generated nightly from fully normalized raw data.

So to simplify it, the query might have clauses like:

WHERE foo_id = 900
  AND '{5}'::integer[] ~ attribute_set_array

Right now I have a btree index on (foo_id).

Can I have a GiST index on (foo_id, attribute_set_array) and have it be just
as fast at narrowing the search to just foo_id = 900 but also speed up the ~
operation?

Incidentally, it seems odd that there isn't an operator like ~ but optimized
specifically for searching for a single item. It seems awkward and possibly
unnecessarily slow to have to construct an array for the search parameter
every time.

--
greg




view thread (11+ messages)  latest in thread

Message-ID: <87smu3kv7d.fsf@stark.dyndns.tv>
Permalink:  ../87smu3kv7d.fsf@stark.dyndns.tv/
Also on:    postgresql.org/message-id/87smu3kv7d.fsf@stark.dyndns.tv

 · 

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: pgsql-sql@postgresql.org
  Cc: gsstark@mit.edu, achill@matrix.gatewaynet.com
  Subject: Re: Gist indexes on int arrays
  In-Reply-To: <87smu3kv7d.fsf@stark.dyndns.tv>

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

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