473,786 Members | 2,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Server execution duration difference

Hello,

I have a stored procedure in SQL Server 2000.

When I execute it through my .NET application (OleDbCommand), I can
see (in SQL Profiler) that it takes 423 ms to complete.

If I run the same exact query in Query Analyzer, it takes 216 ms (in
SQL Profiler).

There's no other activity on that server.

Is there an explanation for that time difference?
Thanks,
Alex

Aug 2 '07 #1
7 1835
alexbf wrote:
Hello,

I have a stored procedure in SQL Server 2000.

When I execute it through my .NET application (OleDbCommand), I can
see (in SQL Profiler) that it takes 423 ms to complete.

If I run the same exact query in Query Analyzer, it takes 216 ms (in
SQL Profiler).

There's no other activity on that server.

Is there an explanation for that time difference?
Thanks,
Alex
The SQL server caches things like execution plans, query results and
function results, so execution times depends also on what the server has
been doing in the past.

To say anything more specific, I would have to know what the stored
procedure is doing.

--
Göran Andersson
_____
http://www.guffa.com
Aug 2 '07 #2
Hello Goran,

it's quite a simple stored procedure.

- One SELECT INTO that feeds a temp table
- Another select to return the results, fitered with a call to a user
defined function in the WHERE.

I don't think it's the stored proc itself because I execute the exact
same thing through my application or with Query Analyzer.

Thanks,
Alex

On Aug 2, 2:02 pm, Göran Andersson <gu...@guffa.co mwrote:
alexbf wrote:
Hello,
I have a stored procedure in SQL Server 2000.
When I execute it through my .NET application (OleDbCommand), I can
see (in SQL Profiler) that it takes 423 ms to complete.
If I run the same exact query in Query Analyzer, it takes 216 ms (in
SQL Profiler).
There's no other activity on that server.
Is there an explanation for that time difference?
Thanks,
Alex

The SQL server caches things like execution plans, query results and
function results, so execution times depends also on what the server has
been doing in the past.

To say anything more specific, I would have to know what the stored
procedure is doing.

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -

Aug 2 '07 #3

"alexbf" <al****@gmail.c omwrote in message
news:11******** **************@ d30g2000prg.goo glegroups.com.. .
Hello,

I have a stored procedure in SQL Server 2000.

When I execute it through my .NET application (OleDbCommand), I can
see (in SQL Profiler) that it takes 423 ms to complete.

If I run the same exact query in Query Analyzer, it takes 216 ms (in
SQL Profiler).

There's no other activity on that server.

Is there an explanation for that time difference?
In using the Stored Procedure with QA, I believe QA is talking directly to
SQL Server and is a faster means.

When using OleDb and running that SP, OleDb is not directly talking to SQL
Server and is a slower means.

<copied from link>

One of the reasons the SQL .NET Data Provider has gotten so much hype (which
is why all the samples use it), is how it has been optimized. The SQL
Managed Provider talks directly to SQL Server without using OLEDB (the
benefits of using products from the same company). Microsoft claims that the
speed of moving data between SQL Server and your ASP.NET application can
increase as much as 300% or more using the SQL Managed Provider because of
this direct communication.

<end>

http://dotnetjunkies.com/Tutorial/92...7C89364A1.dcik

When I was taking my .Net training back in 2004, it was explained that for
speed considerations to avoid OleDb if you were concerned about speed in
accessing SQL Server.

I am sure you can find more articles out on Google about this.

Aug 2 '07 #4
alexbf wrote:
Hello Goran,

it's quite a simple stored procedure.

- One SELECT INTO that feeds a temp table
- Another select to return the results, fitered with a call to a user
defined function in the WHERE.

I don't think it's the stored proc itself because I execute the exact
same thing through my application or with Query Analyzer.

Thanks,
Alex
So, what is it that makes it take more than a few milliseconds to run?
Is there a lot of data in the table that you have to go through? Does
the final result contain a lot of data? Is it the user defined function
that takes time?

Why is there a need for a temporary table at all? Can't you just filter
the data that are selected from the table? The table can have an index
on the field that you are filtering on, while the temporary table
doesn't. That can make filtering on the table much faster than filtering
on the temporary table.

--
Göran Andersson
_____
http://www.guffa.com
Aug 4 '07 #5
Hello Goran,

yes I could do my stored procedure differently to optimize it.. but I
really want to know why there's such a difference in time between
executing the stored procedure through .NET and through Query Analyzer

The data volume is about 100 rows and a few columns... so I doubt it's
an issue.

Alex

On Aug 4, 12:33 pm, Göran Andersson <gu...@guffa.co mwrote:
alexbf wrote:
Hello Goran,
it's quite a simple stored procedure.
- One SELECT INTO that feeds a temp table
- Another select to return the results, fitered with a call to a user
defined function in the WHERE.
I don't think it's the stored proc itself because I execute the exact
same thing through my application or with Query Analyzer.
Thanks,
Alex

