 shared_buffers 
----------------
 1GB
(1 row)

 work_mem 
----------
 100MB
(1 row)

DROP TABLE
SELECT 10000000
CREATE INDEX
CREATE INDEX
ANALYZE
 relname | reltuples | relpages | tpp 
---------+-----------+----------+-----
 aaa     |  10000033 |    44248 | 226
 i1      |  10000033 |    27422 | 365
 i2      |  10000033 |    27422 | 365
(3 rows)

 schemaname | tablename | attname | inherited | null_frac | avg_width | n_distinct |   most_common_vals    |                                      most_common_freqs                                      | histogram_bounds | correlation | most_common_elems | most_common_elem_freqs | elem_count_histogram 
------------+-----------+---------+-----------+-----------+-----------+------------+-----------------------+---------------------------------------------------------------------------------------------+------------------+-------------+-------------------+------------------------+----------------------
 public     | aaa       | num     | f         |         0 |         4 |         10 | {1,7,3,0,4,9,8,2,5,6} | {0.103367,0.101633,0.101133,0.100333,0.0999,0.0995333,0.0989,0.0986667,0.0982667,0.0982667} |                  |    0.100238 |                   |                        | 
 public     | aaa       | flag    | f         |         0 |         4 |          2 | {0,1}                 | {0.9019,0.0981}                                                                             |                  |    0.828507 |                   |                        | 
(2 rows)

 table |  ~count  |  size  |  toast  |  idx   | size + toast + idx 
-------+----------+--------+---------+--------+--------------------
 aaa   | 10000033 | 346 MB | 0 bytes | 428 MB | 774 MB
(1 row)

 table | index | idx_size | idx_scan | is_unique | indkey_names 
-------+-------+----------+----------+-----------+--------------
 aaa   | i1    | 214 MB   |        0 | f         | {num}
 aaa   | i2    | 214 MB   |        0 | f         | {flag}
(2 rows)

Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=20687.87..66456.91 rows=101403 width=8) (actual time=345.349..6061.834 rows=99600 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.flag = 1) AND (aaa.num = 1))
   Heap Blocks: exact=39619
   Buffers: shared read=45091
   ->  BitmapAnd  (cost=20687.87..20687.87 rows=101403 width=0) (actual time=333.815..333.815 rows=0 loops=1)
         Buffers: shared read=5472
         ->  Bitmap Index Scan on i2  (cost=0.00..10048.96 rows=981003 width=0) (actual time=164.621..164.621 rows=1000435 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared read=2737
         ->  Bitmap Index Scan on i1  (cost=0.00..10587.96 rows=1033670 width=0) (actual time=157.469..157.469 rows=999756 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared read=2735
 Planning time: 1.764 ms
 Execution time: 6106.695 ms

                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=20687.87..66456.91 rows=101403 width=8) (actual time=593.915..991.403 rows=99600 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.flag = 1) AND (aaa.num = 1))
   Heap Blocks: exact=39619
   Buffers: shared hit=45091
   ->  BitmapAnd  (cost=20687.87..20687.87 rows=101403 width=0) (actual time=569.146..569.146 rows=0 loops=1)
         Buffers: shared hit=5472
         ->  Bitmap Index Scan on i2  (cost=0.00..10048.96 rows=981003 width=0) (actual time=275.014..275.014 rows=1000435 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared hit=2737
         ->  Bitmap Index Scan on i1  (cost=0.00..10587.96 rows=1033670 width=0) (actual time=273.515..273.515 rows=999756 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared hit=2735
 Planning time: 0.718 ms
 Execution time: 1019.742 ms

                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=20687.87..66456.91 rows=101403 width=8) (actual time=255.273..355.694 rows=99600 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.flag = 1) AND (aaa.num = 1))
   Heap Blocks: exact=39619
   Buffers: shared hit=45091
   ->  BitmapAnd  (cost=20687.87..20687.87 rows=101403 width=0) (actual time=243.781..243.781 rows=0 loops=1)
         Buffers: shared hit=5472
         ->  Bitmap Index Scan on i2  (cost=0.00..10048.96 rows=981003 width=0) (actual time=115.468..115.468 rows=1000435 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared hit=2737
         ->  Bitmap Index Scan on i1  (cost=0.00..10587.96 rows=1033670 width=0) (actual time=117.549..117.549 rows=999756 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared hit=2735
 Planning time: 0.119 ms
 Execution time: 374.539 ms

                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=20687.87..66456.91 rows=101403 width=8) (actual time=284.768..385.505 rows=99600 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.flag = 1) AND (aaa.num = 1))
   Heap Blocks: exact=39619
   Buffers: shared hit=45091
   ->  BitmapAnd  (cost=20687.87..20687.87 rows=101403 width=0) (actual time=272.266..272.266 rows=0 loops=1)
         Buffers: shared hit=5472
         ->  Bitmap Index Scan on i2  (cost=0.00..10048.96 rows=981003 width=0) (actual time=129.277..129.277 rows=1000435 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared hit=2737
         ->  Bitmap Index Scan on i1  (cost=0.00..10587.96 rows=1033670 width=0) (actual time=129.749..129.749 rows=999756 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared hit=2735
 Planning time: 0.129 ms
 Execution time: 404.619 ms

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=0.00..0.00 rows=101403 width=8)
   Recheck Cond: (flag = 1)
   Filter: (num = 1)
   ->  Bitmap Index Scan on i2  (cost=0.00..0.00 rows=981003 width=0)
         Index Cond: (flag = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=0.00..44248.00 rows=101403 width=8)
   Recheck Cond: (flag = 1)
   Filter: (num = 1)
   ->  Bitmap Index Scan on i2  (cost=0.00..0.00 rows=981003 width=0)
         Index Cond: (flag = 1)

SET
SET
SET
SET
SET
                               QUERY PLAN                                
-------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=2691.00..2691.00 rows=101403 width=8)
   Recheck Cond: (flag = 1)
   Filter: (num = 1)
   ->  Bitmap Index Scan on i2  (cost=0.00..2691.00 rows=981003 width=0)
         Index Cond: (flag = 1)

