Re: Stored Procedure is running slow!
From: Erland Sommarskog (esquel_at_sommarskog.se)
Date: 07/18/04
- Next message: David C: "Creating a New Field with a CHAR field and a FLOAT field."
- Previous message: Erland Sommarskog: "Re: how to execute a stored procedure from another stored procedure (nested)"
- In reply to: Mario Splivalo: "Stored Procedure is running slow!"
- Next in thread: Mario Splivalo: "Re: Stored Procedure is running slow!"
- Reply: Mario Splivalo: "Re: Stored Procedure is running slow!"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 18 Jul 2004 23:18:46 +0000 (UTC)
[posted and mailed, please reply in news]
Mario Splivalo (majk@fly.srk.fer.hr) writes:
> I have created a stored procedure that returns a single value, a
> calculation for stock items manipulation over some period of time. When
> I run stored procedure from QA, it takes some 15 seconds to execute.
> But, when I run it via ADO, using Microsoft Fox Pro, even when I set
> .CommandTimeout property to 240 seconds (4 minutes), I still get
> 'connection timeout' messages. I call dozens of stored procedures wich
> take around 5-10 seconds to execute when called from QA, and 90-180
> seconds when called from MS Fox Pro, via ADO.
>
> Has anyone experienced something like this, to give me some guidelines,
> I spent a night here, have no clue why is it happenig like so. Yes, I
> could se the .CommandTimeout property of an ADO connection object to
> something like 5000 seconds, but, I'd like to know why is it taking so
> much time to execute SP from fox.
Try this in Query Analyzer:
SET ARITHABORT OFF
go
EXEC tr_SNV
My prediction is that the query will run for just as long as it would
do from ADO, if the command timeout had not set in.
By default Query Analyzer runs with ARITHABORT ON, but OLE DB and ODBC
connections runs with this seting off by default. Therefore you get
different query plans, but if you change the set in QA, you will use
the bad query plan for the user-defined function.
On the other hand, if you pass SET ARITHABORT ON from ADO, this may
improve things.
Now, we only need to understand the reason for the difference... A shot
in the dark is that you have an index on a computed column or an indexed
view somewhere. For the optimizer to consider these indexes, ARITHABORT
must be ON.
Another way to turn on ARITHABORT, is to use the ALTER DATABASE statement,
so it is on by default for the datbase.
-- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
- Next message: David C: "Creating a New Field with a CHAR field and a FLOAT field."
- Previous message: Erland Sommarskog: "Re: how to execute a stored procedure from another stored procedure (nested)"
- In reply to: Mario Splivalo: "Stored Procedure is running slow!"
- Next in thread: Mario Splivalo: "Re: Stored Procedure is running slow!"
- Reply: Mario Splivalo: "Re: Stored Procedure is running slow!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|