Question: select l _ returnflag, l _ linestatus, sum ( l _ quantity ) as sum _ qty , sum ( l _ extendedprice ) as

select
l_returnflag,
l_linestatus,
sum(l_quantity) as sum_qty,
sum(l_extendedprice) as sum_base_price,
sum(l_extendedprice*(1-l_discount)) as sum_disc_price,
sum(l_extendedprice*(1-l_discount)*(1+l_tax)) as sum_charge,
avg(l_quantity) as avg_qty,
avg(l_extendedprice) as avg_price,
avg(l_discount) as avg_disc,
count(*) as count_order
from
scale1.lineitem
where
l_shipdate <= date '1998-12-01'- interval '90' day
group by
l_returnflag,
l_linestatus
order by
l_returnflag,
l_linestatus;
this is the query plan based on the query above:
Finalize GroupAggregate (cost=231151.60..231153.55 rows=6 width=236)
Group Key: l_returnflag, l_linestatus
-> Gather Merge (cost=231151.60..231153.00 rows=12 width=236)
Workers Planned: 2
-> Sort (cost=230151.58..230151.59 rows=6 width=236)
Sort Key: l_returnflag, l_linestatus
-> Partial HashAggregate (cost=230151.36..230151.50 rows=6 width=236)
Group Key: l_returnflag, l_linestatus
-> Parallel Seq Scan on lineitem (cost=0.00..143854.94 rows=2465612 width=25)
Filter: (l_shipdate <='1998-09-0200:00:00'::timestamp without time zone)
Provide an sketch of a query plan for the column-based approach using late materialization.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!