SET
SET
SET
SET
SET
                                 QUERY PLAN                                  
-----------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=0.00..1014.03 rows=101403 width=8)
   Recheck Cond: ((flag = 1) AND (num = 1))
   ->  BitmapAnd  (cost=0.00..0.00 rows=101403 width=0)
         ->  Bitmap Index Scan on i2  (cost=0.00..0.00 rows=981003 width=0)
               Index Cond: (flag = 1)
         ->  Bitmap Index Scan on i1  (cost=0.00..0.00 rows=1033670 width=0)
               Index Cond: (num = 1)

SET
SET
SET
SET
SET
                               QUERY PLAN                                
-------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=4905.02..4905.02 rows=101403 width=8)
   Recheck Cond: (flag = 1)
   Filter: (num = 1)
   ->  Bitmap Index Scan on i2  (cost=0.00..4905.02 rows=981003 width=0)
         Index Cond: (flag = 1)

SET
SET
SET
SET
SET
                                   QUERY PLAN                                   
--------------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=5088.50..5595.52 rows=101403 width=8)
   Recheck Cond: ((flag = 1) AND (num = 1))
   ->  BitmapAnd  (cost=5088.50..5088.50 rows=101403 width=0)
         ->  Bitmap Index Scan on i2  (cost=0.00..2452.94 rows=981003 width=0)
               Index Cond: (flag = 1)
         ->  Bitmap Index Scan on i1  (cost=0.00..2584.61 rows=1033670 width=0)
               Index Cond: (num = 1)

SET
SET
SET
SET
SET
                                   QUERY PLAN                                    
---------------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=20687.87..66456.91 rows=101403 width=8)
   Recheck Cond: ((flag = 1) AND (num = 1))
   ->  BitmapAnd  (cost=20687.87..20687.87 rows=101403 width=0)
         ->  Bitmap Index Scan on i2  (cost=0.00..10048.96 rows=981003 width=0)
               Index Cond: (flag = 1)
         ->  Bitmap Index Scan on i1  (cost=0.00..10587.96 rows=1033670 width=0)
               Index Cond: (num = 1)

Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                     QUERY PLAN                                                      
---------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194248.49 rows=101403 width=8) (actual time=0.126..2056.913 rows=99600 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9900400
   Buffers: shared read=44248
 Planning time: 1.927 ms
 Execution time: 2082.400 ms

                                                     QUERY PLAN                                                      
---------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194248.49 rows=101403 width=8) (actual time=0.045..1595.377 rows=99600 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9900400
   Buffers: shared hit=32 read=44216
 Planning time: 0.359 ms
 Execution time: 1615.510 ms

                                                     QUERY PLAN                                                      
---------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194248.49 rows=101403 width=8) (actual time=0.066..1392.700 rows=99600 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9900400
   Buffers: shared hit=64 read=44184
 Planning time: 0.106 ms
 Execution time: 1410.820 ms

                                                     QUERY PLAN                                                      
---------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194248.49 rows=101403 width=8) (actual time=0.069..1378.574 rows=99600 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9900400
   Buffers: shared hit=96 read=44152
 Planning time: 0.105 ms
 Execution time: 1397.059 ms

SET
SET
SET
SET
SET
                       QUERY PLAN                       
--------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..0.00 rows=101403 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                         QUERY PLAN                         
------------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..44248.00 rows=101403 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                       QUERY PLAN                       
--------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..0.00 rows=101403 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                         QUERY PLAN                          
-------------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..100000.33 rows=101403 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                       QUERY PLAN                       
--------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..0.00 rows=101403 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                         QUERY PLAN                         
------------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..50000.17 rows=101403 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                         QUERY PLAN                          
-------------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..194248.49 rows=101403 width=8)
   Filter: ((num = 1) AND (flag = 1))

DROP INDEX
DROP INDEX
CREATE INDEX
Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                          QUERY PLAN                                                           
-------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..67358.15 rows=101403 width=8) (actual time=0.400..1325.638 rows=99600 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 900156
   Buffers: shared read=46983
 Planning time: 2.502 ms
 Execution time: 1348.664 ms

                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..67358.15 rows=101403 width=8) (actual time=0.020..479.713 rows=99600 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 900156
   Buffers: shared hit=46983
 Planning time: 0.189 ms
 Execution time: 498.106 ms

                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..67358.15 rows=101403 width=8) (actual time=0.024..642.947 rows=99600 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 900156
   Buffers: shared hit=46983
 Planning time: 0.125 ms
 Execution time: 671.359 ms

                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..67358.15 rows=101403 width=8) (actual time=0.038..756.045 rows=99600 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 900156
   Buffers: shared hit=46983
 Planning time: 0.192 ms
 Execution time: 792.434 ms

SET
SET
SET
SET
SET
                            QUERY PLAN                             
-------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..0.00 rows=101403 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                             
--------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..45.95 rows=101403 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                               
-----------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..46638.42 rows=101403 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                               
-----------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..10336.67 rows=101403 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..5168.34 rows=101403 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.43..5168.77 rows=101403 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                               
-----------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.43..67358.15 rows=101403 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

DROP INDEX
DROP INDEX
CREATE INDEX
Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                          QUERY PLAN                                                           
-------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..39166.34 rows=101403 width=8) (actual time=1.337..1543.611 rows=99600 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 900835
   Buffers: shared read=46985
 Planning time: 4.819 ms
 Execution time: 1574.767 ms

                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..39166.34 rows=101403 width=8) (actual time=0.027..410.623 rows=99600 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 900835
   Buffers: shared hit=46985
 Planning time: 0.208 ms
 Execution time: 428.820 ms

                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..39166.34 rows=101403 width=8) (actual time=0.025..377.529 rows=99600 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 900835
   Buffers: shared hit=46985
 Planning time: 0.134 ms
 Execution time: 395.335 ms

                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..39166.34 rows=101403 width=8) (actual time=0.025..377.554 rows=99600 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 900835
   Buffers: shared hit=46985
 Planning time: 0.130 ms
 Execution time: 395.385 ms

SET
SET
SET
SET
SET
                            QUERY PLAN                             
-------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..0.00 rows=101403 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..2979.08 rows=101403 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                               
-----------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..16566.83 rows=101403 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..9810.00 rows=101403 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..4905.00 rows=101403 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.43..4905.44 rows=101403 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                               
-----------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.43..39166.34 rows=101403 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

 shared_buffers 
----------------
 1GB
(1 row)

 work_mem 
----------
 100MB
(1 row)

DROP TABLE
SELECT 10000000
CREATE INDEX
CREATE INDEX
ANALYZE
 relname | reltuples | relpages | tpp 
---------+-----------+----------+-----
 aaa     |   9999985 |    44248 | 226
 i1      |   9999985 |    27422 | 365
 i2      |   9999985 |    27422 | 365
(3 rows)

 schemaname | tablename | attname | inherited | null_frac | avg_width | n_distinct |                                                               most_common_vals                                                                |                                                                                                                                                                                                                         most_common_freqs                                                                                                                                                                                                                          | histogram_bounds | correlation | most_common_elems | most_common_elem_freqs | elem_count_histogram 
------------+-----------+---------+-----------+-----------+-----------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------+-------------+-------------------+------------------------+----------------------
 public     | aaa       | num     | f         |         0 |         4 |         50 | {31,47,23,21,32,14,36,26,37,49,33,16,27,35,34,24,40,46,0,43,9,42,44,1,6,20,39,48,12,4,41,2,30,19,25,11,10,45,22,8,5,17,13,15,29,3,7,18,28,38} | {0.0218333,0.0217667,0.0212667,0.0211667,0.0211667,0.0209333,0.0208,0.0207667,0.0206,0.0206,0.0205333,0.0205,0.0205,0.0204667,0.0204333,0.0203667,0.0203333,0.0203,0.0202,0.0202,0.0201667,0.0201667,0.0201667,0.0201,0.0201,0.0200333,0.0200333,0.02,0.0199333,0.0198667,0.0198667,0.0197333,0.0197333,0.0196667,0.0196667,0.0195333,0.0194,0.0193667,0.0193333,0.0192667,0.0192,0.0192,0.0190667,0.019,0.0189667,0.0189333,0.0189333,0.0188,0.0187667,0.0182667} |                  |   0.0159961 |                   |                        | 
 public     | aaa       | flag    | f         |         0 |         4 |          2 | {0,1}                                                                                                                                         | {0.902267,0.0977333}                                                                                                                                                                                                                                                                                                                                                                                                                                               |                  |    0.825845 |                   |                        | 
(2 rows)

 table | ~count  |  size  |  toast  |  idx   | size + toast + idx 
-------+---------+--------+---------+--------+--------------------
 aaa   | 9999985 | 346 MB | 0 bytes | 428 MB | 774 MB
(1 row)

 table | index | idx_size | idx_scan | is_unique | indkey_names 
-------+-------+----------+----------+-----------+--------------
 aaa   | i1    | 214 MB   |        0 | f         | {num}
 aaa   | i2    | 214 MB   |        0 | f         | {flag}
(2 rows)

Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=12081.43..28452.09 rows=19644 width=8) (actual time=238.566..3115.445 rows=20114 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.num = 1) AND (aaa.flag = 1))
   Heap Blocks: exact=16139
   Buffers: shared read=19425
   ->  BitmapAnd  (cost=12081.43..12081.43 rows=19644 width=0) (actual time=233.142..233.142 rows=0 loops=1)
         Buffers: shared read=3286
         ->  Bitmap Index Scan on i1  (cost=0.00..2059.93 rows=201000 width=0) (actual time=41.835..41.835 rows=199906 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared read=549
         ->  Bitmap Index Scan on i2  (cost=0.00..10011.42 rows=977332 width=0) (actual time=174.880..174.880 rows=1000464 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared read=2737
 Planning time: 2.024 ms
 Execution time: 3133.016 ms

                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=12081.43..28452.09 rows=19644 width=8) (actual time=314.590..382.207 rows=20114 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.num = 1) AND (aaa.flag = 1))
   Heap Blocks: exact=16139
   Buffers: shared hit=19425
   ->  BitmapAnd  (cost=12081.43..12081.43 rows=19644 width=0) (actual time=307.044..307.044 rows=0 loops=1)
         Buffers: shared hit=3286
         ->  Bitmap Index Scan on i1  (cost=0.00..2059.93 rows=201000 width=0) (actual time=65.647..65.647 rows=199906 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared hit=549
         ->  Bitmap Index Scan on i2  (cost=0.00..10011.42 rows=977332 width=0) (actual time=222.497..222.497 rows=1000464 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared hit=2737
 Planning time: 0.827 ms
 Execution time: 386.667 ms

                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=12081.43..28452.09 rows=19644 width=8) (actual time=265.899..311.064 rows=20114 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.num = 1) AND (aaa.flag = 1))
   Heap Blocks: exact=16139
   Buffers: shared hit=19425
   ->  BitmapAnd  (cost=12081.43..12081.43 rows=19644 width=0) (actual time=258.060..258.060 rows=0 loops=1)
         Buffers: shared hit=3286
         ->  Bitmap Index Scan on i1  (cost=0.00..2059.93 rows=201000 width=0) (actual time=50.308..50.308 rows=199906 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared hit=549
         ->  Bitmap Index Scan on i2  (cost=0.00..10011.42 rows=977332 width=0) (actual time=187.435..187.435 rows=1000464 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared hit=2737
 Planning time: 0.201 ms
 Execution time: 318.210 ms

                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=12081.43..28452.09 rows=19644 width=8) (actual time=209.470..237.697 rows=20114 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.num = 1) AND (aaa.flag = 1))
   Heap Blocks: exact=16139
   Buffers: shared hit=19425
   ->  BitmapAnd  (cost=12081.43..12081.43 rows=19644 width=0) (actual time=204.987..204.987 rows=0 loops=1)
         Buffers: shared hit=3286
         ->  Bitmap Index Scan on i1  (cost=0.00..2059.93 rows=201000 width=0) (actual time=52.527..52.527 rows=199906 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared hit=549
         ->  Bitmap Index Scan on i2  (cost=0.00..10011.42 rows=977332 width=0) (actual time=138.535..138.535 rows=1000464 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared hit=2737
 Planning time: 0.252 ms
 Execution time: 241.112 ms

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=0.00..0.00 rows=19644 width=8)
   Recheck Cond: (num = 1)
   Filter: (flag = 1)
   ->  Bitmap Index Scan on i1  (cost=0.00..0.00 rows=201000 width=0)
         Index Cond: (num = 1)

SET
SET
SET
SET
SET
                                 QUERY PLAN                                 
----------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=0.00..9689.92 rows=19644 width=8)
   Recheck Cond: ((num = 1) AND (flag = 1))
   ->  BitmapAnd  (cost=0.00..0.00 rows=19644 width=0)
         ->  Bitmap Index Scan on i1  (cost=0.00..0.00 rows=201000 width=0)
               Index Cond: (num = 1)
         ->  Bitmap Index Scan on i2  (cost=0.00..0.00 rows=977332 width=0)
               Index Cond: (flag = 1)

