                                                                                                                                                                                                                                                                                                                                                                                                                                          QUERY PLAN                                                                                                                                                                                                                                                                                                                                                                                                                                          
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=887785.12..887785.19 rows=26 width=245) (actual time=17616.406..17616.416 rows=17 loops=1)
   Buffers: shared hit=518327
   ->  Sort  (cost=887785.12..887785.19 rows=26 width=245) (actual time=17616.403..17616.410 rows=17 loops=1)
         Sort Key: store.s_store_name, store.s_store_id, (sum(CASE WHEN (date_dim.d_day_name = 'Sunday'::bpchar) THEN store_sales.ss_sales_price ELSE NULL::numeric END)), (sum(CASE WHEN (date_dim.d_day_name = 'Monday'::bpchar) THEN store_sales.ss_sales_price ELSE NULL::numeric END)), (sum(CASE WHEN (date_dim.d_day_name = 'Tuesday'::bpchar) THEN store_sales.ss_sales_price ELSE NULL::numeric END)), (sum(CASE WHEN (date_dim.d_day_name = 'Wednesday'::bpchar) THEN store_sales.ss_sales_price ELSE NULL::numeric END)), (sum(CASE WHEN (date_dim.d_day_name = 'Thursday'::bpchar) THEN store_sales.ss_sales_price ELSE NULL::numeric END)), (sum(CASE WHEN (date_dim.d_day_name = 'Friday'::bpchar) THEN store_sales.ss_sales_price ELSE NULL::numeric END)), (sum(CASE WHEN (date_dim.d_day_name = 'Saturday'::bpchar) THEN store_sales.ss_sales_price ELSE NULL::numeric END))
         Sort Method: quicksort  Memory: 27kB
         Buffers: shared hit=518327
         ->  GroupAggregate  (cost=886151.46..887784.51 rows=26 width=245) (actual time=15690.419..17616.288 rows=17 loops=1)
               Group Key: store.s_store_name, store.s_store_id
               Buffers: shared hit=518318
               ->  Sort  (cost=886151.46..886247.48 rows=38408 width=37) (actual time=15567.015..15749.814 rows=1802785 loops=1)
                     Sort Key: store.s_store_name, store.s_store_id
                     Sort Method: quicksort  Memory: 189995kB
                     Buffers: shared hit=518318
                     ->  Hash Join  (cost=2329.30..883226.86 rows=38408 width=37) (actual time=18.816..14266.539 rows=1802785 loops=1)
                           Hash Cond: (store_sales.ss_store_sk = store.s_store_sk)
                           Buffers: shared hit=518318
                           ->  Hash Join  (cost=2322.65..882847.36 rows=136613 width=20) (actual time=18.594..12773.800 rows=5519143 loops=1)
                                 Hash Cond: (store_sales.ss_sold_date_sk = date_dim.d_date_sk)
                                 Buffers: shared hit=518313
                                 ->  Seq Scan on store_sales  (cost=0.00..804917.92 rows=28800992 width=14) (actual time=0.004..3943.388 rows=28800991 loops=1)
                                       Buffers: shared hit=516908
                                 ->  Hash  (cost=2318.11..2318.11 rows=363 width=14) (actual time=18.577..18.578 rows=366 loops=1)
                                       Buckets: 1024  Batches: 1  Memory Usage: 26kB
                                       Buffers: shared hit=1405
                                       ->  Seq Scan on date_dim  (cost=0.00..2318.11 rows=363 width=14) (actual time=9.542..18.468 rows=366 loops=1)
                                             Filter: (d_year = 2000)
                                             Rows Removed by Filter: 72683
                                             Buffers: shared hit=1405
                           ->  Hash  (cost=6.28..6.28 rows=30 width=25) (actual time=0.130..0.131 rows=30 loops=1)
                                 Buckets: 1024  Batches: 1  Memory Usage: 10kB
                                 Buffers: shared hit=5
                                 ->  Seq Scan on store  (cost=0.00..6.28 rows=30 width=25) (actual time=0.012..0.112 rows=30 loops=1)
                                       Filter: (s_gmt_offset = '-5'::numeric)
                                       Rows Removed by Filter: 72
                                       Buffers: shared hit=5
 Planning:
   Buffers: shared hit=473
 Planning Time: 2.286 ms
 Execution Time: 17624.307 ms
(39 rows)

