HashAggregate (cost=11972282.27..11972448.32 rows=11070 width=51) (actual time=3523526.572..3523526.646 rows=30 loops=1) -> Hash Join (cost=1287232.78..11220656.06 rows=724459 width=51) (actual time=1702760.590..1898522.706 rows=662583 loops=1) Hash Cond: (a.product_operation = o.id) -> Hash Right Join (cost=1287230.86..11210692.83 rows=724459 width=40) (actual time=1702760.538..1897144.746 rows=662583 loop s=1) Hash Cond: (b.a_id = a.id) -> Append (cost=0.00..9800225.75 rows=8435755 width=10) (actual time=9132.198..1788027.626 rows=9749680 loops=1) -> Seq Scan on public.table_b b (cost=0.00..0.00 rows=1 width=22) (actual time=0.002..0.002 rows=0 loo ps=1) Filter: ((b.product_id = 2) AND (b.organization_id = 3) AND (b.year = 2013) AND (b.month = 3)) -> Bitmap Heap Scan on public.table_b_2 b (cost=172635.99..9800225.75 rows=8435754 width=10) (actual t ime=9132.194..1785196.352 rows=9749680 loops=1) Recheck Cond: ((b.organization_id = 3) AND (b.year = 2013) AND (b.month = 3)) Rows Removed by Index Recheck: 313195667 Filter: (b.product_id = 2) -> Bitmap Index Scan on table_b_2_orgid_ym_unq (cost=0.00..170527.05 rows=8435754 width=0) (actual time=849 1.007..8491.007 rows=9749680 loops=1) Index Cond: ((b.organization_id = 3) AND (b.year = 2013) AND (b.month = 3)) -> Hash (cost=1285387.42..1285387.42 rows=147475 width=34) (actual time=7291.015..7291.015 rows=662583 loops=1) Buckets: 16384 Batches: 1 Memory Usage: 44000kB -> Append (cost=0.00..1285387.42 rows=147475 width=34) (actual time=521.262..6780.112 rows=662583 loops=1) -> Seq Scan on public.table_a a (cost=0.00..0.00 rows=1 width=60) (actual time=0.001..0.001 row s=0 loops=1) Filter: ((a.twin_id IS NULL) AND (a.transaction_date >= '2012-11-01 00:00:00+00'::timestamp with time z one) AND (a.transaction_date < '2012-12-01 00:00:00+00'::timestamp with time zone) AND (a.product_id = 2) AND ((a.trans_type_id = ANY (' {2,3,4}'::integer[])) OR (a.trans_type_id IS NULL))) -> Bitmap Heap Scan on public.table_a_2 a (cost=16549.24..1285387.42 rows=147474 width=34) (act ual time=521.260..6677.788 rows=662583 loops=1) Recheck Cond: ((a.transaction_date >= '2012-11-01 00:00:00+00'::timestamp with time zone) AND (a.transa ction_date < '2012-12-01 00:00:00+00'::timestamp with time zone)) Filter: ((a.twin_id IS NULL) AND (a.product_id = 2) AND ((a.trans_type_id = ANY ('{2,3,4}'::integer[])) OR (a.trans_type_id IS NULL))) Rows Removed by Filter: 411920 -> Bitmap Index Scan on table_a_2_trans_date_idx (cost=0.00..16512.37 rows=1065722 width=0) (act ual time=376.848..376.848 rows=1074503 loops=1) Index Cond: ((a.transaction_date >= '2012-11-01 00:00:00+00'::timestamp with time zone) AND (a.tr ansaction_date < '2012-12-01 00:00:00+00'::timestamp with time zone)) -> Hash (cost=1.41..1.41 rows=41 width=19) (actual time=0.034..0.034 rows=41 loops=1) Buckets: 1024 Batches: 1 Memory Usage: 3kB -> Seq Scan on public.product_operations o (cost=0.00..1.41 rows=41 width=19) (actual time=0.006..0.016 rows=41 loops=1 ) Total runtime: 3523602.967 ms (39 rows)