SET
SET
SET
SET
SET
                               QUERY PLAN                               
------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=552.00..552.00 rows=19644 width=8)
   Recheck Cond: (num = 1)
   Filter: (flag = 1)
   ->  Bitmap Index Scan on i1  (cost=0.00..552.00 rows=201000 width=0)
         Index Cond: (num = 1)

SET
SET
SET
SET
SET
                                 QUERY PLAN                                 
----------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=0.00..196.44 rows=19644 width=8)
   Recheck Cond: ((num = 1) AND (flag = 1))
   ->  BitmapAnd  (cost=0.00..0.00 rows=19644 width=0)
         ->  Bitmap Index Scan on i1  (cost=0.00..0.00 rows=201000 width=0)
               Index Cond: (num = 1)
         ->  Bitmap Index Scan on i2  (cost=0.00..0.00 rows=977332 width=0)
               Index Cond: (flag = 1)

SET
SET
SET
SET
SET
                               QUERY PLAN                                
-------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=1005.00..1005.00 rows=19644 width=8)
   Recheck Cond: (num = 1)
   Filter: (flag = 1)
   ->  Bitmap Index Scan on i1  (cost=0.00..1005.00 rows=201000 width=0)
         Index Cond: (num = 1)

SET
SET
SET
SET
SET
                               QUERY PLAN                               
------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=507.85..1512.85 rows=19644 width=8)
   Recheck Cond: (num = 1)
   Filter: (flag = 1)
   ->  Bitmap Index Scan on i1  (cost=0.00..502.94 rows=201000 width=0)
         Index Cond: (num = 1)

