From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kyle Bateman <kyle(at)actarg(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org, Florian Weimer <fweimer(at)bfk(dot)de> |
Subject: | Re: Using bitmap index scans-more efficient |
Date: | 2006-08-15 01:53:37 |
Message-ID: | 27367.1155606817@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Kyle Bateman <kyle(at)actarg(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Sullivan | 2006-08-15 10:36:24 | Re: Multiple DB join |
Previous Message | Kyle Bateman | 2006-08-15 01:06:34 | Re: Using bitmap index scans-more efficient |