postgres=# explain (ANALYZE, BUFFERS, VERBOSE, WAL) insert into testscan select a from x where a<80000 or (a%2=0 and a>199900000); QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------- Insert on public.testscan (cost=3272.20..3652841.26 rows=0 width=0) (actual time=360.474..360.476 rows=0 loops=1) Buffers: shared hit=392569 read=3 dirtied=934 written=933 WAL: records=260354 bytes=16259841 -> Bitmap Heap Scan on public.x (cost=3272.20..3652841.26 rows=79918 width=8) (actual time=8.096..41.005 rows=129999 loops=1) Output: x.a, NULL::integer Recheck Cond: ((x.a < 80000) OR (x.a > 199900000)) Filter: ((x.a < 80000) OR (((x.a % 2) = 0) AND (x.a > 199900000))) Rows Removed by Filter: 50000 Heap Blocks: exact=975 Buffers: shared hit=1475 -> BitmapOr (cost=3272.20..3272.20 rows=174813 width=0) (actual time=7.975..7.976 rows=0 loops=1) Buffers: shared hit=500 -> Bitmap Index Scan on x_a_idx (cost=0.00..1468.38 rows=79441 width=0) (actual time=3.469..3.470 rows=79999 loops=1) Index Cond: (x.a < 80000) Buffers: shared hit=222 -> Bitmap Index Scan on x_a_idx (cost=0.00..1763.86 rows=95372 width=0) (actual time=4.499..4.499 rows=100000 loops=1) Index Cond: (x.a > 199900000) Buffers: shared hit=278 Planning: Buffers: shared hit=10 Planning Time: 0.126 ms Execution Time: 360.547 ms (22 rows)