SET
SET
SET
SET
SET
                                   QUERY PLAN                                   
--------------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=12081.43..28452.09 rows=19644 width=8)
   Recheck Cond: ((num = 1) AND (flag = 1))
   ->  BitmapAnd  (cost=12081.43..12081.43 rows=19644 width=0)
         ->  Bitmap Index Scan on i1  (cost=0.00..2059.93 rows=201000 width=0)
               Index Cond: (num = 1)
         ->  Bitmap Index Scan on i2  (cost=0.00..10011.42 rows=977332 width=0)
               Index Cond: (flag = 1)

Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                     QUERY PLAN                                                     
--------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194247.77 rows=19644 width=8) (actual time=0.646..1801.794 rows=20114 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9979886
   Buffers: shared read=44248
 Planning time: 2.634 ms
 Execution time: 1808.595 ms

                                                     QUERY PLAN                                                     
--------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194247.77 rows=19644 width=8) (actual time=0.385..1518.613 rows=20114 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9979886
   Buffers: shared hit=32 read=44216
 Planning time: 0.280 ms
 Execution time: 1523.658 ms

                                                     QUERY PLAN                                                     
--------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194247.77 rows=19644 width=8) (actual time=0.346..1369.021 rows=20114 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9979886
   Buffers: shared hit=64 read=44184
 Planning time: 0.333 ms
 Execution time: 1373.371 ms

                                                     QUERY PLAN                                                     
--------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194247.77 rows=19644 width=8) (actual time=0.597..1792.959 rows=20114 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9979886
   Buffers: shared hit=96 read=44152
 Planning time: 0.356 ms
 Execution time: 1798.927 ms

SET
SET
SET
SET
SET
                      QUERY PLAN                       
-------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..0.00 rows=19644 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                        QUERY PLAN                         
-----------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..44248.00 rows=19644 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                      QUERY PLAN                       
-------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..0.00 rows=19644 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                        QUERY PLAN                         
-----------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..99999.85 rows=19644 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                      QUERY PLAN                       
-------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..0.00 rows=19644 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                        QUERY PLAN                         
-----------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..49999.93 rows=19644 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                         QUERY PLAN                         
------------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..194247.77 rows=19644 width=8)
   Filter: ((num = 1) AND (flag = 1))

DROP INDEX
DROP INDEX
CREATE INDEX
Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..48809.34 rows=19644 width=8) (actual time=0.600..1059.269 rows=20114 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 179792
   Buffers: shared read=44373
 Planning time: 2.081 ms
 Execution time: 1066.219 ms

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..48809.34 rows=19644 width=8) (actual time=0.071..208.940 rows=20114 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 179792
   Buffers: shared hit=44373
 Planning time: 0.326 ms
 Execution time: 213.284 ms

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..48809.34 rows=19644 width=8) (actual time=0.044..124.437 rows=20114 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 179792
   Buffers: shared hit=44373
 Planning time: 0.125 ms
 Execution time: 128.018 ms

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..48809.34 rows=19644 width=8) (actual time=0.044..127.814 rows=20114 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 179792
   Buffers: shared hit=44373
 Planning time: 0.123 ms
 Execution time: 131.681 ms

SET
SET
SET
SET
SET
                            QUERY PLAN                            
------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..0.00 rows=19644 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                            QUERY PLAN                            
------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..0.23 rows=19644 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..44788.68 rows=19644 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..2010.00 rows=19644 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..1005.00 rows=19644 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.43..1005.43 rows=19644 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.43..48809.34 rows=19644 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

DROP INDEX
DROP INDEX
CREATE INDEX
Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..39247.83 rows=19644 width=8) (actual time=0.783..2236.765 rows=20114 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 980350
   Buffers: shared read=46985
 Planning time: 2.145 ms
 Execution time: 2249.463 ms

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..39247.83 rows=19644 width=8) (actual time=0.198..777.279 rows=20114 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 980350
   Buffers: shared hit=46985
 Planning time: 0.523 ms
 Execution time: 784.914 ms

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..39247.83 rows=19644 width=8) (actual time=0.196..437.177 rows=20114 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 980350
   Buffers: shared hit=46985
 Planning time: 0.240 ms
 Execution time: 441.492 ms

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..39247.83 rows=19644 width=8) (actual time=0.075..346.481 rows=20114 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 980350
   Buffers: shared hit=46985
 Planning time: 0.109 ms
 Execution time: 350.143 ms

SET
SET
SET
SET
SET
                            QUERY PLAN                            
------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..0.00 rows=19644 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..2949.05 rows=19644 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..16751.68 rows=19644 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..9773.33 rows=19644 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..4886.66 rows=19644 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.43..4887.10 rows=19644 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.43..39247.83 rows=19644 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

 shared_buffers 
----------------
 1GB
(1 row)

 work_mem 
----------
 100MB
(1 row)

DROP TABLE
SELECT 10000000
CREATE INDEX
CREATE INDEX
ANALYZE
 relname | reltuples | relpages | tpp 
---------+-----------+----------+-----
 aaa     |   9999985 |    44248 | 226
 i1      |   9999985 |    27422 | 365
 i2      |   9999985 |    27422 | 365
(3 rows)

 schemaname | tablename | attname | inherited | null_frac | avg_width | n_distinct |                                                                                                                                          most_common_vals                                                                                                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                     most_common_freqs                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | histogram_bounds | correlation | most_common_elems | most_common_elem_freqs | elem_count_histogram 
------------+-----------+---------+-----------+-----------+-----------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------+-------------+-------------------+------------------------+----------------------
 public     | aaa       | num     | f         |         0 |         4 |        100 | {75,60,33,6,73,64,48,70,9,96,79,22,71,26,27,78,74,15,45,19,30,35,59,84,31,32,80,44,81,68,83,92,93,37,46,91,8,66,43,86,40,76,1,3,47,50,69,10,20,63,67,72,98,18,65,87,24,54,4,42,82,29,11,88,5,36,61,62,85,17,55,14,7,16,41,58,77,56,2,13,49,97,0,51,89,21,52,12,25,90,39,94,95,23,28,57,99,53,34,38} | {0.0117,0.0114667,0.0112667,0.0112333,0.0111333,0.0109667,0.0109333,0.0109,0.0108667,0.0108667,0.0108333,0.0108,0.0107667,0.0107333,0.0107333,0.0107,0.0106667,0.0105667,0.0105333,0.0105,0.0105,0.0105,0.0105,0.0104667,0.0104333,0.0104333,0.0104333,0.0103667,0.0103667,0.0103333,0.0103333,0.0103333,0.0103333,0.0103,0.0102667,0.0102667,0.0102333,0.0102333,0.0102,0.0102,0.0101667,0.0101333,0.0101,0.0101,0.0101,0.0101,0.0101,0.0100667,0.0100667,0.0100667,0.0100333,0.0100333,0.0100333,0.01,0.01,0.01,0.00996667,0.00996667,0.00993333,0.00993333,0.00993333,0.00986667,0.0098,0.0098,0.00976667,0.00976667,0.00976667,0.00976667,0.00973333,0.0097,0.0097,0.00963333,0.00953333,0.00953333,0.00953333,0.00953333,0.00953333,0.0095,0.00943333,0.0094,0.00936667,0.00936667,0.0093,0.00923333,0.00923333,0.0092,0.0092,0.00916667,0.0091,0.0091,0.00903333,0.00903333,0.00903333,0.009,0.00896667,0.00886667,0.00886667,0.0087,0.0085,0.0084} |                  |  0.00379713 |                   |                        | 
 public     | aaa       | flag    | f         |         0 |         4 |          2 | {0,1}                                                                                                                                                                                                                                                                                               | {0.9001,0.0999}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |                  |    0.820328 |                   |                        | 
(2 rows)

 table | ~count  |  size  |  toast  |  idx   | size + toast + idx 
-------+---------+--------+---------+--------+--------------------
 aaa   | 9999985 | 346 MB | 0 bytes | 428 MB | 774 MB
(1 row)

 table | index | idx_size | idx_scan | is_unique | indkey_names 
-------+-------+----------+----------+-----------+--------------
 aaa   | i1    | 214 MB   |        0 | f         | {num}
 aaa   | i2    | 214 MB   |        0 | f         | {flag}
(2 rows)

Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=11273.15..20482.50 rows=10090 width=8) (actual time=284.381..2019.717 rows=10114 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.num = 1) AND (aaa.flag = 1))
   Heap Blocks: exact=9044
   Buffers: shared read=12059
   ->  BitmapAnd  (cost=11273.15..11273.15 rows=10090 width=0) (actual time=280.423..280.423 rows=0 loops=1)
         Buffers: shared read=3015
         ->  Bitmap Index Scan on i1  (cost=0.00..1034.93 rows=101000 width=0) (actual time=55.640..55.640 rows=99876 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared read=276
         ->  Bitmap Index Scan on i2  (cost=0.00..10232.92 rows=998998 width=0) (actual time=208.740..208.740 rows=1001503 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared read=2739
 Planning time: 4.184 ms
 Execution time: 2027.047 ms

                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=11273.15..20482.50 rows=10090 width=8) (actual time=153.445..180.770 rows=10114 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.num = 1) AND (aaa.flag = 1))
   Heap Blocks: exact=9044
   Buffers: shared hit=12059
   ->  BitmapAnd  (cost=11273.15..11273.15 rows=10090 width=0) (actual time=151.277..151.277 rows=0 loops=1)
         Buffers: shared hit=3015
         ->  Bitmap Index Scan on i1  (cost=0.00..1034.93 rows=101000 width=0) (actual time=17.927..17.927 rows=99876 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared hit=276
         ->  Bitmap Index Scan on i2  (cost=0.00..10232.92 rows=998998 width=0) (actual time=122.634..122.634 rows=1001503 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared hit=2739
 Planning time: 0.469 ms
 Execution time: 182.687 ms

                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=11273.15..20482.50 rows=10090 width=8) (actual time=146.275..159.446 rows=10114 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.num = 1) AND (aaa.flag = 1))
   Heap Blocks: exact=9044
   Buffers: shared hit=12059
   ->  BitmapAnd  (cost=11273.15..11273.15 rows=10090 width=0) (actual time=143.964..143.964 rows=0 loops=1)
         Buffers: shared hit=3015
         ->  Bitmap Index Scan on i1  (cost=0.00..1034.93 rows=101000 width=0) (actual time=20.310..20.310 rows=99876 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared hit=276
         ->  Bitmap Index Scan on i2  (cost=0.00..10232.92 rows=998998 width=0) (actual time=112.231..112.231 rows=1001503 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared hit=2739
 Planning time: 0.144 ms
 Execution time: 161.134 ms

                                                             QUERY PLAN                                                             
------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on public.aaa  (cost=11273.15..20482.50 rows=10090 width=8) (actual time=140.973..153.998 rows=10114 loops=1)
   Output: num, flag
   Recheck Cond: ((aaa.num = 1) AND (aaa.flag = 1))
   Heap Blocks: exact=9044
   Buffers: shared hit=12059
   ->  BitmapAnd  (cost=11273.15..11273.15 rows=10090 width=0) (actual time=138.696..138.696 rows=0 loops=1)
         Buffers: shared hit=3015
         ->  Bitmap Index Scan on i1  (cost=0.00..1034.93 rows=101000 width=0) (actual time=16.136..16.136 rows=99876 loops=1)
               Index Cond: (aaa.num = 1)
               Buffers: shared hit=276
         ->  Bitmap Index Scan on i2  (cost=0.00..10232.92 rows=998998 width=0) (actual time=111.764..111.764 rows=1001503 loops=1)
               Index Cond: (aaa.flag = 1)
               Buffers: shared hit=2739
 Planning time: 0.114 ms
 Execution time: 155.780 ms

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=0.00..0.00 rows=10090 width=8)
   Recheck Cond: (num = 1)
   Filter: (flag = 1)
   ->  Bitmap Index Scan on i1  (cost=0.00..0.00 rows=101000 width=0)
         Index Cond: (num = 1)

SET
SET
SET
SET
SET
                                 QUERY PLAN                                 
----------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=0.00..4098.28 rows=10090 width=8)
   Recheck Cond: ((num = 1) AND (flag = 1))
   ->  BitmapAnd  (cost=0.00..0.00 rows=10090 width=0)
         ->  Bitmap Index Scan on i1  (cost=0.00..0.00 rows=101000 width=0)
               Index Cond: (num = 1)
         ->  Bitmap Index Scan on i2  (cost=0.00..0.00 rows=998998 width=0)
               Index Cond: (flag = 1)

