performance - To make the following query run in one sec in sql server 2012 -
I have to retrieve the following query the top 10 commands that were not shipped before a certain date : The linetime has 60M records and the order has 15M records.
select from top 10 * (select o_orderkey, o_shippriority, o_orderdate, sum (l_extendedprice line item greater than * (1-l_discount)) by joining the line item l , L.l_partkey, split by l.l_suppkey) as new_with_resources_array_l.l_orderkey = o.o_orderkey on where l.l_shipdate> '2014-08-05' and o_orderstatus = 'o') by potential_revenue desc order; l_shipdate and l_orderkey is a cluster index divided on it date and o_orderkey < There is a package index for Code> Order table I have created a non-cluster index on the O-Orstatus column The query is taking 11 seconds to run and I'm wondering what else Can it be done to improve the performance of the query?
try these indexes
create nonclustered index on neworders Ix_neworders ( O_orderstatus) (o_orderdate, o_shippriority); Include non-indexed index Ix_lineitem on lineitem (L_AdadePrices) (l_discount, l_partkey, l_suppkey); Still the top expensive operation is. When you want to explain the plan, take a look for the key lookup. If you have, try to make the appropriate index + Focus on the index scanner wants to index them try to index.
Comments
Post a Comment