SlideShare a Scribd company logo
15 Pro-tips for MySQL Users PFCongress - 17 september 2011 Utrecht - Netherlands
Joshua Thijssen Senior Software Engineer @ Enrise Development in PHP, Python, Perl, C, Java.... Email:  [email_address] Twitter: @jaytaph Blogs: http://www.adayinthelifeof.nl http://www.enrise.com/blog
15 MySQL Pro-tips No “theoretical tips”, all taken from the field. Starting simple - ending “complex”  What are we going to  discuss? QUESTIONS? RAISE YOUR HAND OR YELL LOUD
0) Use the correct MySQL version Tip  0 MySQL 5.0 != 5.5
RHEL 5-7: 5.0.77 RHEL 6-1: 5.1.52  Debian (lenny) 5.0.51a Debian (squeeze): 5.1.49 Debian (sid): 5.1.58 Tip 0:   Use the correct MySQL version http://distrowatch.com/table.php?distribution=redhat http://distrowatch.com/table.php?distribution=debian
1) Know how to use explain (and profiler) Tip  1 EXPLAIN IS YOUR BESTEST FRIEND
I will not show you how to use EXPLAIN. Use EXPLAIN and EXPLAIN EXTENDED/  SHOW WARNINGS; Tip 1:   Know your EXPLAIN  (1)
Tip 1:   Know your EXPLAIN  (2) mysql> desc varchartest;+----------+--------------+------+-----+---------+-------+| Field  | Type  | Null | Key | Default | Extra |+----------+--------------+------+-----+---------+-------+| id  | int(11)  | NO  | PRI | 0  |  || name  | varchar(255) | NO  | MUL | NULL  |  || utf8name | varchar(255) | NO  | MUL | NULL  |  |+----------+--------------+------+-----+---------+-------+3 rows in set (0.01 sec)
Tip 1:   Know your EXPLAIN  (3) mysql> EXPLAIN EXTENDED  ->  SELECT * FROM varchartest WHERE name LIKE 'joshua';+----+-------------+-------------+-------+---------------+----------+---------+------+------+----------+-------------+| id | select_type | table  | type  | possible_keys | key  | key_len | ref  | rows | filtered | Extra  |+----+-------------+-------------+-------+---------------+----------+---------+------+------+----------+-------------+|  1 | SIMPLE  | varchartest | range | idx_name  | idx_name | 257  | NULL |  1 |  100.00 | Using where |+----+-------------+-------------+-------+---------------+----------+---------+------+------+----------+-------------+1 row in set, 1 warning (0.01 sec)
Tip 1:   Know your EXPLAIN  (4) mysql> SHOW WARNINGS\g+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Level | Code | Message  |+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Note  | 1003 | select `pfz`.`varchartest`.`id` AS `id`,`pfz`.`varchartest`.`name` AS `name`,`pfz`.`varchartest`.`utf8name` AS `utf8name` from `pfz`.`varchartest` where (`pfz`.`varchartest`.`name` like 'joshua') |+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Tip 1:   Know your PROFILER  (1) mysql> SET profiling=1;mysql> SELECT * FROM table; mysql> SHOW PROFILE CPU, BLOCK IO; +--------------------------------+----------+----------+------------+--------------+---------------+| Status  | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |+--------------------------------+----------+----------+------------+--------------+---------------+| starting  | 0.000930 | 0.000000 |  0.000000 |  0 |  8 || checking query cache for query | 0.000547 | 0.000000 |  0.000000 |  0 |  0 || checking permissions  | 0.000045 | 0.000000 |  0.000000 |  0 |  0 || Opening tables  | 0.000142 | 0.000000 |  0.000000 |  0 |  0 || System lock  | 0.000030 | 0.000000 |  0.000000 |  0 |  0 || Table lock  | 0.000045 | 0.000000 |  0.000000 |  0 |  0 || init  | 0.000207 | 0.000000 |  0.000000 |  0 |  0 || optimizing  | 0.000007 | 0.000000 |  0.000000 |  0 |  0 || statistics  | 0.000068 | 0.000000 |  0.000000 |  0 |  0 || preparing  | 0.001393 | 0.004000 |  0.000000 |  0 |  0 || Creating tmp table  | 0.001658 | 0.000000 |  0.000000 |  0 |  8 || executing  | 0.000005 | 0.000000 |  0.000000 |  0 |  0 || Copying to tmp table  | 0.000834 | 0.000000 |  0.004001 |  0 |  8 || Sorting result  | 0.000179 | 0.000000 |  0.000000 |  0 |  0 || Sending data  | 0.000089 | 0.000000 |  0.000000 |  0 |  0 || end  | 0.000022 | 0.000000 |  0.000000 |  0 |  0 || removing tmp table  | 0.000089 | 0.000000 |  0.000000 |  0 |  0 || end  | 0.000005 | 0.000000 |  0.000000 |  0 |  0 || query end  | 0.000004 | 0.000000 |  0.000000 |  0 |  0 || freeing items  | 0.000844 | 0.000000 |  0.000000 |  0 |  0 || logging slow query  | 0.000023 | 0.000000 |  0.000000 |  0 |  0 || logging slow query  | 0.000060 | 0.000000 |  0.000000 |  0 |  8 || cleaning up  | 0.000007 | 0.000000 |  0.000000 |  0 |  0 |+--------------------------------+----------+----------+------------+--------------+---------------+
2) Know the most basic my.cnf settings Tip  2 THERE ARE ONLY A FEW “BASIC” ONES.
Tip 2: My.cnf settings  (1) Know the most important ones: key_buffer_size, innodb_buffer_pool_size,  sort_buffer_size, max_connections
Some settings work on global level, some per connection! Know some quirks:  (max_heap_table_size vs tmp_table_size, binlog-do-db, replicate-ignore-db etc) Tip 2:   My.cnf settings  (2)
http://www.omh.cc/mycnf/ http://rackerhacker.com/mysqltuner/ http://www.day32.com/MySQL/ phpmyadmin Tip 2:   My.cnf settings  (3)
3) Backup on table level Tip  3 RESTORING JUST ONE TABLE CAN BE PAINFUL OTHERWISE
mysqldump can dump per database OR by table. Simple scripts to scan/dump tables. Easy restore for single table (or part of table) Tip 3:   Backup on table level  (1) COULD YOU RESTORE TABLE x? YES! YES I CAN!
4) Don’t use “SELECT *” when you only need one or two fields. Tip  4 DON’T ASK WHAT YOU DON’T NEED
Much more data to be read from disk Much more data will be send over, thus slower (blobs/texts) Cannot use covering indices Tip 4:   Select *  (1) DON’T ASK WHAT YOU DON’T NEED
Tip 4:   Select *  (2) mysql> SHOW FULL COLUMNS FROM `covering`;+--------------+------------------+------------------+------+-----+---------+----------------+ | Field  | Type  | Collation  | Null | Key | Default | Extra  | +--------------+------------------+------------------+------+-----+---------+----------------+| id  | int(10) unsigned | NULL  | NO  | PRI | NULL  | auto_increment || email  | varchar(255)  | ascii_general_ci | NO  | MUL | NULL  |  |  | want_mailing | tinyint(1)  | NULL  | NO  | MUL | NULL  |  | | extra_info  | varchar(255)  | ascii_general_ci | NO  | MUL | NULL  |  |+--------------+------------------+------------------+------+-----+---------+----------------+3 rows in set (0.00 sec)mysql> SHOW INDEXES FROM `covering`;+----------+------------+------------+--------------+--------------+-----------+-------------+| Table  | Non_unique | Key_name  | Seq_in_index | Column_name  | Collation | Cardinality | +----------+------------+------------+--------------+--------------+-----------+-------------+| covering |  0 | PRIMARY  |  1 | id  | A  |  3 || covering |  1 | idx_email  |  1 | email  | A  |  3 || covering |  1 | idx_email  |  2 | want_mailing | A  |  3 || covering |  1 | idx_email2 |  1 | want_mailing | A  |  1 || covering |  1 | idx_email2 |  2 | email  | A  |  3 |+----------+------------+------------+--------------+--------------+-----------+-------------+5 rows in set (0.01 sec)
Tip 4:   Select *  (2) mysql> EXPLAIN SELECT want_mailing FROM `covering` WHERE email LIKE ' [email_address] ';+----+-------------+----------+-------+---------------+-----------+---------+------+------+--------------------------+| id | select_type | table  | type  | possible_keys | key  | key_len | ref  | rows | Extra  |+----+-------------+----------+-------+---------------+-----------+---------+------+------+--------------------------+|  1 | SIMPLE  | covering | range | idx_email  | idx_email | 257  | NULL |  1 | Using where; Using index |+----+-------------+----------+-------+---------------+-----------+---------+------+------+--------------------------+1 row in set (0.00 sec)
5) Use triggers and stored procedures Tip  5 ENFORCE CONSISTENCY
6 triggers per table (insert, update, delete, before and after the mutation) 3rd party tools (phpmyadmin etc) can also use the database without loosing data consistency. Watch out with (phpmyadmin) table dumps! Tip 5: Triggers and stored procedures  (1) ENFORCE CONSISTENCY
6) Don’t use FULLTEXT searches Tip  6 THERE ARE MUCH BETTER SOLUTIONS
They only work for MyISAM tables. Not compatible with other DB’s. Slow (especially compared to Solr, Sphinx). No extra features (faceted search, spell checking etc). Tip 6:   Don’t use FULLTEXT search  (1) THERE ARE MUCH BETTER SOLUTIONS
7) Some wildcard searches (%item%) are bad for performance Tip  7 IT LOOKS LIKE YOU NEED MORE ADVANCED SEARCH?
MySQL cannot use indexing! Revert your data:  search for ‘moc.esirne@%’ instead of ‘%@enrise.com’. Use a better solution (solr, sphinx). You probably want it (no, really) Tip 7:   Wildcard searches  (1) THERE ARE MUCH BETTER SOLUTIONS
8) Shard your volatile and non-volatile data. Tip  8 MAKE CACHING AND LOCKING HAPPY AGAIN
Tip 8:   Sharding  (1) mysql> SHOW FULL COLUMNS FROM `pages`;+------------+------------------+-------------------+------+-----+-------------------+-------+| Field  | Type  | Collation  | Null | Key | Default  | Extra |+------------+------------------+-------------------+------+-----+-------------------+-------+| page_id  | int(10) unsigned | NULL  | NO  | PRI | NULL  |  || created_dt | timestamp  | NULL  | NO  |  | CURRENT_TIMESTAMP |  || creator_id | int(11)  | NULL  | NO  |  | NULL  |  || title  | varchar(100)  | latin1_swedish_ci | NO  |  | NULL  |  || contents  | text  | latin1_swedish_ci | NO  |  | NULL  |  || hit_count  | int(11)  | NULL  | NO  |  | 0  |  |+------------+------------------+-------------------+------+-----+-------------------+-------+6 rows in set (0.01 sec)
Remember: an update on a table will invalidate ALL caches referring to that table. UPDATE pages SET hit_count = hit_count + 1; Thus: page table will NEVER be cached. Tip 8:   Sharding  (2)
Define hot data (volatile, changes often) and cold data (static, changes never or infrequently) move to different tables UPDATE page_stats SET hit_count = hit_count + 1; Query cache is happy again Tip 8:   Sharding  (3)
MySQL 5.1 and higher has got partitioning (but you should shard anyway). Tip 8:   Sharding  (4)
9) Don’t use a large primary key for InnoDB tables. Tip  9 PK’S ARE ON EVERY INDEX
InnoDB adds the primary key to EACH index. No primary key given? It uses an internal 6(!)-byte key. Tip 9: Large primary keys  (1)
10) Don’t “SELECT COUNT(*) FROM TABLE” on InnoDB. Tip  10 COUNT(*) => MYISAM = FAST COUNT(*) => INNODB = SLOW
InnoDB implements MVCC (multi-version concurrency control). COUNT(*) must be counted and is not fetched from metadata. Tip 10:   SELECT COUNT(*)  (1)
What do you want to COUNT(*)? Just for displaying purposes (there are X amount of pages): do you need the EXACT amount? (guess &| cache) Tip 10:   SELECT COUNT(*)  (2)
11) Don’t rely on the VARCHAR() Tip  11 IT ISN’T THAT VARIABLE AS YOU MIGHT THINK
Tip 11:   VARCHAR()  (1) IT DOESN’T SOLVE YOUR PROBLEMS
DON’T WORRY ABOUT THE UTF-8, I’LL BASH THAT LATER Tip 11:   VARCHAR()  (3) mysql> SHOW FULL COLUMNS FROM `varchartest`;+----------+--------------+-------------------+------+-----+---------+-------+| Field  | Type  | Collation  | Null | Key | Default | Extra |+----------+--------------+-------------------+------+-----+---------+-------+| id  | int(11)  | NULL  | NO  | PRI | 0  |  || name  | varchar(255) | latin1_swedish_ci | NO  | MUL | NULL  |  || utf8name | varchar(255) | utf8_general_ci  | NO  | MUL | NULL  |  |+----------+--------------+-------------------+------+-----+---------+-------+3 rows in set (0.01 sec)mysql> SHOW INDEXES FROM `varchartest`;+-------------+------------+--------------+--------------+-------------+-----------+-------------+| Table  | Non_unique | Key_name  | Seq_in_index | Column_name | Collation | Cardinality |+-------------+------------+--------------+--------------+-------------+-----------+-------------+| varchartest |  0 | PRIMARY  |  1 | id  | A  |  3 || varchartest |  1 | idx_name  |  1 | name  | A  |  3 || varchartest |  1 | idx_utf8name |  1 | utf8name  | A  |  3 |+-------------+------------+--------------+--------------+-------------+-----------+-------------+3 rows in set (0.00 sec)
DON’T WORRY ABOUT THE UTF-8, I’LL BASH THAT LATER Tip 11:   VARCHAR()  (3) mysql> EXPLAIN SELECT * FROM `varchartest` WHERE name LIKE 'jthijssen';+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+| id | select_type | table  | type  | possible_keys | key  | key_len | ref  | rows | Extra  |+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+|  1 | SIMPLE  | varchartest | range | idx_name  | idx_name | 257  | NULL |  1 | Using where |+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+1 row in set (0.00 sec)
12) UTF-8 is not the enemy, but it certainly isn’t your friend. Tip  12 DON’T EXCHANGE ONE PROBLEM FOR ANOTHER
Dr Jeckyl and Mr Hyde Solves all your multi-language problems! But gives back performance issues. Tip 12:   UTF-8  (1)
Tip 12:   UTF-8  (1) mysql> SHOW FULL COLUMNS FROM `varchartest`;+----------+--------------+-------------------+------+-----+---------+-------+| Field  | Type  | Collation  | Null | Key | Default | Extra |+----------+--------------+-------------------+------+-----+---------+-------+| id  | int(11)  | NULL  | NO  | PRI | 0  |  || name  | varchar(255) | latin1_swedish_ci | NO  | MUL | NULL  |  || utf8name | varchar(255) | utf8_general_ci  | NO  | MUL | NULL  |  |+----------+--------------+-------------------+------+-----+---------+-------+3 rows in set (0.01 sec)mysql> SHOW INDEXES FROM `varchartest`;+-------------+------------+--------------+--------------+-------------+-----------+-------------+| Table  | Non_unique | Key_name  | Seq_in_index | Column_name | Collation | Cardinality |+-------------+------------+--------------+--------------+-------------+-----------+-------------+| varchartest |  0 | PRIMARY  |  1 | id  | A  |  3 || varchartest |  1 | idx_name  |  1 | name  | A  |  3 || varchartest |  1 | idx_utf8name |  1 | utf8name  | A  |  3 |+-------------+------------+--------------+--------------+-------------+-----------+-------------+3 rows in set (0.00 sec)
Tip 12:   UTF-8  (1) mysql> EXPLAIN SELECT * FROM `varchartest` WHERE name LIKE 'jthijssen';+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+| id | select_type | table  | type  | possible_keys | key  | key_len | ref  | rows | Extra  |+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+|  1 | SIMPLE  | varchartest | range | idx_name  | idx_name | 257  | NULL |  1 | Using where |+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+1 row in set (0.00 sec) mysql> EXPLAIN SELECT * FROM `varchartest` WHERE utf8name LIKE 'jthijssen';+----+-------------+-------------+-------+---------------+--------------+---------+------+------+-------------+| id | select_type | table  | type  | possible_keys | key  | key_len | ref  | rows | Extra  |+----+-------------+-------------+-------+---------------+--------------+---------+------+------+-------------+|  1 | SIMPLE  | varchartest | range | idx_utf8name  | idx_utf8name | 767  | NULL |  1 | Using where |+----+-------------+-------------+-------+---------------+--------------+---------+------+------+-------------+1 row in set (0.01 sec)
ALL temporary buffers are allocated for worst-case scenario’s.  This means a varchar(255) in UTF-8 uses 255*3 + 2 = 767 bytes PER row, even if you have only  1 single char  inside. Tip 12:   UTF-8  (1)
13) Know your cardinality & selectivity Tip  13
Cardinality: the number of unique entries inside the index. Selectivity: percentage of unique entries. S(I) = cardinality / count * 100% Tip 13:   Cardinality & Selectivity  (1)
Tip 13:   Cardinality & Selectivity  (2)
with 10 records: 5/10 * 100% = 50% with 1000 records: 75/1000 * 100 = 7.5% with 10.000 records: 200/10000 * 100% = 2% Tip 13:   Cardinality & Selectivity  (3) country_id (max +-200, but effectively +- 50, maybe less)
A selectivity < 30% ? Full table scan! ANALYZE TABLE frequently. Tip 13:   Cardinality & Selectivity  (4)
Adding records changes your cardinality and thus selectivity.  Develop against a “real” dataset. Tip 13:   Cardinality & Selectivity  (5)
14) Non-deterministic functions do not go well with query caching  Tip  14 NOW(), RAND(), UUID(), CONNECTION_ID() ETC..
Tip 14:   Query caching  (1) mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name  | Value  |+-------------------------+----------+| Qcache_free_blocks  | 1  || Qcache_free_memory  | 16768400 || Qcache_hits  | 3860  || Qcache_inserts  | 975  || Qcache_lowmem_prunes  | 0  || Qcache_not_cached  | 486  || Qcache_queries_in_cache | 0  || Qcache_total_blocks  | 1  |+-------------------------+----------+8 rows in set (0.00 sec) mysql> select * from varchartest;+----+------+----------+| id | name | utf8name |+----+------+----------+|  1 | j  | joshua  ||  2 | j  | jeroen  ||  3 | d  | david  |+----+------+----------+3 rows in set (0.00 sec)mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name  | Value  |+-------------------------+----------+| Qcache_free_blocks  | 1  || Qcache_free_memory  | 16766864 || Qcache_hits  | 3860  || Qcache_inserts  | 976  || Qcache_lowmem_prunes  | 0  || Qcache_not_cached  | 486  || Qcache_queries_in_cache | 1  || Qcache_total_blocks  | 4  |+-------------------------+----------+8 rows in set (0.00 sec)
Tip 14:   Query caching  (2) mysql> select * from varchartest;+----+------+----------+| id | name | utf8name |+----+------+----------+|  1 | j  | joshua  ||  2 | j  | jeroen  ||  3 | d  | david  |+----+------+----------+3 rows in set (0.00 sec)mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name  | Value  |+-------------------------+----------+| Qcache_free_blocks  | 1  || Qcache_free_memory  | 16766864 || Qcache_hits  | 3861  || Qcache_inserts  | 976  || Qcache_lowmem_prunes  | 0  || Qcache_not_cached  | 486  || Qcache_queries_in_cache | 1  || Qcache_total_blocks  | 4  |+-------------------------+----------+8 rows in set (0.00 sec) mysql> select * from varchartest;+----+------+----------+| id | name | utf8name |+----+------+----------+|  1 | j  | joshua  ||  2 | j  | jeroen  ||  3 | d  | david  |+----+------+----------+3 rows in set (0.00 sec)mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name  | Value  |+-------------------------+----------+| Qcache_free_blocks  | 1  || Qcache_free_memory  | 16766864 || Qcache_hits  | 3860  || Qcache_inserts  | 976  || Qcache_lowmem_prunes  | 0  || Qcache_not_cached  | 486  || Qcache_queries_in_cache | 1  || Qcache_total_blocks  | 4  |+-------------------------+----------+8 rows in set (0.00 sec)
Tip 14:   Query caching  (3) mysql> select * from varchartest;+----+------+----------+| id | name | utf8name |+----+------+----------+|  1 | j  | joshua  ||  2 | j  | jeroen  ||  3 | d  | david  |+----+------+----------+3 rows in set (0.00 sec)mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name  | Value  |+-------------------------+----------+| Qcache_free_blocks  | 1  || Qcache_free_memory  | 16766864 || Qcache_hits  | 3861  || Qcache_inserts  | 976  || Qcache_lowmem_prunes  | 0  || Qcache_not_cached  | 486  || Qcache_queries_in_cache | 1  || Qcache_total_blocks  | 4  |+-------------------------+----------+8 rows in set (0.00 sec) mysql> select * from varchartest ORDER BY RAND();+----+------+----------+| id | name | utf8name |+----+------+----------+|  2 | j  | jeroen  ||  1 | j  | joshua  ||  3 | d  | david  |+----+------+----------+3 rows in set (0.05 sec)mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name  | Value  |+-------------------------+----------+| Qcache_free_blocks  | 1  || Qcache_free_memory  | 16766864 || Qcache_hits  | 3861  || Qcache_inserts  | 976  || Qcache_lowmem_prunes  | 0  || Qcache_not_cached  | 487  || Qcache_queries_in_cache | 1  || Qcache_total_blocks  | 4  |+-------------------------+----------+8 rows in set (0.00 sec)
SELECT * FROM table WHERE YEAR(created_dt) < YEAR(NOW()); vs SELECT * FROM table WHERE YEAR(created_dt) < ‘2010’; Tip 14:   Query caching  (4)
15) Certify yourself as a DBA and/or DBE. Tip  15 AND GET SOME NICE TITLES WHILE YOU’RE AT IT...
Oracle Certified MySQL Associate  Oracle Certified Professional MySQL 5.0 Developer Oracle Certified Professional MySQL 5.0 Database Administrator Oracle Certified Expert, MySQL 5.1 Cluster Database Administrator “ Old”, but still, get them all! Tip 15:   Certify yourself  (1) THEY ARE NOT VERY EASY EXAMS, BUT WELL WORTH IT
Let’s  summarize Know how to use explain. Know the most basic my.cnf settings. Backup on table level. Don’t use “SELECT *” when you only need 1 or 2 fields. Use triggers and stored procedures. Don’t use FULLTEXT searches. Wildcard searches (%item%) are bad for performance. Shard your volatile and non-volatile data. Don’t use a large Primary Key for InnoDB tables.Don’t “Select COUNT(*)” on InnoDB. Don’t rely on the VARCHAR(). UTF-8 is not the enemy, but it certainly isn’t your friend.Know your cardinality & selectivity.Non-deterministic functions do not go well with query caching.  Certify yourself as a DBA and/or DBE.
Any  questions? QUESTIONS? http://farm1.static.flickr.com/73/163450213_18478d3aa6_d.jpg
Daycamp for developers http://www.enrise.com http://www.daycamp4developers.com /
THANK YOU FOR YOUR ATTENTION Please rate my talk:  http://joind.in/3662
Ad

More Related Content

What's hot (18)

SQL techniques for faster applications
SQL techniques for faster applicationsSQL techniques for faster applications
SQL techniques for faster applications
Connor McDonald
 
Lecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erickLecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erick
okelloerick
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
oysteing
 
Percona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuningPercona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuning
Sergey Petrunya
 
Practica controlconcurrencia
Practica controlconcurrenciaPractica controlconcurrencia
Practica controlconcurrencia
María Luisa Velasco
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
Lecture5 my sql statements by okello erick
Lecture5 my sql statements by okello erickLecture5 my sql statements by okello erick
Lecture5 my sql statements by okello erick
okelloerick
 
Lecture2 mysql by okello erick
Lecture2 mysql by okello erickLecture2 mysql by okello erick
Lecture2 mysql by okello erick
okelloerick
 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Tesora
 
Explain2
Explain2Explain2
Explain2
Anis Berejeb
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tips
Connor McDonald
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
Connor McDonald
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on Autonomous
Connor McDonald
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
oysteing
 
Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolest
Connor McDonald
 
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
Sergey Petrunya
 
KScope19 - SQL Features
KScope19 - SQL FeaturesKScope19 - SQL Features
KScope19 - SQL Features
Connor McDonald
 
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
Sergey Petrunya
 
SQL techniques for faster applications
SQL techniques for faster applicationsSQL techniques for faster applications
SQL techniques for faster applications
Connor McDonald
 
Lecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erickLecture3 mysql gui by okello erick
Lecture3 mysql gui by okello erick
okelloerick
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
oysteing
 
Percona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuningPercona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuning
Sergey Petrunya
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
Lecture5 my sql statements by okello erick
Lecture5 my sql statements by okello erickLecture5 my sql statements by okello erick
Lecture5 my sql statements by okello erick
okelloerick
 
Lecture2 mysql by okello erick
Lecture2 mysql by okello erickLecture2 mysql by okello erick
Lecture2 mysql by okello erick
okelloerick
 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Tesora
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tips
Connor McDonald
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
Connor McDonald
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on Autonomous
Connor McDonald
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
oysteing
 
Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolest
Connor McDonald
 
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
Sergey Petrunya
 
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...ANALYZE for executable statements - a new way to do optimizer troubleshooting...
ANALYZE for executable statements - a new way to do optimizer troubleshooting...
Sergey Petrunya
 

Viewers also liked (20)

Traits & Mixins
Traits & Mixins Traits & Mixins
Traits & Mixins
Skills Matter
 
Mario
MarioMario
Mario
宗志 陈
 
Log experience
Log experienceLog experience
Log experience
宗志 陈
 
Beanstalk
BeanstalkBeanstalk
Beanstalk
宗志 陈
 
bada-data-beautiful
bada-data-beautifulbada-data-beautiful
bada-data-beautiful
宗志 陈
 
Pika
PikaPika
Pika
宗志 陈
 
Disk and page cache
Disk and page cacheDisk and page cache
Disk and page cache
宗志 陈
 
Workshop unittesting
Workshop unittestingWorkshop unittesting
Workshop unittesting
Joshua Thijssen
 
Puppet for dummies - PHPBenelux UG edition
Puppet for dummies - PHPBenelux UG editionPuppet for dummies - PHPBenelux UG edition
Puppet for dummies - PHPBenelux UG edition
Joshua Thijssen
 
Representation state transfer and some other important stuff
Representation state transfer and some other important stuffRepresentation state transfer and some other important stuff
Representation state transfer and some other important stuff
Joshua Thijssen
 
Moved 301
Moved 301Moved 301
Moved 301
Joshua Thijssen
 
15 protips for mysql users
15 protips for mysql users15 protips for mysql users
15 protips for mysql users
Joshua Thijssen
 
Alice & bob public key cryptography 101 - uncon dpc
Alice & bob  public key cryptography 101 - uncon dpcAlice & bob  public key cryptography 101 - uncon dpc
Alice & bob public key cryptography 101 - uncon dpc
Joshua Thijssen
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APT
Joshua Thijssen
 
PFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - AdvancedPFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - Advanced
Joshua Thijssen
 
PFZ WorkshopDay Linux - Basic
PFZ WorkshopDay Linux - BasicPFZ WorkshopDay Linux - Basic
PFZ WorkshopDay Linux - Basic
Joshua Thijssen
 
Paxos introduction
Paxos introductionPaxos introduction
Paxos introduction
宗志 陈
 
Leveldb background
Leveldb backgroundLeveldb background
Leveldb background
宗志 陈
 
Alice & bob public key cryptography 101
Alice & bob  public key cryptography 101Alice & bob  public key cryptography 101
Alice & bob public key cryptography 101
Joshua Thijssen
 
Log experience
Log experienceLog experience
Log experience
宗志 陈
 
bada-data-beautiful
bada-data-beautifulbada-data-beautiful
bada-data-beautiful
宗志 陈
 
Disk and page cache
Disk and page cacheDisk and page cache
Disk and page cache
宗志 陈
 
Puppet for dummies - PHPBenelux UG edition
Puppet for dummies - PHPBenelux UG editionPuppet for dummies - PHPBenelux UG edition
Puppet for dummies - PHPBenelux UG edition
Joshua Thijssen
 
Representation state transfer and some other important stuff
Representation state transfer and some other important stuffRepresentation state transfer and some other important stuff
Representation state transfer and some other important stuff
Joshua Thijssen
 
15 protips for mysql users
15 protips for mysql users15 protips for mysql users
15 protips for mysql users
Joshua Thijssen
 
Alice & bob public key cryptography 101 - uncon dpc
Alice & bob  public key cryptography 101 - uncon dpcAlice & bob  public key cryptography 101 - uncon dpc
Alice & bob public key cryptography 101 - uncon dpc
Joshua Thijssen
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APT
Joshua Thijssen
 
PFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - AdvancedPFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - Advanced
Joshua Thijssen
 
PFZ WorkshopDay Linux - Basic
PFZ WorkshopDay Linux - BasicPFZ WorkshopDay Linux - Basic
PFZ WorkshopDay Linux - Basic
Joshua Thijssen
 
Paxos introduction
Paxos introductionPaxos introduction
Paxos introduction
宗志 陈
 
Leveldb background
Leveldb backgroundLeveldb background
Leveldb background
宗志 陈
 
Alice & bob public key cryptography 101
Alice & bob  public key cryptography 101Alice & bob  public key cryptography 101
Alice & bob public key cryptography 101
Joshua Thijssen
 
Ad

Similar to 15 protips for mysql users pfz (20)

MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
Sveta Smirnova
 
Beginner guide to mysql command line
Beginner guide to mysql command lineBeginner guide to mysql command line
Beginner guide to mysql command line
Priti Solanki
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.ppt
KISHOYIANKISH
 
Advance MySQL Training by Pratyush Majumdar
Advance MySQL Training by Pratyush MajumdarAdvance MySQL Training by Pratyush Majumdar
Advance MySQL Training by Pratyush Majumdar
Pratyush Majumdar
 
My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2
Morgan Tocker
 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
Stanley Huang
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New Tricks
MYXPLAIN
 
MySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesMySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queries
Damien Seguy
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
New index features in MySQL 8
New index features in MySQL 8New index features in MySQL 8
New index features in MySQL 8
Erik Frøseth
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query Tuning
Sveta Smirnova
 
Short Intro to PHP and MySQL
Short Intro to PHP and MySQLShort Intro to PHP and MySQL
Short Intro to PHP and MySQL
Jussi Pohjolainen
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
Mysql basics1
Mysql basics1Mysql basics1
Mysql basics1
Steffy Robert
 
Introduction To Lamp P2
Introduction To Lamp P2Introduction To Lamp P2
Introduction To Lamp P2
Amzad Hossain
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
MySQL SQL Tutorial
MySQL SQL TutorialMySQL SQL Tutorial
MySQL SQL Tutorial
Chien Chung Shen
 
Performance schema and sys schema
Performance schema and sys schemaPerformance schema and sys schema
Performance schema and sys schema
Mark Leith
 
Need for Speed: MySQL Indexing
Need for Speed: MySQL IndexingNeed for Speed: MySQL Indexing
Need for Speed: MySQL Indexing
MYXPLAIN
 
Undelete (and more) rows from the binary log
Undelete (and more) rows from the binary logUndelete (and more) rows from the binary log
Undelete (and more) rows from the binary log
Frederic Descamps
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
Sveta Smirnova
 
Beginner guide to mysql command line
Beginner guide to mysql command lineBeginner guide to mysql command line
Beginner guide to mysql command line
Priti Solanki
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.ppt
KISHOYIANKISH
 
Advance MySQL Training by Pratyush Majumdar
Advance MySQL Training by Pratyush MajumdarAdvance MySQL Training by Pratyush Majumdar
Advance MySQL Training by Pratyush Majumdar
Pratyush Majumdar
 
My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2
Morgan Tocker
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New Tricks
MYXPLAIN
 
MySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesMySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queries
Damien Seguy
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
New index features in MySQL 8
New index features in MySQL 8New index features in MySQL 8
New index features in MySQL 8
Erik Frøseth
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query Tuning
Sveta Smirnova
 
Short Intro to PHP and MySQL
Short Intro to PHP and MySQLShort Intro to PHP and MySQL
Short Intro to PHP and MySQL
Jussi Pohjolainen
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
Introduction To Lamp P2
Introduction To Lamp P2Introduction To Lamp P2
Introduction To Lamp P2
Amzad Hossain
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
Performance schema and sys schema
Performance schema and sys schemaPerformance schema and sys schema
Performance schema and sys schema
Mark Leith
 
Need for Speed: MySQL Indexing
Need for Speed: MySQL IndexingNeed for Speed: MySQL Indexing
Need for Speed: MySQL Indexing
MYXPLAIN
 
Undelete (and more) rows from the binary log
Undelete (and more) rows from the binary logUndelete (and more) rows from the binary log
Undelete (and more) rows from the binary log
Frederic Descamps
 
Ad

Recently uploaded (20)

Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 

