Re: encourging bitmap AND

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marti Raudsepp <marti(at)juffo(dot)org>
Cc: Ben <midfield(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: encourging bitmap AND
Date: 2010-12-26 17:24:47
Message-ID: 17713.1293384287@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Marti Raudsepp <marti(at)juffo(dot)org> writes:
> On Thu, Dec 23, 2010 at 22:52, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> That index structure is really entirely unsuited to what you want to do,
>> so it's not surprising that the planner isn't impressed with the idea of
>> a bitmap AND.

> Why is it unsuited for this query? It expands to (150 < s AND 150 > e)
> which should work nicely with bitmap AND as far as I can tell.

Well, maybe for small values of "nicely". If you do it like that, then
on average each indexscan will scan about half of its index and return a
bitmap representing about half the rows in the table. That's an
expensive indexscan, and an expensive bitmap-AND operation, even if the
final number of rows out of the AND is small. Plus you're at serious
risk that the bitmaps will become lossy, which degrades the performance
of the final bitmap heapscan.

If you're doing interval queries enough to worry about having an index
for them, you really want an indexing structure that is designed to do
interval queries efficiently.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message marc.hsiao 2010-12-28 05:53:48 How to turn autovacuum prevent wrap around run faster?
Previous Message Jeff Janes 2010-12-26 16:11:07 Re: concurrent IO in postgres?