Hi Everyone,

I have a query as -


select top 10 bm.name, sum(sd.Amount) as bd
from brandmaster bm join lobattributevalue lob
on bm.brandid = lob.valueid and bm.lobid = lob.lobid
join salesdetail sd
on sd.productid = lob.productid
where lob.attributeid = 3
group by bm.name
order by bd desc

Now In this query I am joining multiple tables which has millions of rows.
This query takes about 40-50sec for execution

Can anyone tell me how can I optimize this query.

Does anyone know about INDEXING, PERFORMANCE ANALYZER and steps to use them in MSSQL 2005

You can try making a stored procedure and see how faster you receive your answer back.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.