                                                                                                                     QUERY PLAN                                                                                                                      
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=898777.61..898777.86 rows=100 width=210) (actual time=24014.916..24014.940 rows=100 loops=1)
   Buffers: shared hit=525391
   ->  Sort  (cost=898777.61..898780.11 rows=1001 width=210) (actual time=24014.914..24014.926 rows=100 loops=1)
         Sort Key: ((GROUPING(item.i_category) + GROUPING(item.i_class))) DESC, (CASE WHEN (((GROUPING(item.i_category) + GROUPING(item.i_class))) = 0) THEN item.i_category ELSE NULL::bpchar END), (rank() OVER (?))
         Sort Method: quicksort  Memory: 61kB
         Buffers: shared hit=525391
         ->  WindowAgg  (cost=898704.31..898739.35 rows=1001 width=210) (actual time=24013.981..24014.330 rows=166 loops=1)
               Buffers: shared hit=525382
               ->  Sort  (cost=898704.31..898706.82 rows=1001 width=178) (actual time=24013.965..24013.984 rows=166 loops=1)
                     Sort Key: ((GROUPING(item.i_category) + GROUPING(item.i_class))), (CASE WHEN (GROUPING(item.i_class) = 0) THEN item.i_category ELSE NULL::bpchar END), ((sum(store_sales.ss_net_profit) / sum(store_sales.ss_ext_sales_price)))
                     Sort Method: quicksort  Memory: 61kB
                     Buffers: shared hit=525382
                     ->  MixedAggregate  (cost=11581.80..898654.43 rows=1001 width=178) (actual time=24013.164..24013.481 rows=166 loops=1)
                           Hash Key: item.i_category, item.i_class
                           Hash Key: item.i_category
                           Group Key: ()
                           Batches: 1  Memory Usage: 329kB
                           Buffers: shared hit=525379
                           ->  Hash Join  (cost=11581.80..895837.70 rows=124187 width=114) (actual time=125.808..18647.791 rows=1888703 loops=1)
                                 Hash Cond: (store_sales.ss_item_sk = item.i_item_sk)
                                 Buffers: shared hit=525379
                                 ->  Nested Loop  (cost=2322.80..886252.70 rows=124187 width=16) (actual time=19.371..17192.366 rows=1888703 loops=1)
                                       Buffers: shared hit=518415
                                       ->  Hash Join  (cost=2322.65..882847.36 rows=136613 width=20) (actual time=19.320..13321.683 rows=5470761 loops=1)
                                             Hash Cond: (store_sales.ss_sold_date_sk = d1.d_date_sk)
                                             Buffers: shared hit=518313
                                             ->  Seq Scan on store_sales  (cost=0.00..804917.92 rows=28800992 width=24) (actual time=0.007..3975.713 rows=28800991 loops=1)
                                                   Buffers: shared hit=516908
                                             ->  Hash  (cost=2318.11..2318.11 rows=363 width=4) (actual time=19.273..19.274 rows=365 loops=1)
                                                   Buckets: 1024  Batches: 1  Memory Usage: 21kB
                                                   Buffers: shared hit=1405
                                                   ->  Seq Scan on date_dim d1  (cost=0.00..2318.11 rows=363 width=4) (actual time=10.099..19.166 rows=365 loops=1)
                                                         Filter: (d_year = 2001)
                                                         Rows Removed by Filter: 72684
                                                         Buffers: shared hit=1405
                                       ->  Result Cache  (cost=0.15..0.18 rows=1 width=4) (actual time=0.000..0.000 rows=0 loops=5470761)
                                             Cache Key: store_sales.ss_store_sk
                                             Hits: 5470709  Misses: 52  Evictions: 0  Overflows: 0  Memory Usage: 5kB
                                             Buffers: shared hit=102
                                             ->  Index Scan using store_pkey on store  (cost=0.14..0.17 rows=1 width=4) (actual time=0.004..0.004 rows=0 loops=52)
                                                   Index Cond: (s_store_sk = store_sales.ss_store_sk)
                                                   Filter: (s_state = ANY ('{TN,TN,TN,TN,TN,TN,TN,TN}'::bpchar[]))
                                                   Rows Removed by Filter: 1
                                                   Buffers: shared hit=102
                                 ->  Hash  (cost=7984.00..7984.00 rows=102000 width=106) (actual time=106.093..106.094 rows=102000 loops=1)
                                       Buckets: 131072  Batches: 1  Memory Usage: 14946kB
                                       Buffers: shared hit=6964
                                       ->  Seq Scan on item  (cost=0.00..7984.00 rows=102000 width=106) (actual time=0.017..63.397 rows=102000 loops=1)
                                             Buffers: shared hit=6964
 Planning:
   Buffers: shared hit=415
 Planning Time: 2.720 ms
 Execution Time: 24015.405 ms
(53 rows)

