StrataFrame Forum
Back
Login
Login
Home
»
StrataFrame Application Framework - V1
»
Business Objects and Data Access (How do I?)
»
Speed of Stored Procedure
Speed of Stored Procedure
Post Reply
Like
0
Speed of Stored Procedure
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
RSS Feed
Goto Topics Forum
Author
Message
Bill Cunnien
Bill Cunnien
posted 17 Years Ago
ANSWER
HOT
Topic Details
Share Topic
Group: Forum Members
Posts: 785,
Visits: 3.6K
I am not getting it. Earlier this spring I discussed in these forums the utilization of UDFs in filling a BO. The conclusion was to not use them since they have a great deal of overhead involved. So, instead, I went with some raw SQL to achieve the same results. I was able to get one of my more complex queries down to about 3 seconds. That was wonderful. Now, I am simply taking the same script that runs in the SQL Query Analyzer at 3 seconds and placing it into a stored procedure with three parameters. These parameters are declared at the beginning of the script in the query analyzer, too. I run the stored procedure and it takes many minutes to run (last run: 10 min 04 sec). I really don't get this. It is the exact same script. Is there really that much of a difference in quality between raw SQL script and the same SQL script placed into a stored procedure? What am I doing wrong? I have attached the script that I am running in the Query Analyzer and the stored procedure. I know that these are not pretty...I am still working through the details of this query. Any help, tips, criticism is welcome!
Thanks,
Bill
Attachments
Running Inventory - Material.zip
(
128 views,
900 bytes
)
Running Inventory - Material (SP).txt
(
184 views,
2.00 KB
)
Reply
Like
0
Reply
Trent Taylor
Trent Taylor
posted 17 Years Ago
ANSWER
Post Details
Share Post
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
All of Peter's comments were excellent...I thought I would toss in a few more things as well:
You can tell a query which index to use by using the WITH and INDEX commands. Sometimes SQL needs a little help...we ran into this the other day. It would look like this:
SELECT * FROM Customers WITH(INDEX(IX_MyIndex))
The framework is not going to change anything in regards to the execution speed and performance....so if you get it down to 1 second in SQL Server management Studio executing the sproc...this will not change on the framework side unless you have some type of connection issue or something else in the mix.
DateTime columns are aweful about slowing down queries when in the WHERE...one way to get around this is to store dates as a BigInt data type and then store then DateTimes using Ticks. We then create a Custom property on the BO that wraps this as a DateTime so that while using the BOs inside of your app you interact with a DateTime...but it is stored as Ticks on the SQL Server side...and this will drastically improve performance....by like a ton when you are testing with <, >, or betweens.
Reply
Like
0
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Threaded View
Threaded View
Speed of Stored Procedure
Bill Cunnien
-
17 Years Ago
Bill,
I'm not quite sure what you are doing to get the time...
Greg McGuffey
-
17 Years Ago
The raw script executes in 3 sec. The stored procedure, using the...
Bill Cunnien
-
17 Years Ago
Interesting note: the execution plan for the raw sql script is way...
Bill Cunnien
-
17 Years Ago
I took the parameters out of the stored procedure and hardcoded them...
Bill Cunnien
-
17 Years Ago
If I remove the first parameter (varchar(30)), then the stored...
Bill Cunnien
-
17 Years Ago
OK, that is different. I understand why you are baffled.:blink:
...
Greg McGuffey
-
17 Years Ago
[quote]I'd see what replacing the LIKE in your where clause with an...
Bill Cunnien
-
17 Years Ago
The stored procedure does not like the LIKE. Who woulda thunk...
Bill Cunnien
-
17 Years Ago
I'm not quite sure why LIKE isn't...er...liked by SQL Server, but I do...
Greg McGuffey
-
17 Years Ago
Hi Bill, A few random comments that may help: 1) Be careful with...
Peter Jones
-
17 Years Ago
All of Peter's comments were excellent...I thought I would toss in a...
Trent L. Taylor
-
17 Years Ago
Hi Guys, While I've never tried converting a date to a bigint I...
Peter Jones
-
17 Years Ago
Thanks for the info...it always good to hear how other developers...
Trent L. Taylor
-
17 Years Ago
Hi Trent, Thanks for the extra info. Hopefully we never have to get...
Peter Jones
-
17 Years Ago
Post Reply
Like
0
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search