Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 speed up stored procedure

Author  Topic 

McGurk
Starting Member

21 Posts

Posted - 2009-10-26 : 12:09:43
Simple stored procedure but it is slow. Can I do something to speed it up?

SELECT DISTINCT Seller
FROM Sellers
ORDER BY Seller


McGurk
All that is gold does not glitter, not all those who wander are lost... JRR Tolkien

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-10-26 : 12:12:43
how many rows does it have?
is Seller indexed?
show us the data structure of that table
highlight Seller and do Alt+F1



<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

McGurk
Starting Member

21 Posts

Posted - 2009-10-26 : 12:46:17
Thanks for your quick reply!
- 50,000 rows (the stored procedure results in over 23,000 records)
- Seller is indexed
- Data structure? Are you looking for the the table structure or something more? Alt+F1 did not give me anything.

Here is the table:
SellerID(PK) Int
ID(FK) varchar(10)
Seller(Indexed) varchar(50)
Field4 varchar(15)
Field5 varchar(10)
Field6 varchar(10)
Field7 varchar(50)
Field8 char(5)
Field9 char(10)


McGurk
All that is gold does not glitter, not all those who wander are lost... JRR Tolkien
Go to Top of Page

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2009-10-26 : 14:32:25
First rebuild the index to ensure it's properly working

It's a very simple query, and if it's properly indexed, and it's still running slow, your only options are to get better hardware to run it. There's not too much that can be done in terms of rewriting the query for a dramatic speed increase.


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

mfemenel
Professor Frink

1421 Posts

Posted - 2009-10-26 : 15:05:17
Why are you using distinct? Do you have duplicate sellers in your table? The DISTINCT keyword is going to cost you a little bit of time.

Mike
"oh, that monkey is going to pay"
Go to Top of Page
   

- Advertisement -