SET
SET
SET
SET
SET
                               QUERY PLAN                               
------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=277.00..277.00 rows=10090 width=8)
   Recheck Cond: (num = 1)
   Filter: (flag = 1)
   ->  Bitmap Index Scan on i1  (cost=0.00..277.00 rows=101000 width=0)
         Index Cond: (num = 1)

SET
SET
SET
SET
SET
                                 QUERY PLAN                                 
----------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=0.00..100.90 rows=10090 width=8)
   Recheck Cond: ((num = 1) AND (flag = 1))
   ->  BitmapAnd  (cost=0.00..0.00 rows=10090 width=0)
         ->  Bitmap Index Scan on i1  (cost=0.00..0.00 rows=101000 width=0)
               Index Cond: (num = 1)
         ->  Bitmap Index Scan on i2  (cost=0.00..0.00 rows=998998 width=0)
               Index Cond: (flag = 1)

SET
SET
SET
SET
SET
                               QUERY PLAN                               
------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=505.00..505.00 rows=10090 width=8)
   Recheck Cond: (num = 1)
   Filter: (flag = 1)
   ->  Bitmap Index Scan on i1  (cost=0.00..505.00 rows=101000 width=0)
         Index Cond: (num = 1)

SET
SET
SET
SET
SET
                               QUERY PLAN                               
------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=255.46..760.46 rows=10090 width=8)
   Recheck Cond: (num = 1)
   Filter: (flag = 1)
   ->  Bitmap Index Scan on i1  (cost=0.00..252.94 rows=101000 width=0)
         Index Cond: (num = 1)

SET
SET
SET
SET
SET
                                   QUERY PLAN                                   
