Re: Best way to scan on-disk bitmaps

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Victor Y. Yegorov" <viy@mits.lv>
Cc: Postgres Hackers <pgsql-hackers@postgresql.org>
Date: 2005-05-12T21:40:06Z
Lists: pgsql-hackers
"Victor Y. Yegorov" <viy@mits.lv> writes:
> If I have on-disk bitmap
> 	ON (a, b, c)
> will the planner pick an index scan for
> 	WHERE a = 42 AND b = 'foo'
> (i.e. only part of the index attributes are involved)? Any modifications
> needed to achieve this functionality?

Hmm.  That particular case will work, but the planner believes that only
consecutive columns in the index are usable --- that is, if you have
quals for a and c but not for b, it will think that the condition for c
isn't usable with the index.  This is true for btree and gist indexes,
so I suppose we'd need to introduce a pg_am column that tells what to
do.

[ thinks some more ... ]

Plan B would be to remove that restriction and teach btree and gist to
cope.  While a btree couldn't use a nonconsecutive restriction as part
of its where-to-scan logic, I don't see any good reason why it couldn't
still perform the test before returning the TID, thus possibly saving a
trip to the heap.  Offhand it seems this should be true of gist as well,
but I don't know that code well enough to be sure.

			regards, tom lane