                                                                                                                                         QUERY PLAN                                                                                                                                         
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Sort  (cost=889076.00..889077.43 rows=575 width=77) (actual time=12802.171..12802.271 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=523205
   ->  Nested Loop  (cost=884501.84..889049.64 rows=575 width=77) (actual time=12741.348..12798.192 rows=1207 loops=1)
         Buffers: shared hit=523199
         ->  GroupAggregate  (cost=884501.42..884630.89 rows=575 width=16) (actual time=12741.281..12787.522 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=518371
               ->  Sort  (cost=884501.42..884514.36 rows=5179 width=8) (actual time=12741.130..12751.629 rows=135866 loops=1)
                     Sort Key: store_sales.ss_ticket_number, store_sales.ss_customer_sk
                     Sort Method: quicksort  Memory: 12513kB
                     Buffers: shared hit=518371
                     ->  Hash Join  (cost=3408.22..884181.91 rows=5179 width=8) (actual time=27.541..12672.232 rows=135866 loops=1)
                           Hash Cond: (store_sales.ss_store_sk = store.s_store_sk)
                           Buffers: shared hit=518371
                           ->  Hash Join  (cost=3399.98..884157.96 rows=5756 width=12) (actual time=27.352..12564.170 rows=411271 loops=1)
                                 Hash Cond: (store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk)
                                 Buffers: shared hit=518366
                                 ->  Hash Join  (cost=3142.86..883667.57 rows=88817 width=16) (actual time=24.173..11734.784 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.004..3853.249 rows=28800991 loops=1)
                                             Buffers: shared hit=516908
                                       ->  Hash  (cost=3139.91..3139.91 rows=236 width=4) (actual time=24.151..24.152 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=11.994..24.074 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
                                 ->  Hash  (cost=251.00..251.00 rows=489 width=4) (actual time=2.945..2.945 rows=800 loops=1)
                                       Buckets: 1024  Batches: 1  Memory Usage: 37kB
                                       Buffers: shared hit=53
                                       ->  Seq Scan on household_demographics  (cost=0.00..251.00 rows=489 width=4) (actual time=0.384..2.705 rows=800 loops=1)
                                             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: 6400
                                             Buffers: shared hit=53
                           ->  Hash  (cost=7.04..7.04 rows=96 width=4) (actual time=0.147..0.148 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.014..0.134 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.217 ms
 Execution Time: 12803.469 ms
(54 rows)

