An In-memory Bitmap Index Bug

Started by Jie Zhangover 20 years ago2 messageshackers
Jump to latest
#1Jie Zhang
jzhang@greenplum.com

There is a bug in the in-memory bitmap index on the CVS Tip.

Consider this query: select * from bt1 where g=2 and e=20, which will generate the following query plan:

QUERY PLAN
----------------------------------------------------------------------------------------
Bitmap Heap Scan on bt1 (cost=2041.47..19807.47 rows=8451 width=159)
Recheck Cond: ((e = 20) AND (g = 2))
-> BitmapAnd (cost=2041.47..2041.47 rows=8451 width=0)
-> Bitmap Index Scan on bt1_btree_e (cost=0.00..145.91 rows=25404 width=0)
Index Cond: (e = 20)
-> Bitmap Index Scan on bt1_btree_g (cost=0.00..1895.31 rows=332661 width=0)
Index Cond: (g = 2)
(7 rows)

With default work_mem setting (1024), the bitmap generated for (e=20) will not have lossy pages, while the bitmap generated for (g=2) will have lossy pages.

The problem appears when a page in the first bitmap tries to intersect with the second bitmap. The current code didn't set the page in the first bitmap to lossy after the intersection. As a result, incorrect answers are returned.

A patch is attached in this email.

Sincerely,

Jie Zhang
Greenplum

Attachments:

pgsql-bitmapscan-bugfix.patchapplication/octet-stream; name=pgsql-bitmapscan-bugfix.patchDownload+11-8
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jie Zhang (#1)
Re: An In-memory Bitmap Index Bug

"Jie Zhang" <jzhang@greenplum.com> writes:

There is a bug in the in-memory bitmap index on the CVS Tip.

Good catch, thanks for the report.

regards, tom lane