in Education by
This is a question I asked on another forum which received some decent answers, but I wanted to see if anyone here has more insight. The problem is that you have one of your pages in a web application timing out when it gets to a stored procedure call, so you use Sql Profiler, or your application trace logs, to find the query and you paste it into management studio to figure our why it's running slow. But you run it from there and it just blazes along, returning in less than a second each time. My particular case was using ASP.NET 2.0 and Sql Server 2005, but I think the problem could apply to any RDBMS system. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
This is what I've learned so far from my research. .NET sends in connection settings that are not the same as what you get when you log in to management studio. Here is what you see if you sniff the connection with Sql Profiler: -- network protocol: TCP/IP set quoted_identifier off set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls off set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language us_english set dateformat mdy set datefirst 7 set transaction isolation level read committed I am now pasting those setting in above every query that I run when logged in to sql server, to make sure the settings are the same. For this case, I tried each setting individually, after disconnecting and reconnecting, and found that changing arithabort from off to on reduced the problem query from 90 seconds to 1 second. The most probable explanation is related to parameter sniffing, which is a technique Sql Server uses to pick what it thinks is the most effective query plan. When you change one of the connection settings, the query optimizer might choose a different plan, and in this case, it apparently chose a bad one. But I'm not totally convinced of this. I have tried comparing the actual query plans after changing this setting and I have yet to see the diff show any changes. Is there something else about the arithabort setting that might cause a query to run slowly in some cases? The solution seemed simple: Just put set arithabort on into the top of the stored procedure. But this could lead to the opposite problem: change the query parameters and suddenly it runs faster with 'off' than 'on'. For the time being I am running the procedure 'with recompile' to make sure the plan gets regenerated each time. It's Ok for this particular report, since it takes maybe a second to recompile, and this isn't too noticeable on a report that takes 1-10 seconds to return (it's a monster). But it's not an option for other queries that run much more frequently and need to return as quickly as possible, in just a few milliseconds.

Related questions

0 votes
    I have a stored procedure in SQL 2005. The Stored Procedure is actually creating temporary tables in the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I have a stored procedure in SQL 2005. The Stored Procedure is actually creating temporary tables in the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 18, 2022 in Education by JackTerrance
0 votes
    I have a stored procedure in SQL 2005. The Stored Procedure is actually creating temporary tables in the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 18, 2022 in Education by JackTerrance
0 votes
    Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I'm trying to write a query that will pull back the two most recent rows from the Bill table ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I have a rating system in which any person may review other. Each person can be judged by one person more than once. For the ... SQL? Person 1 rates Person 2 with 5 on 1.2.2011...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    I have a rating system in which any person may review other. Each person can be judged by one person more than once. For the ... SQL? Person 1 rates Person 2 with 5 on 1.2.2011...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I try to select the Products that has a yearmodel between +1 and -1 the current year. And I only ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I try to select the Products that has a yearmodel between +1 and -1 the current year. And I only ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I have added some code for a "lightbox" effect on one of my images (below) [The website is live] ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    #include void display(int *q,int,int); int main(){ int a[3][4]={ 2,3,4,5, 5,7,6,8, 9,0,1,6 }; display(a,3,4); return 0; } void display(int *q,int row,int col){ int i,j; for(i=0;i...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    #include void display(int *q,int,int); int main(){ int a[3][4]={ 2,3,4,5, 5,7,6,8, 9,0,1,6 }; display(a,3,4); return 0; } void display(int *q,int row,int col){ int i,j; for(i=0;i...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    The handler runs only once even if you run the Playbook many times. (1)True (2)False...
asked Jul 5, 2021 in Education by JackTerrance
0 votes
    I am writing a powershell script that will automate a dev environment deployment and I've hit a problem ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
...