Updated on 2024-05-07 GMT+08:00

Bitmap Scan Hints

Function

These hints generate a bitmap scan path by using the specified index on the target table. The path that meets the hint requirement is selected from the paths that can be generated by the optimizer.

Syntax

[no] bitmapscan([@queryblock] table [index_list])

Parameter Description

  • no indicates that the scan of hints is not used.
  • For details about @queryblock, see Hint Specifying the Query Block Where the Hint Is Located. @queryblock can be omitted, indicating that the hint takes effect in the current query block.
  • table indicates the target table of the bitmap scan.
  • index_list indicates the index used by the bitmap scan.

Example

gaussdb=# explain(costs off)  select /*+ BitmapScan(t1 it1 it3)*/* from t1 where  (t1.c1 = 5 or t1.c2=6) or (t1.c3=3 or t1.c2=7);
                              QUERY PLAN                              
----------------------------------------------------------------------
 Streaming (type: GATHER)
   Node/s: All datanodes
   ->  Bitmap Heap Scan on t1
         Recheck Cond: ((c1 = 5) OR (c2 = 6) OR (c3 = 3) OR (c2 = 7))
         ->  BitmapOr
               ->  Bitmap Index Scan on it1
                     Index Cond: (c1 = 5)
               ->  Bitmap Index Scan on it3
                     Index Cond: (c2 = 6)
               ->  Bitmap Index Scan on it3
                     Index Cond: (c3 = 3)
               ->  Bitmap Index Scan on it3
                     Index Cond: (c2 = 7)
(13 rows)

The path that meets the bitmap scan hint is selected from the existing index paths. Because the index path construction space is large and the optimizer prunes the paths, if any index path is not generated, the path cannot be constructed.