pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kyle Bateman <kyle@actarg.com>
Cc: pgsql-sql@postgresql.org, Florian Weimer <fweimer@bfk.de>
Subject: Re: Using bitmap index scans-more efficient
Date: Mon, 14 Aug 2006 21:53:37 -0400
Message-ID: <27367.1155606817@sss.pgh.pa.us> (raw)
In-Reply-To: <44E11E1A.8020507@actarg.com>
References: <44DF6582.4000806@actarg.com>
	<82mza77rch.fsf@mid.bfk.de>
	<44E11E1A.8020507@actarg.com>

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



view thread (9+ messages)  latest in thread

Message-ID: <27367.1155606817@sss.pgh.pa.us>
Permalink:  ../27367.1155606817@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27367.1155606817@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, kyle@actarg.com, fweimer@bfk.de
  Subject: Re: Using bitmap index scans-more efficient
  In-Reply-To: <27367.1155606817@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox