tutorial - tuning mysql server to boost performance




What resources exist for Database performance-tuning? (18)

What good resources exist for understanding database tuning on the major engines and advancing your knowledge in that area?

The idea of this question is to collect the shed load of resources that invariably exist, so that people can have a "one stop" knowledge shop of the good, peer approved resources.


General SQL

PostgreSQL (wiki) (PGsearch)

MySQL

Oracle

MS SQL Server

Sybase SQL Anywhere

JDBC




Quick PostgreSQL Optimization (query optimizing)

Short read, explains a lot of things well and 'works' a real example which is nice for those of us that learn better that way.

After seeing the wiki link to PostgreSQL, figured I'd edit this post with links for mysql/oracle docs, not really an optimization guides specifically but both are good resources, especially the mysql one. For optimization and any other tuning features.





For Microsoft SQL, I'd recommend the books by Kalen Delaney (et al) called "Inside SQL Server". They offer a good insight into the internals of SQL Server, thus allowing readers to educate themselves on why particular statements might be faster than others.

Inside SQL Server 7.0
Inside SQL Server 2000
Inside Microsoft SQL Server 2005
Microsoft SQL Server 2008 Internals

There's also a book dedicated to performance tuning of SQL Server 2008 queries: SQL Server Performance Tuning Distilled

I also like the blogs by Paul Randal and Kimberly Tripp on SQLSkills.com. They are full of solid SQL advice:

Paul's blog
Kimberly's blog



For SQL Server performance tuning, Itzik Ben-Gan is a legend.

You can find his many detailed books here, all with his usual style of empirical measurement to prove his case: http://tsql.solidq.com/books/index.htm

If you're searching for the fastest solution to a t-sql problem add the word 'itzik' to your google search term.

Itzik Ben-Gan has been mentioned over 600 times here on , but I couldn't believe it to find not a single mention of him here on this performance tuning question.

As an additional resource, you can also find some videos of Itzik talking about performance related stuff here on youtube.



Here is another highly-regarded book that is platform-neutral:

Dan Tow's SQL Tuning: Generating Optimal Execution Plans

Contains some specific examples for Oracle, MS SQL, and IBM DB2, but the techniques involved should apply to other platforms, too.


I was pretty happy when I saw this way of quickly seeing what happened with a SQL statement you are tuning under Oracle. Change the first SQL statement below to your SELECT statement and keep that hint in there.

SELECT /*+ GATHER_PLAN_STATISTICS */ * FROM DUAL;

SELECT * FROM TABLE(dbms_xplan.display_cursor( NULL, NULL, 'RUNSTATS_LAST'))
;

PLAN_TABLE_OUTPUT
-----------------------------------------------------
SQL_ID  5z36y0tq909a8, child number 0
-------------------------------------
SELECT /*+ GATHER_PLAN_STATISTICS */ * FROM DUAL

Plan hash value: 272002086

---------------------------------------------------------------------------------------------
| Id  | Operation         | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
---------------------------------------------------------------------------------------------
|   1 |  TABLE ACCESS FULL| DUAL |      1 |      1 |      1 |00:00:00.02 |       3 |      2 |
---------------------------------------------------------------------------------------------


12 rows selected.

Where:

  • E-Rows is estimated rows.
  • A-Rows is actual rows.
  • A-Time is actual time.
  • Buffers is actual buffers.

Where the estimated plan varies from the actual execution by orders of magnitude, you know you have problems.


I'd start out by understanding how the database works at a fundamental level. How is data stored on disk, what does creating an index do, how does query plan optimization work, how are plans cached, when to cached plans expire.

If you can commit all that to memory, most of the advice about tuning seems obvious.

Here's a great book for MSSQL

SQL Server Internals


If you are looking for SQL Server specific Performance tuning references there are an absolute shed load of quality resources available online, ranging from white papers on implementing specific technologies such as partitioning, to excellent Blogs that detail step by step instruction on how to performance tune a sql server platform.

Shameless plug follows: You can start you research by reviewing the performance tuning area of my personal Blog, or for any specific SQL Server requirements/issues feel free to fire me an email.

SQL Server Resources


Oracle sites

  1. 2 day performance tuning guide http://docs.oracle.com/cd/E11882_01/server.112/e10822/toc.htm
  2. Performance Tuning Guide http://docs.oracle.com/cd/E36909_01/server.1111/e16638/toc.htm

Oracle books

  1. Oracle Core: Essential Internals for DBAs and Developers by Jonathan Lewis
  2. Expert Oracle Database Architecture: Oracle Database 9i, 10g, and 11g Programming Techniques and Solutions by Thomas Kyte
  3. SQL Tuning by Dan Tow
  4. Oracle Database 11g Release 2 Performance Tuning Tips & Techniques (Oracle Press) by Richard Niemiec

Oracle's very own Tom Kyte has a fantastic repository on every type of performance problem imaginable on http://asktom.oracle.com. He usually takes the time to recreate specific problems and gives very detailed explanations.









postgresql