Re: Help w/speeding up range queries?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Major <major(at)cbio(dot)mskcc(dot)org>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Help w/speeding up range queries?
Date: 2006-11-01 04:29:09
Message-ID: 12189.1162355349@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

John Major <major(at)cbio(dot)mskcc(dot)org> writes:
> My problem is, I often need to execute searches of tables like these
> which find "All features within a range".
> Ie: select FeatureID from SIMPLE_TABLE where FeatureChromosomeName like
> 'chrX' and StartPosition > 1000500 and EndPosition < 2000000;

A standard btree index is just going to suck for these types of queries;
you need something that's actually designed for spatial range queries.
You might look at the contrib/seg module --- if you can store your
ranges as "seg" datatype then the seg overlap operator expresses what
you need to do, and searches on an overlap operator can be handled well
by a GIST index.

Also, there's the PostGIS stuff, though it might be overkill for what
you want.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Carlos H. Reimer 2006-11-01 05:23:17 Context switching
Previous Message mark 2006-11-01 00:20:26 Re: MVCC & indexes?