Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id D281D9FA12B for ; Wed, 1 Nov 2006 00:29:57 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 22543-05 for ; Wed, 1 Nov 2006 04:29:55 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id EE4A99F9F80 for ; Wed, 1 Nov 2006 00:29:24 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id kA14T92j012190; Tue, 31 Oct 2006 23:29:10 -0500 (EST) To: John Major cc: pgsql-performance@postgresql.org Subject: Re: Help w/speeding up range queries? In-reply-to: <4547D9CE.2040705@cbio.mskcc.org> References: <4547D9CE.2040705@cbio.mskcc.org> Comments: In-reply-to John Major message dated "Tue, 31 Oct 2006 18:18:38 -0500" Date: Tue, 31 Oct 2006 23:29:09 -0500 Message-ID: <12189.1162355349@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/1 X-Sequence-Number: 21771 John Major 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