October 30, 2013 at 7:19 am
AssembleTrn is table with about 170157 records
when i run this query it will take about more than 1.30 minute
plesae help me in getting recoeds in faster wat
select sum(Qty) as qty,at.POConfirmID from AssembleTrn at where at.Type =1 and at.status=1
group by POConfirmID
thank in advance
from
Janki Shah
October 30, 2013 at 7:26 am
janki0430 (10/30/2013)
AssembleTrn is table with about 170157 recordswhen i run this query it will take about more than 1.30 minute
plesae help me in getting recoeds in faster wat
select sum(Qty) as qty,at.POConfirmID from AssembleTrn at where at.Type =1 and at.status=1
group by POConfirmID
thank in advance
from
Janki Shah
can you please provide some details like table structure...
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
October 30, 2013 at 7:30 am
kapil_kk (10/30/2013)
janki0430 (10/30/2013)
AssembleTrn is table with about 170157 recordswhen i run this query it will take about more than 1.30 minute
plesae help me in getting recoeds in faster wat
select sum(Qty) as qty,at.POConfirmID from AssembleTrn at where at.Type =1 and at.status=1
group by POConfirmID
thank in advance
from
Janki Shah
can you please provide some details like table structure...
and any indexes that may be on the table. You can create a covering index for this query on AssembleTrn with columns Type, Status, POConfirmID and Qty
October 30, 2013 at 7:42 am
You should look to the execution plan to understand what is happening in your query and how the optimizer is choosing to select your data.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 30, 2013 at 7:03 pm
janki0430 (10/30/2013)
AssembleTrn is table with about 170157 recordswhen i run this query it will take about more than 1.30 minute
plesae help me in getting recoeds in faster wat
select sum(Qty) as qty,at.POConfirmID from AssembleTrn at where at.Type =1 and at.status=1
group by POConfirmID
thank in advance
from
Janki Shah
Add an index that contains POConfirmID, Type, and Status in that order (for a first guess) with an INCLUDE for Qty.
Also, get into the habit of always using the 2 part naming convention on all table references.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 30, 2013 at 7:05 pm
Keith Tate (10/30/2013)
kapil_kk (10/30/2013)
janki0430 (10/30/2013)
AssembleTrn is table with about 170157 recordswhen i run this query it will take about more than 1.30 minute
plesae help me in getting recoeds in faster wat
select sum(Qty) as qty,at.POConfirmID from AssembleTrn at where at.Type =1 and at.status=1
group by POConfirmID
thank in advance
from
Janki Shah
can you please provide some details like table structure...
and any indexes that may be on the table. You can create a covering index for this query on AssembleTrn with columns Type, Status, POConfirmID and Qty
Be careful now. That would give you an index with a leading column that has very low cardinality. Inserts to the table will cause massive page/extent splits that could (likely will) actually lead to massive timeouts on the GUI side of the house.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 30, 2013 at 7:16 pm
Good point Jeff. I was simply making a suggestion of which columns should be in the index not intending them to be added necessary in that order, but I should have made a best guess at the correct order.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply