Hi,
While experimenting with BRIN on PostgreSQL 9.5RC1 I came across the following
plan (which is, btw a very good example of how BRIN rocks for the clustered
data, the size of this table is around 90GB, the size of the index is around
3MB):
explain (analyze, buffers, verbose) select 1 from example where event_time =
now() - interval '5 months';
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------
Bitmap Heap Scan on example (cost=744.44..757.64 rows=6 width=0) (actual
time=73.895..73.895 rows=0 loops=1)
Output: 1
Recheck Cond: (example.event_time = (now() - '5 mons'::interval))
Rows Removed by Index Recheck: 4030
Heap Blocks: lossy=128
Buffers: shared hit=629
-> Bitmap Index Scan on example_event_time_idx1 (cost=0.00..744.41 rows=6
width=0) (actual time=70.335..70.335 rows=1280 loops=1)
Index Cond: (example.event_time = (now() - '5 mons'::interval))
Buffers: shared hit=501
Planning time: 0.125 ms
Execution time: 73.943 ms
(11 rows)
Time: 74.642 ms
Here EXPLAIN ANALYZE reports 1280 rows from the Bitmap Index Scan, but on the
higher level, 4030 rows were removed by Index Recheck.
The questions are:
- how does it get 1280 rows from the BRIN index scan, given that BRIN only
stores pointers to the heap blocks, not individual rows. Does it calculate the
number of rows in the blocks returned?
- how comes that the subsequent recheck filters out 4030 rows, out of
supposedly 1280 returned?
Kind regards,
--
Oleksii