                                                                                                                                                                                                                                                                                                                                                                                                                                          QUERY PLAN                                                                                                                                                                                                                                                                                                                                                                                                                                          
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=890811.42..890811.49 rows=26 width=245) (actual time=19915.330..19915.339 rows=17 loops=1)
   Buffers: shared hit=518424
   ->  Sort  (cost=890811.42..890811.49 rows=26 width=245) (actual time=19915.327..19915.334 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=518424
         ->  GroupAggregate  (cost=889177.76..890810.81 rows=26 width=245) (actual time=17986.909..19915.220 rows=17 loops=1)
               Group Key: store.s_store_name, store.s_store_id
               Buffers: shared hit=518415
               ->  Sort  (cost=889177.76..889273.78 rows=38408 width=37) (actual time=17863.748..18046.900 rows=1802785 loops=1)
                     Sort Key: store.s_store_name, store.s_store_id
                     Sort Method: quicksort  Memory: 189995kB
                     Buffers: shared hit=518415
                     ->  Nested Loop  (cost=2322.80..886253.16 rows=38408 width=37) (actual time=19.579..16505.790 rows=1802785 loops=1)
                           Buffers: shared hit=518415
                           ->  Hash Join  (cost=2322.65..882847.36 rows=136613 width=20) (actual time=19.457..12655.905 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.007..3957.617 rows=28800991 loops=1)
                                       Buffers: shared hit=516908
                                 ->  Hash  (cost=2318.11..2318.11 rows=363 width=14) (actual time=19.432..19.434 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.929..19.317 rows=366 loops=1)
                                             Filter: (d_year = 2000)
                                             Rows Removed by Filter: 72683
                                             Buffers: shared hit=1405
                           ->  Result Cache  (cost=0.15..0.17 rows=1 width=25) (actual time=0.000..0.000 rows=0 loops=5519143)
                                 Cache Key: store_sales.ss_store_sk
                                 Hits: 5519091  Misses: 52  Evictions: 0  Overflows: 0  Memory Usage: 5kB
                                 Buffers: shared hit=102
                                 ->  Index Scan using store_pkey on store  (cost=0.14..0.16 rows=1 width=25) (actual time=0.003..0.003 rows=0 loops=52)
                                       Index Cond: (s_store_sk = store_sales.ss_store_sk)
                                       Filter: (s_gmt_offset = '-5'::numeric)
                                       Rows Removed by Filter: 1
                                       Buffers: shared hit=102
 Planning:
   Buffers: shared hit=473
 Planning Time: 2.356 ms
 Execution Time: 19922.577 ms
(40 rows)

