Site sponsored by: Idera Try Idera’s new SQL admin toolset
SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Quiz
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


FAQ Topics

All FAQ's
General DBA
General Developer
DBA Performance Tuning
Developer Performance Tuning
Clustering
Error Messages

Write for Us

Share you SQL Server knowledge with others and raise your profile in the community More...
Latest Articles

Policy Based Management in SQL Server 2008
Inside SQL Server Cluster Setup and Troubleshooting Techniques - Part I ...
Configure and Manage Policy Based Management in SQL Server 2008 ...
Using Column Sets with Sparse Columns

More     
 
Latest FAQ's

Cannot Start SQL Server Service
Users are able to connect to report manager but not able ...
Errors when SQL Server Snapshot Replication is Running
How to Display Server Name or IP Address in a Reporting ...

More     
   
Latest Software Reviews

Spotlight on ApexSQL Doc 2008
ApexSQL Enforce
Embarcadero Change Manager
SQL Server DBA Dashboard

More     

Why does a query executed from VB run more slowly than when run from Query Analyzer?



Question

I have a VB-based application that uses SQL Server as its back-end. I have noticed that if I run the exact Transact-SQL queries (taken from the VB app) in Query Analyzer, that they run must faster than they do from within the VB application. Why is this?



Answer

There can be many reasons why the exact same query runs much faster from within Query Analyzer(or Management Studio) than it does from a VB application. Here are some reasons, although this is not a comprehensive list.

  • VB can introduce additional overhead to Transact-SQL that does not occur in Query Analyzer. And how you call the query in your VB program affects performance differently. For example, using a bound control to execute the query code can be slow. Also, calling the code directly within a recordset object, and not from a stored procedure , can also slow down the code.
  • Is the VB app using DAO to access SQL Server ? This is very slow. ADO or .NET is faster.
  • Are you using ODBC or OLEDB to connect? OLEDB offers better performance.
  • Is SET NOCOUNT ON being used in your application to reduce network traffic between the application and SQL Server? If not, this can reduce performance.
  • What is your setting for the CacheSize property of the ADO Recordset object? If you are using the default value of 1, performance can be very slow due to unnecessary network traffic generated.

This list could go on and on. The main point I want to make is that while SQL Server may perform its tasks quickly (you saw this when you ran the query in Query Analyzer), it is very easy to slow it down with unnecessary overhead from your VB application.

There is another lesson to be learned here also. If you are trying to performance tune a VB application that accesses SQL Server, one of the best ways to help identify if it is the VB app, or SQL Server, causing the problem, is to run each of the queries in your VB application from within Query Analyzer or Management Studio. If the queries run faster in Query Analyzer or Management Studio, then your VB application is the most likely cause of the performance problem. But if the query runs slow in Query Analyzer, then you can blame the query (perhaps it is written poorly), or the indexes (you may have poor or no useful indexes), or perhaps some other functionality of SQL Server is responsible. But until you perform this testing, you really don't know the cause of the performance problem.








Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | QDPMA Performance Tuning | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views


              © 1999-2008 by T10 Media. All rights reserved