July 21, 2015 at 6:14 pm
We're using a survey tool, Votations Nsurvey, to build a web form, and running into a SQL performance issue. Initially, when DB size is still relatively small, about several thousands of records. Now it has grown to hundreds of thousands records, and one of the Stored Procedure runs very slow, take about 30-50 seconds to complete.
The query is basically to select all questions and answers specific form, and then write it out to a web page. See attached file for SQL query.
I'm looking for any advises and suggestions on how to improve this query.
Thank you all very much.
July 21, 2015 at 6:50 pm
1) You have what are almost certainly views in that query, so G-d only knows what the decompiled query looks like. I have seen queries like that net out to HUNDREDS of lines of SELECT statement.
2) How many rows are returned?
3) Have you checked for blocking/waits during execution? sp_whoisactive for that
4) Have you done wait stats analysis during execution?
5) Have you done file IO stall analysis during execution?
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
July 21, 2015 at 8:53 pm
Some DDL for the tables and underlying objects involved would be helpful. Note the link in my subject line.
Also, could you include the query plan that this query generates?
From just a quick look at your query I can tell you that the ORDER BY is probably not doing you any favors.
-- Itzik Ben-Gan 2001
July 22, 2015 at 2:53 am
Table definitions, index definitions and the actual execution plan please?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 22, 2015 at 3:46 am
July 22, 2015 at 6:47 am
Thank you for your reply, Kevin.
Per your questions:
#1. Yes, it uses views, instead of tables;
#2. It only returns about 5-10 rows per question ID. It take 1-2 second run for one question. However, there are about 10 to 20 questions in a given survey form, and together, it takes about 30-50 seconds to complete entire form questionnaire.
#3. Not yet, but will try it today;
#4. Not yet, and need to learn how to do it first;
#5. Not yet, and need to learn how to do it first;
Again, thank you very much for your advises.
July 22, 2015 at 6:48 am
Thanks, Gail. I'll discuss it with my DBA.
July 22, 2015 at 6:49 am
very good reference. Thanks.
July 24, 2015 at 12:46 pm
UPDATE:
We removed a Count(*) function in the query, and the performance improved significantly.
Thanks to everyone's suggestion.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply