                                                                                                                                 QUERY PLAN                                                                                                                                  
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Sort  (cost=887417.31..887417.67 rows=143 width=77) (actual time=11316.751..11316.758 rows=11 loops=1)
   Sort Key: (count(*)) DESC, customer.c_last_name
   Sort Method: quicksort  Memory: 26kB
   Buffers: shared hit=539725
   ->  Nested Loop  (cost=886200.17..887412.19 rows=143 width=77) (actual time=11305.479..11316.696 rows=11 loops=1)
         Buffers: shared hit=539719
         ->  GroupAggregate  (cost=886199.74..886231.84 rows=143 width=16) (actual time=11303.269..11316.316 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=539675
               ->  Sort  (cost=886199.74..886202.95 rows=1284 width=8) (actual time=11303.177..11306.178 rows=38692 loops=1)
                     Sort Key: store_sales.ss_ticket_number, store_sales.ss_customer_sk
                     Sort Method: quicksort  Memory: 3350kB
                     Buffers: shared hit=539675
                     ->  Nested Loop  (cost=2783.37..886133.45 rows=1284 width=8) (actual time=30.250..11282.446 rows=38692 loops=1)
                           Buffers: shared hit=539672
                           ->  Hash Join  (cost=2783.07..883381.74 rows=19807 width=12) (actual time=22.695..10985.598 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=22.485..10692.242 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.005..3861.220 rows=28800991 loops=1)
                                             Buffers: shared hit=516908
                                       ->  Hash  (cost=2774.67..2774.67 rows=72 width=4) (actual time=22.367..22.368 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=11.271..22.343 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.148..0.148 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.012..0.134 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
                           ->  Result Cache  (cost=0.29..0.33 rows=1 width=4) (actual time=0.000..0.000 rows=0 loops=355669)
                                 Cache Key: store_sales.ss_hdemo_sk
                                 Hits: 348550  Misses: 7119  Evictions: 0  Overflows: 0  Memory Usage: 501kB
                                 Buffers: shared hit=21354
                                 ->  Index Scan using household_demographics_pkey on household_demographics  (cost=0.28..0.32 rows=1 width=4) (actual time=0.005..0.005 rows=0 loops=7119)
                                       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=21354
         ->  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.383 ms
 Execution Time: 11325.150 ms
(55 rows)

