Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
SQL Server Performance:  Tips and Techniques Siddhesh Bhobe 14 th  March 2002
Topics <ul><li>Motivation </li></ul><ul><li>Tips and Techniques </li></ul><ul><ul><li>Installation and Configuration </li>...
Motivation <ul><li>Simple tricks and tips can lead to a tremendous improvement in performance of your RDBMS engine </li></...
Installation and Configuration <ul><li>Don't install network libraries that are not   required </li></ul><ul><li>Don't ins...
Installation and Config (2) <ul><li>Remove anti-virus software </li></ul><ul><li>Consider setting ”min memory per query” <...
Database Schema Design <ul><li>Do not use the same database for OLAP & OLTP </li></ul><ul><li>Don't use FLOAT or REAL for ...
DDL and DML Statements <ul><li>Avoid using DISTINCT clause if possible </li></ul><ul><li>Use EXISTS instead of IN </li></u...
DDL and DML Statements (2) <ul><li>Do not use Count(*) if you are ok with approximates </li></ul><ul><ul><li>SELECT rows <...
DDL and DML Statements (3) <ul><li>Consider OUTPUT parameters instead of   SELECT statement for single row result sets </l...
DDL and DML Statements (4) <ul><li>Avoiding bottlenecks with temporary tables </li></ul><ul><ul><li>SELECTing data into a ...
Indexing <ul><li>Avoid using SQL functions in the Search Criteria </li></ul><ul><ul><li>This can prevent indexes from bein...
Indexing (2) <ul><li>Consider creating covering indexes for repeated   queries if you have to use non-clustered indexes </...
Miscellaneous <ul><li>Use OLE DB to access SQL Server over other mechanisms like ODBC </li></ul><ul><li>Use DSN-less conne...
References <ul><li>Links </li></ul><ul><ul><li>http://www. sql -server-performance.com </li></ul></ul><ul><ul><li>http://w...
Upcoming SlideShare
Loading in …5
×

Sql Server Performance Siddhesh

614 views

Published on

Enabling high performance in your SQL Server

Published in: Technology
  • Be the first to comment

Sql Server Performance Siddhesh

  1. 1. SQL Server Performance: Tips and Techniques Siddhesh Bhobe 14 th March 2002
  2. 2. Topics <ul><li>Motivation </li></ul><ul><li>Tips and Techniques </li></ul><ul><ul><li>Installation and Configuration </li></ul></ul><ul><ul><li>Database Schema Design </li></ul></ul><ul><ul><li>DDL and DML Statements </li></ul></ul><ul><ul><li>Indexing </li></ul></ul><ul><ul><li>Miscellaneous </li></ul></ul><ul><li>References </li></ul>
  3. 3. Motivation <ul><li>Simple tricks and tips can lead to a tremendous improvement in performance of your RDBMS engine </li></ul><ul><li>You do not have to be an “expert”! </li></ul><ul><li>Although we will talk about SQL Server, most of these techniques can be applied to all databases </li></ul><ul><li>The purpose of this talk is to sensitize you towards this topic… this is not a tutorial in “How to improve the performance of your database engine” </li></ul>
  4. 4. Installation and Configuration <ul><li>Don't install network libraries that are not  required </li></ul><ul><li>Don't install services you do not need </li></ul><ul><li>Turn off the MS DTC if your applications  do not  need it </li></ul><ul><li>Do not run Screensavers or Terminal  Services  on SQL Server machines </li></ul>
  5. 5. Installation and Config (2) <ul><li>Remove anti-virus software </li></ul><ul><li>Consider setting ”min memory per query” </li></ul><ul><li>Set min and max server memory options </li></ul><ul><li>Choose appropriate sort order  </li></ul><ul><li>Consider changing default network packet size </li></ul>
  6. 6. Database Schema Design <ul><li>Do not use the same database for OLAP & OLTP </li></ul><ul><li>Don't use FLOAT or REAL for Primary Keys </li></ul><ul><li>Use UNICODE only if you require internationalization </li></ul><ul><li>Use CHAR datatype only when column is  non-nullable. Else use VARCHAR </li></ul><ul><li>Consider denormalization if you require more than 4-5 joins in the queries </li></ul>
  7. 7. DDL and DML Statements <ul><li>Avoid using DISTINCT clause if possible </li></ul><ul><li>Use EXISTS instead of IN </li></ul><ul><li>Use derived instead of temporary tables </li></ul><ul><ul><li>A derived table is the result of using a SELECT statement in the FROM clause of an existing SELECT statement. </li></ul></ul><ul><li>Do not use Select *. Use column list </li></ul><ul><li>Use TRUNCATE table instead of DELETE all </li></ul>
  8. 8. DDL and DML Statements (2) <ul><li>Do not use Count(*) if you are ok with approximates </li></ul><ul><ul><li>SELECT rows </li></ul></ul><ul><ul><li>FROM sysindexes </li></ul></ul><ul><ul><li>WHERE id = OBJECT_ID('<table_name>') AND indid < 2 </li></ul></ul><ul><li>Using SELECT DISTINCT after sampling to speed up operation </li></ul><ul><li>Use &quot;SET NOCOUNT ON&quot; in stored procedures </li></ul>
  9. 9. DDL and DML Statements (3) <ul><li>Consider OUTPUT parameters instead of  SELECT statement for single row result sets </li></ul><ul><li>Give constraints precedence over triggers </li></ul><ul><li>Use triggers for maintaining aggregate summary  data </li></ul><ul><li>Avoid using CURSORs. Use the new  TABLE  datatype available in SQL Server  2000 </li></ul><ul><li>Force small tables into buffer using the  SP_TABLEOPTION PINTABLE option </li></ul>
  10. 10. DDL and DML Statements (4) <ul><li>Avoiding bottlenecks with temporary tables </li></ul><ul><ul><li>SELECTing data into a temp tables can block the tempdb for the duration of the SELECT, creating a bottleneck. Ensure that the &quot;create temporary table&quot; part of the operation is committed as quickly as possible. </li></ul></ul>
  11. 11. Indexing <ul><li>Avoid using SQL functions in the Search Criteria </li></ul><ul><ul><li>This can prevent indexes from being used </li></ul></ul><ul><li>Every table in the database should have atleast a  clustered index defined on it </li></ul><ul><li>Add/Delete Indexes in OLTP applications, if  required </li></ul><ul><li>Use CHECKSUM instead of indexes on very wide columns </li></ul><ul><li>Use most selective columns to the left of the index key </li></ul>
  12. 12. Indexing (2) <ul><li>Consider creating covering indexes for repeated  queries if you have to use non-clustered indexes </li></ul><ul><li>Consider creating covering indexes for frequent  queries with aggregates </li></ul><ul><li>Schedule periodic reorganization on all indexes on all tables in the database </li></ul><ul><li>Create only UNIQUE clustered indexes </li></ul><ul><li>Drop indexes and regenerate if you are importing data in batches </li></ul>
  13. 13. Miscellaneous <ul><li>Use OLE DB to access SQL Server over other mechanisms like ODBC </li></ul><ul><li>Use DSN-less connections in OLE DB </li></ul>
  14. 14. References <ul><li>Links </li></ul><ul><ul><li>http://www. sql -server-performance.com </li></ul></ul><ul><ul><li>http://www. dbazine .com/ ch _ sql .html </li></ul></ul><ul><ul><li>http://www. sqlmag .com </li></ul></ul><ul><li>Tools </li></ul><ul><ul><li>http://www.quest.com/spotlight_ sql </li></ul></ul>

×