Home > Ask the SQL Server Experts > Archive: Performance Tuning Questions & Answers > Improve query performance without adding CompanyID to OrderStatusHistory table
Ask The SQL Server Expert: Questions & Answers
EMAIL THIS

Improve query performance without adding CompanyID to OrderStatusHistory table

Jeremy Kadlec EXPERT RESPONSE FROM: Jeremy Kadlec

Pose a Question
Other SQL Server Categories
Meet all SQL Server Experts
Become an Expert for this site


Expert advice on database administration
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 30 June 2005
I have inherited an application that uses SQL Server. The application essentially tracks orders for hundreds of companies.

Initially, performance on the Orders table was poor. To improve it, I added CompanyID to the Orders table, since that would be the limiting factor for all users. Now the problem revolves around an OrderStatusHistory table.

Required functionality of the application includes selecting all records from OrderStatusHistory for a particular company (although it is also limited by an Active flag). The current stored procedure for retrieving this data contains SQL similar to "SELECT OrderStatusHistory.SomeFields, Orders.OtherFields FROM OrderStatusHistory WITH (NOLOCK) INNER JOIN Orders WITH (NOLOCK) ON Orders.OrderID = OrderStatusHistory.OrderID WHERE Orders.CompanyID = @CompanyID" AND Active = 1.

How can I improve performance of this query (currently 16 seconds against 2 million records) without adding CompanyID to the OrderStatusHistory table?


>
I would research the performance improvement by changing your clustered and non clustered indexes. I would also determine if you can archive older data to limit the sheer amount of data that is queried.


Do you have comments on this Ask the Expert Q&A? Let us know.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
Microsoft SQL Server Performance Monitoring and Tuning
Top 5 DBA tasks that are a waste of time (and might be hurting your SQL Server)
SQL Server Mailbag: Asymmetric encryption, log shipping issues
Using traces in SQL Server Profiler
SQL Server Mailbag: CALs, witnesses and unwanted changes
SQL Server Mailbag: Data restoration and DB property management
Working with IntelliSense in SQL Server 2008 Management Studio
SQL Server Mailbag: Stored procedures, triggers and SSRS reports
Troubleshooting Distributed Transaction Coordinator errors in SQL Server
Clearing the Windows page file and its effect on server performance
Optimizing SQL Server indexes –- even when they're not your indexes

Archive: Performance Tuning
Upgrading to SQL Server 2008 advantages and hardware requirements
Tool to synchronize two SQL Server databases
Performance tuning for SQL Server 2005 and Exchange running on SBS
SQL Server tools don't appear in menu after SQL Server 2005 install
Use SQL Profiler to find long running stored procedures and commands
Maintain large SQL Server database and resolve website 'Timeout Error'
How to retrieve SQL Server database disk space in use
Troubleshoot SQL Server 2005 temporary table performance problems
View query execution plan in SQL Server with this method
Adding non-clustered indexes to SQL Server columns

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
contiguity  (SearchSQLServer.com)
contiguous  (SearchSQLServer.com)
drilldown  (SearchSQLServer.com)
hashing  (SearchSQLServer.com)
hybrid online analytical processing  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



SQL Solutions - SQL Database Design
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts