What is the "Scan raster map" in the query plan?

I want to know the principle of "scanning a bitmap heap", I know that this often happens when I execute a request with OR in a condition.

Who can explain the principle of “scanning a bitmap heap”?

+65
indexing postgresql sql-execution-plan
Jul 06 2018-11-11T00:
source share
1 answer

The best explanation comes from Tom Lane , who is the author of the algorithm, if I'm not mistaken. See Also Wikipedia article .

In short, this is a bit like seq scanning. The difference is that instead of visiting every page on the disk, the bitmap index indexes AND and ORs apply the indexes together and visit only those pages on the disk that they need.

This is different from index scanning, where the index is visited line by line in order - this means that a disk page can be visited several times.




Re: the question is in your comment ... Yes, that’s it.

The index scan will go through the lines one by one, opening the disk pages again and again, as many times as necessary (some of them, of course, will remain in memory, but you will get a point).

Scanning a raster index will sequentially open a short list of disk pages and capture each applicable row in each of them (therefore, the so-called double-check that you see in the query plans).

Notice, aside, how the clustering / row order affects the associated costs using any method. If the rows are randomly everywhere, the bitmap index will be cheaper. (And, in fact, if they are really everywhere, seq scanning will be the cheapest since scanning a raster index is not without some overhead.)

+83
Jul 06 2018-11-11T00:
source share



All Articles