Re: Using bitmap index scans-more efficient

From: Kyle Bateman <kyle(at)actarg(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: Florian Weimer <fweimer(at)bfk(dot)de>
Subject: Re: Using bitmap index scans-more efficient
Date: 2006-08-15 01:06:34
Message-ID: 44E11E1A.8020507@actarg.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Florian Weimer wrote:

>* Kyle Bateman:
>
>
>
>>Any ideas about whether/how this can be done?
>>
>>
>
>If the project tree is fairly consistent, it's convenient to encode it
>using intervals instead of parent/child intervals. IIRC, Celko's "SQL
>for smarties" explains how to do this, and Kristian Koehntopp has
>written some PHP code to implement it.
>
>
>
I agree that this produces a more efficient query for finding the
projects that are the progeny of another project, but I'm trying to
figure out how that helps me select the right project transactions from
my ledger efficiently.

This query produces wonderful results (very fast):

select * from ledger where proj >= 4737 and proj <= 4740;

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;

The problem (at least according to my initial testing) is that this
forces a join of the entire ledger and I get my slowest performance
group (5 seconds).

What am I missing?

Kyle

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2006-08-15 01:53:37 Re: Using bitmap index scans-more efficient
Previous Message Shoaib Mir 2006-08-14 22:04:35 Re: Multiple DB join