Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 0F83D9F9F0F for ; Tue, 31 Oct 2006 19:47:53 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 73572-10 for ; Tue, 31 Oct 2006 19:47:47 -0400 (AST) X-Greylist: delayed 00:29:04.230027 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id D72B09FB2E1 for ; Tue, 31 Oct 2006 19:47:42 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from cbio.mskcc.org (cbio.mskcc.org [140.163.254.35]) by svr4.postgresql.org (Postfix) with ESMTP id 378715AF9E7 for ; Tue, 31 Oct 2006 23:18:30 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by cbio.mskcc.org (Postfix) with ESMTP id 5F46D61B5E for ; Tue, 31 Oct 2006 18:18:26 -0500 (EST) Received: from cbio.mskcc.org ([127.0.0.1]) by localhost (cbio [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23794-10 for ; Tue, 31 Oct 2006 18:18:24 -0500 (EST) Received: from [172.21.218.242] (mrchips.mskcc.org [172.21.218.242]) by cbio.mskcc.org (Postfix) with ESMTP id CE86D61B5C for ; Tue, 31 Oct 2006 18:18:24 -0500 (EST) Message-ID: <4547D9CE.2040705@cbio.mskcc.org> Date: Tue, 31 Oct 2006 18:18:38 -0500 From: John Major User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Help w/speeding up range queries? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at cbio.mskcc.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.316 tagged_above=0 required=5 tests=BAYES_50, SARE_MILLIONSOF X-Spam-Level: X-Archive-Number: 200610/637 X-Sequence-Number: 21766 Hello- #I am a biologist, and work with large datasets (tables with millions of rows are common). #These datasets often can be simplified as features with a name, and a start and end position (ie: a range along a number line. GeneX is on some chromosome from position 10->40) I store these features in tables that generally have the form: SIMPLE_TABLE: FeatureID(PrimaryKey) -- FeatureName(varchar) -- FeatureChromosomeName(varchar) -- StartPosition(int) -- EndPosition(int) 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; This kind of query is VERY slow, and I've tried tinkering with indexes to speed it up, but with little success. Indexes on Chromosome help a little, but it I can't think of a way to avoid full table scans for each of the position range queries. Any advice on how I might be able to improve this situation would be very helpful. Thanks! John