                                                                                                                                         QUERY PLAN                                                                                                                                         
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Sort  (cost=893080.43..893081.87 rows=575 width=77)
   Sort Key: customer.c_last_name, customer.c_first_name, customer.c_salutation, customer.c_preferred_cust_flag DESC, store_sales.ss_ticket_number
   ->  Nested Loop  (cost=888506.27..893054.08 rows=575 width=77)
         ->  GroupAggregate  (cost=888505.85..888635.33 rows=575 width=16)
               Group Key: store_sales.ss_ticket_number, store_sales.ss_customer_sk
               Filter: ((count(*) >= 15) AND (count(*) <= 20))
               ->  Sort  (cost=888505.85..888518.80 rows=5179 width=8)
                     Sort Key: store_sales.ss_ticket_number, store_sales.ss_customer_sk
                     ->  Hash Join  (cost=3151.40..888186.35 rows=5179 width=8)
                           Hash Cond: (store_sales.ss_store_sk = store.s_store_sk)
                           ->  Nested Loop  (cost=3143.16..888162.40 rows=5756 width=12)
                                 ->  Hash Join  (cost=3142.86..883667.57 rows=88817 width=16)
                                       Hash Cond: (store_sales.ss_sold_date_sk = date_dim.d_date_sk)
                                       ->  Seq Scan on store_sales  (cost=0.00..804917.92 rows=28800992 width=20)
                                       ->  Hash  (cost=3139.91..3139.91 rows=236 width=4)
                                             ->  Seq Scan on date_dim  (cost=0.00..3139.91 rows=236 width=4)
                                                   Filter: ((d_year = ANY ('{2000,2001,2002}'::integer[])) AND (((d_dom >= 1) AND (d_dom <= 3)) OR ((d_dom >= 25) AND (d_dom <= 28))))
                                 ->  Result Cache  (cost=0.29..0.33 rows=1 width=4)
                                       Cache Key: store_sales.ss_hdemo_sk
                                       ->  Index Scan using household_demographics_pkey on household_demographics  (cost=0.28..0.32 rows=1 width=4)
                                             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))
                           ->  Hash  (cost=7.04..7.04 rows=96 width=4)
                                 ->  Seq Scan on store  (cost=0.00..7.04 rows=96 width=4)
                                       Filter: ((s_county)::text = ANY ('{"Williamson County","Williamson County","Williamson County","Williamson County","Williamson County","Williamson County","Williamson County","Williamson County"}'::text[]))
         ->  Index Scan using customer_pkey on customer  (cost=0.42..7.67 rows=1 width=69)
               Index Cond: (c_customer_sk = store_sales.ss_customer_sk)
(27 rows)

