Re: Using bitmap index scans-more efficient - Mailing list pgsql-sql

From Tom Lane
Subject Re: Using bitmap index scans-more efficient
Date
Msg-id 27367.1155606817@sss.pgh.pa.us
Whole thread Raw
In response to Re: Using bitmap index scans-more efficient  (Kyle Bateman <kyle@actarg.com>)
Responses Re: Using bitmap index scans-more efficient
Re: Using bitmap index scans-more efficient
List pgsql-sql
Kyle Bateman <kyle@actarg.com> 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


pgsql-sql by date:

Previous
From: Kyle Bateman
Date:
Subject: Re: Using bitmap index scans-more efficient
Next
From: Andrew Sullivan
Date:
Subject: Re: Multiple DB join