                                                                                                                                         QUERY PLAN                                                                                                                                         
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Sort  (cost=893080.43..893081.87 rows=575 width=77) (actual time=14739.442..14739.542 rows=1207 loops=1)
   Sort Key: customer.c_last_name, customer.c_first_name, customer.c_salutation, customer.c_preferred_cust_flag DESC, store_sales.ss_ticket_number
   Sort Method: quicksort  Memory: 215kB
   Buffers: shared hit=544752
   ->  Nested Loop  (cost=888506.27..893054.08 rows=575 width=77) (actual time=14678.570..14735.456 rows=1207 loops=1)
         Buffers: shared hit=544746
         ->  GroupAggregate  (cost=888505.85..888635.33 rows=575 width=16) (actual time=14678.509..14724.593 rows=1207 loops=1)
               Group Key: store_sales.ss_ticket_number, store_sales.ss_customer_sk
               Filter: ((count(*) >= 15) AND (count(*) <= 20))
               Rows Removed by Filter: 11870
               Buffers: shared hit=539918
               ->  Sort  (cost=888505.85..888518.80 rows=5179 width=8) (actual time=14678.362..14688.883 rows=135866 loops=1)
                     Sort Key: store_sales.ss_ticket_number, store_sales.ss_customer_sk
                     Sort Method: quicksort  Memory: 12513kB
                     Buffers: shared hit=539918
                     ->  Hash Join  (cost=3151.40..888186.35 rows=5179 width=8) (actual time=25.713..14606.362 rows=135866 loops=1)
                           Hash Cond: (store_sales.ss_store_sk = store.s_store_sk)
                           Buffers: shared hit=539918
                           ->  Nested Loop  (cost=3143.16..888162.40 rows=5756 width=12) (actual time=25.512..14484.415 rows=411271 loops=1)
                                 Buffers: shared hit=539913
                                 ->  Hash Join  (cost=3142.86..883667.57 rows=88817 width=16) (actual time=25.140..11902.362 rows=3794674 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..3908.401 rows=28800991 loops=1)
                                             Buffers: shared hit=516908
                                       ->  Hash  (cost=3139.91..3139.91 rows=236 width=4) (actual time=25.109..25.110 rows=252 loops=1)
                                             Buckets: 1024  Batches: 1  Memory Usage: 17kB
                                             Buffers: shared hit=1405
                                             ->  Seq Scan on date_dim  (cost=0.00..3139.91 rows=236 width=4) (actual time=12.926..25.032 rows=252 loops=1)
                                                   Filter: ((d_year = ANY ('{2000,2001,2002}'::integer[])) AND (((d_dom >= 1) AND (d_dom <= 3)) OR ((d_dom >= 25) AND (d_dom <= 28))))
                                                   Rows Removed by Filter: 72797
                                                   Buffers: shared hit=1405
                                 ->  Result Cache  (cost=0.29..0.33 rows=1 width=4) (actual time=0.000..0.000 rows=0 loops=3794674)
                                       Cache Key: store_sales.ss_hdemo_sk
                                       Hits: 3787473  Misses: 7201  Evictions: 0  Overflows: 0  Memory Usage: 507kB
                                       Buffers: shared hit=21600
                                       ->  Index Scan using household_demographics_pkey on household_demographics  (cost=0.28..0.32 rows=1 width=4) (actual time=0.004..0.004 rows=0 loops=7201)
                                             Index Cond: (hd_demo_sk = store_sales.ss_hdemo_sk)
                                             Filter: ((hd_vehicle_count > 0) AND ((hd_buy_potential = '501-1000'::bpchar) OR (hd_buy_potential = 'Unknown'::bpchar)) AND ((CASE WHEN (hd_vehicle_count > 0) THEN (hd_dep_count / hd_vehicle_count) ELSE NULL::integer END)::numeric > 1.2))
                                             Rows Removed by Filter: 1
                                             Buffers: shared hit=21600
                           ->  Hash  (cost=7.04..7.04 rows=96 width=4) (actual time=0.146..0.147 rows=31 loops=1)
                                 Buckets: 1024  Batches: 1  Memory Usage: 10kB
                                 Buffers: shared hit=5
                                 ->  Seq Scan on store  (cost=0.00..7.04 rows=96 width=4) (actual time=0.013..0.132 rows=31 loops=1)
                                       Filter: ((s_county)::text = ANY ('{"Williamson County","Williamson County","Williamson County","Williamson County","Williamson County","Williamson County","Williamson County","Williamson County"}'::text[]))
                                       Rows Removed by Filter: 71
                                       Buffers: shared hit=5
         ->  Index Scan using customer_pkey on customer  (cost=0.42..7.67 rows=1 width=69) (actual time=0.008..0.008 rows=1 loops=1207)
               Index Cond: (c_customer_sk = store_sales.ss_customer_sk)
               Buffers: shared hit=4828
 Planning:
   Buffers: shared hit=614
 Planning Time: 3.450 ms
 Execution Time: 14740.839 ms
(55 rows)

