SQL Server Performance Forum – Threads Archive
Need a biggg help optimizing Stored procedure.People – I have a question for you regarding optimizing an existing Stored procedure for me. This will be a long description which covers the business need and required dataset for me. Please take a little time and help me with this. Business Requirement
This stored procedure will get an XML file which has some search criteria and the stored procedure is expected to do some joins depending on the criteria and return the dataset. The new requirement is to see if the existing stored procedure can be optimized further. See if changing the table structure or modifying the stored procedure will improve performance or not. I’m sorry for really big chunk of code and table design i’m posting, but i felt this would help you guys to figure out what exactly happening.
Description of Tables used in Stored procedure
The only static table used in this stored procedure is MISSDenormalized and the rest of the tables local to Stored procedure. These tables are created based on the search criteria that is passed into the Stored procedure. Design of MISSDenormalized table
AwardedBus The description for other tables are specified in stored procedure which i will post the bottom. Working of Stored Procedure
————————— To drill down, the three main columns are UNSPSCCODE, AttributeID and AttributeValue. Sample Test Criteria
<ISOCertText ID="414"><![CDATA[ISO 9001 Certified]]></ISOCertText>
</SearchCriteria> Now, the stored procedure will load the values into the temp table VARIABLES local to stored procedure and will join those table variables with MIDD_Denormalized table to get the DataSet.
HOW TO OPTIMIZE.
————— Since, the stored procedure is very big in size, i added this in Yahoo briefcase and made it PUBLIC so that everyone can look at the stored procedure. CAN YOU PLEASE LOOK INTO THE STORED PROCEDURE AND TELL ME HOW WE CAN INCREASE THE PERFORMANCE OF THE STORED PROCEDURE? There is a while loop used to fetch the dataset when there are more than one <Attributes> node in the search criteria. And my team lead feels, if some how the while loop is skipped the there will be an increase in performance. But i’m just out of ideas. IF ANYONE CAN JUST TAKE A LOOK AT STORED PROCEDURE AND THROW IN SOME IDEA, I WILL WORK ON THAT. Link to file which has Stored procedure —>http://us.f1f.yahoofs.com/bc/2abd67d3/bc/SQL/StoredProc.sql?bf6qSEBBMQw_OeDW
Link to Sample Data (Only three fields) –>http://us.f1f.yahoofs.com/bc/2abd67d3/bc/SQL/SampleData.txt?bf6qSEBBxImhs7Kw I know that the information that i gave above is not enough toorrectly understand, So please shoot me a reply back and will reply to you guys immediately. Thanks,
If you need to improve performance with new indexs, use Query Analyzer and see execution plan.
If you need to improve performance with smart codification, I suggest try using SQL Server Tuning version 3.3 (Trial) from Quest Central. HTH Luis Martin
SQL-Server-Performance.com All postings are provided â€œAS ISâ€ with no warranties for accuracy.
Thanks Martin….Will try that…If anyone has anymore ideas, please let me know.
… artciles reference to fine tune the issue. HTH Satya SKJ
This posting is provided â€œAS ISâ€ with no rights for the sake of knowledge sharing.