15 protips for mysql users pfz

  • 1. 15 Pro-tips for MySQL Users PFCongress - 17 september 2011 Utrecht - Netherlands
  • 2. Joshua Thijssen Senior Software Engineer @ Enrise Development in PHP, Python, Perl, C, Java.... Email: [email_address] Twitter: @jaytaph Blogs: http://www.adayinthelifeof.nl http://www.enrise.com/blog
  • 3. 15 MySQL Pro-tips No “theoretical tips”, all taken from the field. Starting simple - ending “complex” What are we going to discuss? QUESTIONS? RAISE YOUR HAND OR YELL LOUD
  • 4. 0) Use the correct MySQL version Tip 0 MySQL 5.0 != 5.5
  • 5. RHEL 5-7: 5.0.77 RHEL 6-1: 5.1.52 Debian (lenny) 5.0.51a Debian (squeeze): 5.1.49 Debian (sid): 5.1.58 Tip 0: Use the correct MySQL version http://distrowatch.com/table.php?distribution=redhat http://distrowatch.com/table.php?distribution=debian
  • 6. 1) Know how to use explain (and profiler) Tip 1 EXPLAIN IS YOUR BESTEST FRIEND
  • 7. I will not show you how to use EXPLAIN. Use EXPLAIN and EXPLAIN EXTENDED/ SHOW WARNINGS; Tip 1: Know your EXPLAIN (1)
  • 8. Tip 1: Know your EXPLAIN (2) mysql> desc varchartest;+----------+--------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+----------+--------------+------+-----+---------+-------+| id | int(11) | NO | PRI | 0 | || name | varchar(255) | NO | MUL | NULL | || utf8name | varchar(255) | NO | MUL | NULL | |+----------+--------------+------+-----+---------+-------+3 rows in set (0.01 sec)
  • 9. Tip 1: Know your EXPLAIN (3) mysql> EXPLAIN EXTENDED -> SELECT * FROM varchartest WHERE name LIKE 'joshua';+----+-------------+-------------+-------+---------------+----------+---------+------+------+----------+-------------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |+----+-------------+-------------+-------+---------------+----------+---------+------+------+----------+-------------+| 1 | SIMPLE | varchartest | range | idx_name | idx_name | 257 | NULL | 1 | 100.00 | Using where |+----+-------------+-------------+-------+---------------+----------+---------+------+------+----------+-------------+1 row in set, 1 warning (0.01 sec)
  • 10. Tip 1: Know your EXPLAIN (4) mysql> SHOW WARNINGS\g+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Level | Code | Message |+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Note | 1003 | select `pfz`.`varchartest`.`id` AS `id`,`pfz`.`varchartest`.`name` AS `name`,`pfz`.`varchartest`.`utf8name` AS `utf8name` from `pfz`.`varchartest` where (`pfz`.`varchartest`.`name` like 'joshua') |+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  • 11. Tip 1: Know your PROFILER (1) mysql> SET profiling=1;mysql> SELECT * FROM table; mysql> SHOW PROFILE CPU, BLOCK IO; +--------------------------------+----------+----------+------------+--------------+---------------+| Status | Duration | CPU_user | CPU_system | Block_ops_in | Block_ops_out |+--------------------------------+----------+----------+------------+--------------+---------------+| starting | 0.000930 | 0.000000 | 0.000000 | 0 | 8 || checking query cache for query | 0.000547 | 0.000000 | 0.000000 | 0 | 0 || checking permissions | 0.000045 | 0.000000 | 0.000000 | 0 | 0 || Opening tables | 0.000142 | 0.000000 | 0.000000 | 0 | 0 || System lock | 0.000030 | 0.000000 | 0.000000 | 0 | 0 || Table lock | 0.000045 | 0.000000 | 0.000000 | 0 | 0 || init | 0.000207 | 0.000000 | 0.000000 | 0 | 0 || optimizing | 0.000007 | 0.000000 | 0.000000 | 0 | 0 || statistics | 0.000068 | 0.000000 | 0.000000 | 0 | 0 || preparing | 0.001393 | 0.004000 | 0.000000 | 0 | 0 || Creating tmp table | 0.001658 | 0.000000 | 0.000000 | 0 | 8 || executing | 0.000005 | 0.000000 | 0.000000 | 0 | 0 || Copying to tmp table | 0.000834 | 0.000000 | 0.004001 | 0 | 8 || Sorting result | 0.000179 | 0.000000 | 0.000000 | 0 | 0 || Sending data | 0.000089 | 0.000000 | 0.000000 | 0 | 0 || end | 0.000022 | 0.000000 | 0.000000 | 0 | 0 || removing tmp table | 0.000089 | 0.000000 | 0.000000 | 0 | 0 || end | 0.000005 | 0.000000 | 0.000000 | 0 | 0 || query end | 0.000004 | 0.000000 | 0.000000 | 0 | 0 || freeing items | 0.000844 | 0.000000 | 0.000000 | 0 | 0 || logging slow query | 0.000023 | 0.000000 | 0.000000 | 0 | 0 || logging slow query | 0.000060 | 0.000000 | 0.000000 | 0 | 8 || cleaning up | 0.000007 | 0.000000 | 0.000000 | 0 | 0 |+--------------------------------+----------+----------+------------+--------------+---------------+
  • 12. 2) Know the most basic my.cnf settings Tip 2 THERE ARE ONLY A FEW “BASIC” ONES.
  • 13. Tip 2: My.cnf settings (1) Know the most important ones: key_buffer_size, innodb_buffer_pool_size, sort_buffer_size, max_connections
  • 14. Some settings work on global level, some per connection! Know some quirks: (max_heap_table_size vs tmp_table_size, binlog-do-db, replicate-ignore-db etc) Tip 2: My.cnf settings (2)
  • 16. 3) Backup on table level Tip 3 RESTORING JUST ONE TABLE CAN BE PAINFUL OTHERWISE
  • 17. mysqldump can dump per database OR by table. Simple scripts to scan/dump tables. Easy restore for single table (or part of table) Tip 3: Backup on table level (1) COULD YOU RESTORE TABLE x? YES! YES I CAN!
  • 18. 4) Don’t use “SELECT *” when you only need one or two fields. Tip 4 DON’T ASK WHAT YOU DON’T NEED
  • 19. Much more data to be read from disk Much more data will be send over, thus slower (blobs/texts) Cannot use covering indices Tip 4: Select * (1) DON’T ASK WHAT YOU DON’T NEED
  • 20. Tip 4: Select * (2) mysql> SHOW FULL COLUMNS FROM `covering`;+--------------+------------------+------------------+------+-----+---------+----------------+ | Field | Type | Collation | Null | Key | Default | Extra | +--------------+------------------+------------------+------+-----+---------+----------------+| id | int(10) unsigned | NULL | NO | PRI | NULL | auto_increment || email | varchar(255) | ascii_general_ci | NO | MUL | NULL | | | want_mailing | tinyint(1) | NULL | NO | MUL | NULL | | | extra_info | varchar(255) | ascii_general_ci | NO | MUL | NULL | |+--------------+------------------+------------------+------+-----+---------+----------------+3 rows in set (0.00 sec)mysql> SHOW INDEXES FROM `covering`;+----------+------------+------------+--------------+--------------+-----------+-------------+| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | +----------+------------+------------+--------------+--------------+-----------+-------------+| covering | 0 | PRIMARY | 1 | id | A | 3 || covering | 1 | idx_email | 1 | email | A | 3 || covering | 1 | idx_email | 2 | want_mailing | A | 3 || covering | 1 | idx_email2 | 1 | want_mailing | A | 1 || covering | 1 | idx_email2 | 2 | email | A | 3 |+----------+------------+------------+--------------+--------------+-----------+-------------+5 rows in set (0.01 sec)
  • 21. Tip 4: Select * (2) mysql> EXPLAIN SELECT want_mailing FROM `covering` WHERE email LIKE ' [email_address] ';+----+-------------+----------+-------+---------------+-----------+---------+------+------+--------------------------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+----------+-------+---------------+-----------+---------+------+------+--------------------------+| 1 | SIMPLE | covering | range | idx_email | idx_email | 257 | NULL | 1 | Using where; Using index |+----+-------------+----------+-------+---------------+-----------+---------+------+------+--------------------------+1 row in set (0.00 sec)
  • 22. 5) Use triggers and stored procedures Tip 5 ENFORCE CONSISTENCY
  • 23. 6 triggers per table (insert, update, delete, before and after the mutation) 3rd party tools (phpmyadmin etc) can also use the database without loosing data consistency. Watch out with (phpmyadmin) table dumps! Tip 5: Triggers and stored procedures (1) ENFORCE CONSISTENCY
  • 24. 6) Don’t use FULLTEXT searches Tip 6 THERE ARE MUCH BETTER SOLUTIONS
  • 25. They only work for MyISAM tables. Not compatible with other DB’s. Slow (especially compared to Solr, Sphinx). No extra features (faceted search, spell checking etc). Tip 6: Don’t use FULLTEXT search (1) THERE ARE MUCH BETTER SOLUTIONS
  • 26. 7) Some wildcard searches (%item%) are bad for performance Tip 7 IT LOOKS LIKE YOU NEED MORE ADVANCED SEARCH?
  • 27. MySQL cannot use indexing! Revert your data: search for ‘moc.esirne@%’ instead of ‘%@enrise.com’. Use a better solution (solr, sphinx). You probably want it (no, really) Tip 7: Wildcard searches (1) THERE ARE MUCH BETTER SOLUTIONS
  • 28. 8) Shard your volatile and non-volatile data. Tip 8 MAKE CACHING AND LOCKING HAPPY AGAIN
  • 29. Tip 8: Sharding (1) mysql> SHOW FULL COLUMNS FROM `pages`;+------------+------------------+-------------------+------+-----+-------------------+-------+| Field | Type | Collation | Null | Key | Default | Extra |+------------+------------------+-------------------+------+-----+-------------------+-------+| page_id | int(10) unsigned | NULL | NO | PRI | NULL | || created_dt | timestamp | NULL | NO | | CURRENT_TIMESTAMP | || creator_id | int(11) | NULL | NO | | NULL | || title | varchar(100) | latin1_swedish_ci | NO | | NULL | || contents | text | latin1_swedish_ci | NO | | NULL | || hit_count | int(11) | NULL | NO | | 0 | |+------------+------------------+-------------------+------+-----+-------------------+-------+6 rows in set (0.01 sec)
  • 30. Remember: an update on a table will invalidate ALL caches referring to that table. UPDATE pages SET hit_count = hit_count + 1; Thus: page table will NEVER be cached. Tip 8: Sharding (2)
  • 31. Define hot data (volatile, changes often) and cold data (static, changes never or infrequently) move to different tables UPDATE page_stats SET hit_count = hit_count + 1; Query cache is happy again Tip 8: Sharding (3)
  • 32. MySQL 5.1 and higher has got partitioning (but you should shard anyway). Tip 8: Sharding (4)
  • 33. 9) Don’t use a large primary key for InnoDB tables. Tip 9 PK’S ARE ON EVERY INDEX
  • 34. InnoDB adds the primary key to EACH index. No primary key given? It uses an internal 6(!)-byte key. Tip 9: Large primary keys (1)
  • 35. 10) Don’t “SELECT COUNT(*) FROM TABLE” on InnoDB. Tip 10 COUNT(*) => MYISAM = FAST COUNT(*) => INNODB = SLOW
  • 36. InnoDB implements MVCC (multi-version concurrency control). COUNT(*) must be counted and is not fetched from metadata. Tip 10: SELECT COUNT(*) (1)
  • 37. What do you want to COUNT(*)? Just for displaying purposes (there are X amount of pages): do you need the EXACT amount? (guess &| cache) Tip 10: SELECT COUNT(*) (2)
  • 38. 11) Don’t rely on the VARCHAR() Tip 11 IT ISN’T THAT VARIABLE AS YOU MIGHT THINK
  • 39. Tip 11: VARCHAR() (1) IT DOESN’T SOLVE YOUR PROBLEMS
  • 40. DON’T WORRY ABOUT THE UTF-8, I’LL BASH THAT LATER Tip 11: VARCHAR() (3) mysql> SHOW FULL COLUMNS FROM `varchartest`;+----------+--------------+-------------------+------+-----+---------+-------+| Field | Type | Collation | Null | Key | Default | Extra |+----------+--------------+-------------------+------+-----+---------+-------+| id | int(11) | NULL | NO | PRI | 0 | || name | varchar(255) | latin1_swedish_ci | NO | MUL | NULL | || utf8name | varchar(255) | utf8_general_ci | NO | MUL | NULL | |+----------+--------------+-------------------+------+-----+---------+-------+3 rows in set (0.01 sec)mysql> SHOW INDEXES FROM `varchartest`;+-------------+------------+--------------+--------------+-------------+-----------+-------------+| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality |+-------------+------------+--------------+--------------+-------------+-----------+-------------+| varchartest | 0 | PRIMARY | 1 | id | A | 3 || varchartest | 1 | idx_name | 1 | name | A | 3 || varchartest | 1 | idx_utf8name | 1 | utf8name | A | 3 |+-------------+------------+--------------+--------------+-------------+-----------+-------------+3 rows in set (0.00 sec)
  • 41. DON’T WORRY ABOUT THE UTF-8, I’LL BASH THAT LATER Tip 11: VARCHAR() (3) mysql> EXPLAIN SELECT * FROM `varchartest` WHERE name LIKE 'jthijssen';+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+| 1 | SIMPLE | varchartest | range | idx_name | idx_name | 257 | NULL | 1 | Using where |+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+1 row in set (0.00 sec)
  • 42. 12) UTF-8 is not the enemy, but it certainly isn’t your friend. Tip 12 DON’T EXCHANGE ONE PROBLEM FOR ANOTHER
  • 43. Dr Jeckyl and Mr Hyde Solves all your multi-language problems! But gives back performance issues. Tip 12: UTF-8 (1)
  • 44. Tip 12: UTF-8 (1) mysql> SHOW FULL COLUMNS FROM `varchartest`;+----------+--------------+-------------------+------+-----+---------+-------+| Field | Type | Collation | Null | Key | Default | Extra |+----------+--------------+-------------------+------+-----+---------+-------+| id | int(11) | NULL | NO | PRI | 0 | || name | varchar(255) | latin1_swedish_ci | NO | MUL | NULL | || utf8name | varchar(255) | utf8_general_ci | NO | MUL | NULL | |+----------+--------------+-------------------+------+-----+---------+-------+3 rows in set (0.01 sec)mysql> SHOW INDEXES FROM `varchartest`;+-------------+------------+--------------+--------------+-------------+-----------+-------------+| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality |+-------------+------------+--------------+--------------+-------------+-----------+-------------+| varchartest | 0 | PRIMARY | 1 | id | A | 3 || varchartest | 1 | idx_name | 1 | name | A | 3 || varchartest | 1 | idx_utf8name | 1 | utf8name | A | 3 |+-------------+------------+--------------+--------------+-------------+-----------+-------------+3 rows in set (0.00 sec)
  • 45. Tip 12: UTF-8 (1) mysql> EXPLAIN SELECT * FROM `varchartest` WHERE name LIKE 'jthijssen';+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+| 1 | SIMPLE | varchartest | range | idx_name | idx_name | 257 | NULL | 1 | Using where |+----+-------------+-------------+-------+---------------+----------+---------+------+------+-------------+1 row in set (0.00 sec) mysql> EXPLAIN SELECT * FROM `varchartest` WHERE utf8name LIKE 'jthijssen';+----+-------------+-------------+-------+---------------+--------------+---------+------+------+-------------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+-------------+-------+---------------+--------------+---------+------+------+-------------+| 1 | SIMPLE | varchartest | range | idx_utf8name | idx_utf8name | 767 | NULL | 1 | Using where |+----+-------------+-------------+-------+---------------+--------------+---------+------+------+-------------+1 row in set (0.01 sec)
  • 46. ALL temporary buffers are allocated for worst-case scenario’s. This means a varchar(255) in UTF-8 uses 255*3 + 2 = 767 bytes PER row, even if you have only 1 single char inside. Tip 12: UTF-8 (1)
  • 47. 13) Know your cardinality & selectivity Tip 13
  • 48. Cardinality: the number of unique entries inside the index. Selectivity: percentage of unique entries. S(I) = cardinality / count * 100% Tip 13: Cardinality & Selectivity (1)
  • 49. Tip 13: Cardinality & Selectivity (2)
  • 50. with 10 records: 5/10 * 100% = 50% with 1000 records: 75/1000 * 100 = 7.5% with 10.000 records: 200/10000 * 100% = 2% Tip 13: Cardinality & Selectivity (3) country_id (max +-200, but effectively +- 50, maybe less)
  • 51. A selectivity < 30% ? Full table scan! ANALYZE TABLE frequently. Tip 13: Cardinality & Selectivity (4)
  • 52. Adding records changes your cardinality and thus selectivity. Develop against a “real” dataset. Tip 13: Cardinality & Selectivity (5)
  • 53. 14) Non-deterministic functions do not go well with query caching Tip 14 NOW(), RAND(), UUID(), CONNECTION_ID() ETC..
  • 54. Tip 14: Query caching (1) mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name | Value |+-------------------------+----------+| Qcache_free_blocks | 1 || Qcache_free_memory | 16768400 || Qcache_hits | 3860 || Qcache_inserts | 975 || Qcache_lowmem_prunes | 0 || Qcache_not_cached | 486 || Qcache_queries_in_cache | 0 || Qcache_total_blocks | 1 |+-------------------------+----------+8 rows in set (0.00 sec) mysql> select * from varchartest;+----+------+----------+| id | name | utf8name |+----+------+----------+| 1 | j | joshua || 2 | j | jeroen || 3 | d | david |+----+------+----------+3 rows in set (0.00 sec)mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name | Value |+-------------------------+----------+| Qcache_free_blocks | 1 || Qcache_free_memory | 16766864 || Qcache_hits | 3860 || Qcache_inserts | 976 || Qcache_lowmem_prunes | 0 || Qcache_not_cached | 486 || Qcache_queries_in_cache | 1 || Qcache_total_blocks | 4 |+-------------------------+----------+8 rows in set (0.00 sec)
  • 55. Tip 14: Query caching (2) mysql> select * from varchartest;+----+------+----------+| id | name | utf8name |+----+------+----------+| 1 | j | joshua || 2 | j | jeroen || 3 | d | david |+----+------+----------+3 rows in set (0.00 sec)mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name | Value |+-------------------------+----------+| Qcache_free_blocks | 1 || Qcache_free_memory | 16766864 || Qcache_hits | 3861 || Qcache_inserts | 976 || Qcache_lowmem_prunes | 0 || Qcache_not_cached | 486 || Qcache_queries_in_cache | 1 || Qcache_total_blocks | 4 |+-------------------------+----------+8 rows in set (0.00 sec) mysql> select * from varchartest;+----+------+----------+| id | name | utf8name |+----+------+----------+| 1 | j | joshua || 2 | j | jeroen || 3 | d | david |+----+------+----------+3 rows in set (0.00 sec)mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name | Value |+-------------------------+----------+| Qcache_free_blocks | 1 || Qcache_free_memory | 16766864 || Qcache_hits | 3860 || Qcache_inserts | 976 || Qcache_lowmem_prunes | 0 || Qcache_not_cached | 486 || Qcache_queries_in_cache | 1 || Qcache_total_blocks | 4 |+-------------------------+----------+8 rows in set (0.00 sec)
  • 56. Tip 14: Query caching (3) mysql> select * from varchartest;+----+------+----------+| id | name | utf8name |+----+------+----------+| 1 | j | joshua || 2 | j | jeroen || 3 | d | david |+----+------+----------+3 rows in set (0.00 sec)mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name | Value |+-------------------------+----------+| Qcache_free_blocks | 1 || Qcache_free_memory | 16766864 || Qcache_hits | 3861 || Qcache_inserts | 976 || Qcache_lowmem_prunes | 0 || Qcache_not_cached | 486 || Qcache_queries_in_cache | 1 || Qcache_total_blocks | 4 |+-------------------------+----------+8 rows in set (0.00 sec) mysql> select * from varchartest ORDER BY RAND();+----+------+----------+| id | name | utf8name |+----+------+----------+| 2 | j | jeroen || 1 | j | joshua || 3 | d | david |+----+------+----------+3 rows in set (0.05 sec)mysql> show status like '%qcache%';+-------------------------+----------+| Variable_name | Value |+-------------------------+----------+| Qcache_free_blocks | 1 || Qcache_free_memory | 16766864 || Qcache_hits | 3861 || Qcache_inserts | 976 || Qcache_lowmem_prunes | 0 || Qcache_not_cached | 487 || Qcache_queries_in_cache | 1 || Qcache_total_blocks | 4 |+-------------------------+----------+8 rows in set (0.00 sec)
  • 57. SELECT * FROM table WHERE YEAR(created_dt) < YEAR(NOW()); vs SELECT * FROM table WHERE YEAR(created_dt) < ‘2010’; Tip 14: Query caching (4)
  • 58. 15) Certify yourself as a DBA and/or DBE. Tip 15 AND GET SOME NICE TITLES WHILE YOU’RE AT IT...
  • 59. Oracle Certified MySQL Associate Oracle Certified Professional MySQL 5.0 Developer Oracle Certified Professional MySQL 5.0 Database Administrator Oracle Certified Expert, MySQL 5.1 Cluster Database Administrator “ Old”, but still, get them all! Tip 15: Certify yourself (1) THEY ARE NOT VERY EASY EXAMS, BUT WELL WORTH IT
  • 60. Let’s summarize Know how to use explain. Know the most basic my.cnf settings. Backup on table level. Don’t use “SELECT *” when you only need 1 or 2 fields. Use triggers and stored procedures. Don’t use FULLTEXT searches. Wildcard searches (%item%) are bad for performance. Shard your volatile and non-volatile data. Don’t use a large Primary Key for InnoDB tables.Don’t “Select COUNT(*)” on InnoDB. Don’t rely on the VARCHAR(). UTF-8 is not the enemy, but it certainly isn’t your friend.Know your cardinality & selectivity.Non-deterministic functions do not go well with query caching. Certify yourself as a DBA and/or DBE.
  • 61. Any questions? QUESTIONS? http://farm1.static.flickr.com/73/163450213_18478d3aa6_d.jpg
  • 62. Daycamp for developers http://www.enrise.com http://www.daycamp4developers.com /
  • 63. THANK YOU FOR YOUR ATTENTION Please rate my talk: http://joind.in/3662