So, what is it that makes it take more than a few milliseconds to run?
Is there a lot of data in the table that you have to go through? Does
the final result contain a lot of data? Is it the user defined function
that takes time?

Why is there a need for a temporary table at all? Can't you just filter
the data that are selected from the table? The table can have an index
on the field that you are filtering on, while the temporary table
doesn't. That can make filtering on the table much faster than filtering
on the temporary table.

--
Göran Andersson
_____http://www.guffa.com

Aug 8 '07 #6
alexbf wrote:
Hello Goran,

yes I could do my stored procedure differently to optimize it.. but I
really want to know why there's such a difference in time between
executing the stored procedure through .NET and through Query Analyzer

The data volume is about 100 rows and a few columns... so I doubt it's
an issue.

Alex
Have you verified that there is a consistent time difference? Do you
include opening and closing the connection when you check the time in
the code?

--
Göran Andersson
_____
http://www.guffa.com
Aug 8 '07 #7
I am trying to figure out what you two are talking about now that doesn't
make any sense about the speed of something running through SQL Server QA,
which is in direct contact with SQL Server, as opposed to something that's
running from a program that using OleDb

<from a post to me in another NG about the speed>
One of the reasons the SQL .NET Data Provider has gotten so much hype
(which
is why all the samples use it), is how it has been optimized. The SQL
Managed Provider talks directly to SQL Server without using OLEDB (the
benefits of using products from the same company). Microsoft claims that
the
speed of moving data between SQL Server and your ASP.NET application can
increase as much as 300% or more using the SQL Managed Provider because of
this direct communication.
I posted the results of a little test here back in June:

SQL Client (2.0): INSERT 20000 rows: 9,109375 seconds
SQL Client (2.0): 50 SELECT 20000 rows: 1,75 seconds
OLE DB (2000): INSERT 20000 rows: 20 seconds
OLE DB (2000): 50 SELECT 20000 rows: 62,140625 seconds
ODBC (2000): INSERT 20000 rows: 16,65625 seconds
ODBC (2000): 50 SELECT 20000 rows: 47,8125 seconds
OLE DB (2005): INSERT 20000 rows: 17,28125 seconds
OLE DB (2005): 50 SELECT 20000 rows: 61,484375 seconds
ODBC (2005): INSERT 20000 rows: 13,96875 seconds
ODBC (2005): 50 SELECT 20000 rows: 47,734375 seconds

<end>

Anything coming from OLE DB or ODBC is going to be slower because those
solutions are not in direct contact with SQL Server, as opposed to SQL
Client or something running within SQL Server QA with those solutions being
in direct contact with SQL Server.

Aug 8 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7798
by: Naresh Agarwal | last post by:
Hi What are the different kinds of JVMs exist and in what respect do they differ. What is the difference between client, server, classic and hotspot jvms? thanks, Naresh
19
14850
by: Thue Tuxen Sørensen | last post by:
Hi everybody ! I´m maintaining a large intranet (approx 10000 concurrent users) running on one IIS box and one DB box with sqlserver 2000. Currently there is 2,5 GB Ram, 1 1400 mhz cpu and 2 scsi disks installed on the db box. Sqlserver is set to use max 1,4 GB RAM, and the sqlserver does not seem to be using it all.
5
2051
by: Lorax | last post by:
I'm on the IS team of a medium-sized non-profit with international reach. We're trying to make some decisions regarding our Web server and database server as we expand our web site to have more dynamic content. Currently the database server houses all data pertinent to the organization (membership data, events, products, etc) in one database (~2.2 GB) as well as the web site content in a separate database (~40 MB). The web site pulls from...
3
5372
by: Will Atkinson | last post by:
Hi All, I'm a relative newbie to SQL Server, so please forgive me if this is a daft question... When I set "Show Execution Plan" on in Query Analyzer, and execute a (fairly complex) sproc, I note that a particular query is reported as having a query cost of "71% relative to the batch" - however, this is nowhere near the slowest executing query in the batch - other queries which take over twice as long are reported as having costs in...
15
7260
by: brettclare | last post by:
I have linked a large SQL Server table to Access, however 'only' 2,195,439 records are shown and are available to query. Can I increase the size (cache??)/number of records showing in Access? Thank you.
2
6968
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
1
1999
by: Biodigit | last post by:
The DTS works perfectly when I run it manually. However, when I run it as a job it fails. Before you ask if i'm running it under different security context. I have already made sure of that. I was logged into the server through remote viewer, when I created and ran the package, as well as scheduling the job. So the accounts they're running under are consistent. They're the same accounts as the SQL Agent is running under and it's the sys...
23
14042
by: Nishant Saini | last post by:
Dear All, We have a database which contains many tables which have millions of records. When We attach the database with MS SQL Server 2005 Standard Edition Server and run some queries (having joins, filters etc.) then they take very long time to execute while when We execute same queries on Enterprise Edition then they run 10 times faster than on standard edition. Our database does not use any features which are present in Enterprise
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.