optimizing "between" queries

From: Kyle <kaf(at)nwlink(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: optimizing "between" queries
Date: 2001-01-22 20:23:57
Message-ID: 14956.38621.306933.780332@ip146.usw5.rb1.bel.nwlink.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table where I need to select elements that are between
certain values. The typical query would be like:

select foo from bar where
element1 between ? and ? and -- using some val_1a and val_1b
element2 between ? and ? and -- using some val_2a and val_2b
...
element30 between ? and ?;

ie- we've got 30 elements here. The runtime is acceptable now with
10k rows in the table (about 0.04 seconds). However, the table size
will grow to the milions in the near future.

The data for element1..30 are int2's and columns element1..element30
have been ordered by how well they discriminate. Can I use "cluster"
on more than one column with indexes per column to improve the search
time? How else might I be able to tweak this?

thanks,
Kyle

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Héctor Balanzar 2001-01-22 20:28:49 Changing pgsql error messages...
Previous Message Brian E. Pangburn 2001-01-22 19:07:15 [General] Comments