--------------------------------------------------------------------------------
 Bitmap Heap Scan on aaa  (cost=11273.15..20482.50 rows=10090 width=8)
   Recheck Cond: ((num = 1) AND (flag = 1))
   ->  BitmapAnd  (cost=11273.15..11273.15 rows=10090 width=0)
         ->  Bitmap Index Scan on i1  (cost=0.00..1034.93 rows=101000 width=0)
               Index Cond: (num = 1)
         ->  Bitmap Index Scan on i2  (cost=0.00..10232.92 rows=998998 width=0)
               Index Cond: (flag = 1)

Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                     QUERY PLAN                                                     
--------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194247.77 rows=10090 width=8) (actual time=0.700..2194.195 rows=10114 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9989886
   Buffers: shared read=44248
 Planning time: 4.575 ms
 Execution time: 2198.663 ms

                                                     QUERY PLAN                                                     
--------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194247.77 rows=10090 width=8) (actual time=0.145..1401.274 rows=10114 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9989886
   Buffers: shared hit=32 read=44216
 Planning time: 0.298 ms
 Execution time: 1403.893 ms

                                                     QUERY PLAN                                                     
--------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194247.77 rows=10090 width=8) (actual time=0.185..1602.002 rows=10114 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9989886
   Buffers: shared hit=64 read=44184
 Planning time: 0.140 ms
 Execution time: 1605.095 ms

                                                     QUERY PLAN                                                     
--------------------------------------------------------------------------------------------------------------------
 Seq Scan on public.aaa  (cost=0.00..194247.77 rows=10090 width=8) (actual time=0.184..1353.162 rows=10114 loops=1)
   Output: num, flag
   Filter: ((aaa.num = 1) AND (aaa.flag = 1))
   Rows Removed by Filter: 9989886
   Buffers: shared hit=96 read=44152
 Planning time: 0.139 ms
 Execution time: 1355.689 ms

SET
SET
SET
SET
SET
                      QUERY PLAN                       
-------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..0.00 rows=10090 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                        QUERY PLAN                         
-----------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..44248.00 rows=10090 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                      QUERY PLAN                       
-------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..0.00 rows=10090 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                        QUERY PLAN                         
-----------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..99999.85 rows=10090 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                      QUERY PLAN                       
-------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..0.00 rows=10090 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                        QUERY PLAN                         
-----------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..49999.93 rows=10090 width=8)
   Filter: ((num = 1) AND (flag = 1))

SET
SET
SET
SET
SET
                         QUERY PLAN                         
------------------------------------------------------------
 Seq Scan on aaa  (cost=0.00..194247.77 rows=10090 width=8)
   Filter: ((num = 1) AND (flag = 1))

DROP INDEX
DROP INDEX
CREATE INDEX
Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..46544.80 rows=10090 width=8) (actual time=0.647..1510.482 rows=10114 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 89762
   Buffers: shared read=39928
 Planning time: 2.478 ms
 Execution time: 1516.870 ms

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..46544.80 rows=10090 width=8) (actual time=0.035..141.847 rows=10114 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 89762
   Buffers: shared hit=39928
 Planning time: 0.202 ms
 Execution time: 144.146 ms

                                                         QUERY PLAN                                                         
----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..46544.80 rows=10090 width=8) (actual time=0.032..86.716 rows=10114 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 89762
   Buffers: shared hit=39928
 Planning time: 0.137 ms
 Execution time: 88.926 ms

                                                         QUERY PLAN                                                         
----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i1 on public.aaa  (cost=0.43..46544.80 rows=10090 width=8) (actual time=0.032..79.492 rows=10114 loops=1)
   Output: num, flag
   Index Cond: (aaa.num = 1)
   Filter: (aaa.flag = 1)
   Rows Removed by Filter: 89762
   Buffers: shared hit=39928
 Planning time: 0.137 ms
 Execution time: 81.321 ms

SET
SET
SET
SET
SET
                            QUERY PLAN                            
------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..0.00 rows=10090 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                            QUERY PLAN                            
------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..0.01 rows=10090 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..44524.36 rows=10090 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..1010.00 rows=10090 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                             
--------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.00..505.00 rows=10090 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                             
--------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.43..505.44 rows=10090 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i1 on aaa  (cost=0.43..46544.80 rows=10090 width=8)
   Index Cond: (num = 1)
   Filter: (flag = 1)

DROP INDEX
DROP INDEX
CREATE INDEX
Default footer is off.
SET
SET
SET
SET
 effective_cache_size 
----------------------
 1GB

SET
SET
SET
SET
SET
                                                          QUERY PLAN                                                          
------------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..40167.34 rows=10090 width=8) (actual time=0.619..1350.886 rows=10114 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 991389
   Buffers: shared read=46987
 Planning time: 2.208 ms
 Execution time: 1355.320 ms

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..40167.34 rows=10090 width=8) (actual time=0.069..448.975 rows=10114 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 991389
   Buffers: shared hit=46987
 Planning time: 0.209 ms
 Execution time: 451.251 ms

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..40167.34 rows=10090 width=8) (actual time=0.048..383.066 rows=10114 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 991389
   Buffers: shared hit=46987
 Planning time: 0.130 ms
 Execution time: 385.227 ms

                                                         QUERY PLAN                                                          
-----------------------------------------------------------------------------------------------------------------------------
 Index Scan using i2 on public.aaa  (cost=0.43..40167.34 rows=10090 width=8) (actual time=0.050..387.874 rows=10114 loops=1)
   Output: num, flag
   Index Cond: (aaa.flag = 1)
   Filter: (aaa.num = 1)
   Rows Removed by Filter: 991389
   Buffers: shared hit=46987
 Planning time: 0.130 ms
 Execution time: 390.060 ms

SET
SET
SET
SET
SET
                            QUERY PLAN                            
------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..0.00 rows=10090 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..2974.39 rows=10090 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..17212.52 rows=10090 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..9990.00 rows=10090 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.00..4995.00 rows=10090 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                             QUERY PLAN                              
---------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.43..4995.44 rows=10090 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

SET
SET
SET
SET
SET
                              QUERY PLAN                              
----------------------------------------------------------------------
 Index Scan using i2 on aaa  (cost=0.43..40167.34 rows=10090 width=8)
   Index Cond: (flag = 1)
   Filter: (num = 1)

