SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Training
  • 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

USEFUL SITES :

ASP.NET Tutorials
Windows and SQL Azure Tutorials
Cloud Hosting Magazine
SharePoint Tutorials
Windows Server Help

Write for Us

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

A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server - Part ...
A High Level Comparison Between Oracle and SQL Server

More     
 
Latest FAQ's

Add Node to A SQL Server failover Cluster failed with invalid ...
SQL Server Destination remote server error
Setting Up Data And Log Files For SQL Server
Will Check Constraints Improve Database Performance?

More     
   
Latest Software Reviews

dbForge Review
Spotlight on ApexSQL Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Data Diff - Server-based database comparison tool ...
Spotlight on ApexSQL Doc 2008

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.








C# Help and Tutorials | PHP MySQL Tutorial | Sharepoint Tutorial | Azure Tutorial | Cloud Hosting Magazine | ASP.NET Tutorials | Windows Server Help | Windows Phone Pro | Silverlight Ace | Visual Studio Tutorials | Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | SQL Server Training Videos | 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 | 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


              © 2010 Jude O'Kelly. All rights reserved