- Mastering PostgreSQL 9.6
- Hans Jurgen Schonig
- 227字
- 2021-07-09 19:57:16
Using bitmap scans effectively
The question naturally arising now is: when is a bitmap scan most beneficial and when is it chosen by the optimizer? From my point of view, there are really two use cases:
- Avoiding using the same block over and over again
- Combining relatively bad conditions
The first case it quite common. Suppose you are looking for everybody who speaks a certain language. For the sake of the example, we can assume that 10% of all people speak the required language. Scanning the index would mean that a block in the table has to be scanned all over again as many skilled speakers might be stored in the same block. By applying a bitmap scan, it is ensured that a specific block is only used once, which of course leads to better performance.
The second common use case is to use relatively weak criteria together. Let's suppose we are looking for everybody between 20 and 30 years of age owning a yellow shirt. Now, maybe 15% of all people are between 20 and 30 and maybe 15% of all people actually own a yellow shirt. Scanning a table sequentially is expensive, and so PostgreSQL might decide to choose two indexes because the final result might consist of just 1% of the data. Scanning both indexes might be cheaper than reading all of the data.
- Natural Language Processing Fundamentals
- IoT Penetration Testing Cookbook
- 快學(xué)Flash動(dòng)畫百例
- VMware Performance and Capacity Management(Second Edition)
- INSTANT Autodesk Revit 2013 Customization with .NET How-to
- 精通數(shù)據(jù)科學(xué)算法
- 基于32位ColdFire構(gòu)建嵌入式系統(tǒng)
- Mastering ServiceNow Scripting
- 和機(jī)器人一起進(jìn)化
- 基于Proteus的單片機(jī)應(yīng)用技術(shù)
- Redash v5 Quick Start Guide
- 30天學(xué)通Java Web項(xiàng)目案例開發(fā)
- FreeCAD [How-to]
- ARM體系結(jié)構(gòu)與編程
- ASP.NET 4.0 MVC敏捷開發(fā)給力起飛