X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 2DB4C9FB38F for ; Mon, 14 Aug 2006 22:53:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 25448-06 for ; Mon, 14 Aug 2006 22:53:44 -0300 (ADT) 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 36AA09FB1C8 for ; Mon, 14 Aug 2006 22:53:45 -0300 (ADT) 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 k7F1rb3x027368; Mon, 14 Aug 2006 21:53:37 -0400 (EDT) To: Kyle Bateman cc: pgsql-sql@postgresql.org, Florian Weimer Subject: Re: Using bitmap index scans-more efficient In-reply-to: <44E11E1A.8020507@actarg.com> References: <44DF6582.4000806@actarg.com> <82mza77rch.fsf@mid.bfk.de> <44E11E1A.8020507@actarg.com> Comments: In-reply-to Kyle Bateman message dated "Mon, 14 Aug 2006 19:06:34 -0600" Date: Mon, 14 Aug 2006 21:53:37 -0400 Message-ID: <27367.1155606817@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.188 tagged_above=0 required=5 tests=AWL, SPF_HELO_PASS, SPF_PASS X-Spam-Level: X-Archive-Number: 200608/101 X-Sequence-Number: 26059 Kyle Bateman writes: > But I'm assuming that using an interval-encoded project tree, I would > have to do something like the following to get a progency group: > select * from ledger l, proj p where p.proj_id = l.proj and p.left > > 1234 and p.right < 2345; btree has no idea about the constraint (that I imagine exists) that left <= right. If you're just doing a simple index on (left, right) then the above query requires scanning all index entries with left > 1234. It would probably help to say select * from ledger l, proj p where p.proj_id = l.proj and p.left > 1234 and p.left < 2345 and p.right < 2345; so that you can constrain the range of "left" values scanned. regards, tom lane