                                                                                                                              QUERY PLAN                                                                                                                               
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Sort  (cost=890904.92..890905.27 rows=143 width=77) (actual time=12163.345..12163.352 rows=11 loops=1)
   Sort Key: (count(*)) DESC, customer.c_last_name
   Sort Method: quicksort  Memory: 26kB
   Buffers: shared hit=1572349
   ->  Nested Loop  (cost=889687.77..890899.80 rows=143 width=77) (actual time=12152.117..12163.289 rows=11 loops=1)
         Buffers: shared hit=1572343
         ->  GroupAggregate  (cost=889687.35..889719.45 rows=143 width=16) (actual time=12149.855..12162.936 rows=229 loops=1)
               Group Key: store_sales.ss_ticket_number, store_sales.ss_customer_sk
               Filter: ((count(*) >= 1) AND (count(*) <= 5))
               Rows Removed by Filter: 3479
               Buffers: shared hit=1572299
               ->  Sort  (cost=889687.35..889690.56 rows=1284 width=8) (actual time=12149.763..12152.760 rows=38692 loops=1)
                     Sort Key: store_sales.ss_ticket_number, store_sales.ss_customer_sk
                     Sort Method: quicksort  Memory: 3350kB
                     Buffers: shared hit=1572299
                     ->  Nested Loop  (cost=2783.36..889621.05 rows=1284 width=8) (actual time=29.793..12127.664 rows=38692 loops=1)
                           Buffers: shared hit=1572296
                           ->  Hash Join  (cost=2783.07..883381.74 rows=19807 width=12) (actual time=21.935..10911.767 rows=355669 loops=1)
                                 Hash Cond: (store_sales.ss_store_sk = store.s_store_sk)
                                 Buffers: shared hit=518318
                                 ->  Hash Join  (cost=2775.57..883300.28 rows=27097 width=16) (actual time=21.751..10614.686 rows=1086621 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=20) (actual time=0.004..3896.974 rows=28800991 loops=1)
                                             Buffers: shared hit=516908
                                       ->  Hash  (cost=2774.67..2774.67 rows=72 width=4) (actual time=21.638..21.639 rows=72 loops=1)
                                             Buckets: 1024  Batches: 1  Memory Usage: 11kB
                                             Buffers: shared hit=1405
                                             ->  Seq Scan on date_dim  (cost=0.00..2774.67 rows=72 width=4) (actual time=10.976..21.614 rows=72 loops=1)
                                                   Filter: ((d_dom >= 1) AND (d_dom <= 2) AND (d_year = ANY ('{1999,2000,2001}'::integer[])))
                                                   Rows Removed by Filter: 72977
                                                   Buffers: shared hit=1405
                                 ->  Hash  (cost=6.53..6.53 rows=78 width=4) (actual time=0.131..0.132 rows=31 loops=1)
                                       Buckets: 1024  Batches: 1  Memory Usage: 10kB
                                       Buffers: shared hit=5
                                       ->  Seq Scan on store  (cost=0.00..6.53 rows=78 width=4) (actual time=0.013..0.117 rows=31 loops=1)
                                             Filter: ((s_county)::text = ANY ('{"Williamson County","Williamson County","Williamson County","Williamson County"}'::text[]))
                                             Rows Removed by Filter: 71
                                             Buffers: shared hit=5
                           ->  Index Scan using household_demographics_pkey on household_demographics  (cost=0.28..0.32 rows=1 width=4) (actual time=0.003..0.003 rows=0 loops=355669)
                                 Index Cond: (hd_demo_sk = store_sales.ss_hdemo_sk)
                                 Filter: ((hd_vehicle_count > 0) AND ((hd_buy_potential = '1001-5000'::bpchar) OR (hd_buy_potential = '5001-10000'::bpchar)) AND (CASE WHEN (hd_vehicle_count > 0) THEN (hd_dep_count / hd_vehicle_count) ELSE NULL::integer END > 1))
                                 Rows Removed by Filter: 1
                                 Buffers: shared hit=1053978
         ->  Index Scan using customer_pkey on customer  (cost=0.42..8.24 rows=1 width=69) (actual time=0.001..0.001 rows=0 loops=229)
               Index Cond: (c_customer_sk = store_sales.ss_customer_sk)
               Buffers: shared hit=44
 Planning:
   Buffers: shared hit=620
 Planning Time: 3.122 ms
 Execution Time: 12163.740 ms
(51 rows)

