SlideShare a Scribd company logo
1 of 46
Download to read offline
MySQL 5.5
Guide to InnoDB Status
        Bill Karwin, Percona Inc.
Me
• Software developer
• C, Java, Perl, PHP, Ruby
• SQL maven
• MySQL Consultant at Percona
• Author of SQL Antipatterns:
   Avoiding the Pitfalls of
   Database Programming         Bill Karwin




                                    www.percona.com
MyISAM or InnoDB?
• MyISAM can store more compactly
• MyISAM supports FULLTEXT indexes
• MyISAM uses primary keys and secondary keys in
  the same way
BUT...
• MyISAM does not support transactions
• MyISAM allows updates to write non-atomically
• MyISAM is susceptible to corruption on crashes
• MyISAM relies on filesystem cache
                                        www.percona.com
InnoDB Plugin 1.0
• Enable in /etc/my.cnf:
  [mysqld]
  ignore-builtin-innodb
  plugin-load=innodb=ha_innodb_plugin.so

• Verify InnoDB plugin is enabled:
  mysql> SHOW PLUGINS;
  +------------+----------+----------------+---------------------+---------+
  | Name       | Status   | Type           | Library             | License |
  +------------+----------+----------------+---------------------+---------+
  | InnoDB     | ACTIVE   | STORAGE ENGINE | ha_innodb_plugin.so | GPL     |
  +------------+----------+----------------+---------------------+---------+




                                                                www.percona.com
InnoDB Plugin 1.1
• Not necessary to enable InnoDB Plugin 1.1
• Default storage engine in MySQL 5.5




                                       www.percona.com
How to Show InnoDB Status

mysql> SHOW ENGINE INNODB STATUS G



      required keyword in 5.5     output without
                                long table borders




                                        www.percona.com
=====================================
INNODB MONITOR OUTPUT
=====================================
=====================================
111001 19:29:44 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 23 seconds




                               if this is less than 20-30 seconds,
                                   statistics may be inaccurate.
                                     run this command again.




                                                     www.percona.com
InnoDB Monitor Sections
• Background Thread
• Semaphores
• Latest Foreign Key Error
• Latest Detect Deadlock
• File I/O
• Insert Buffer and Adaptive Hash Index
• Log
• Buffer Pool and Memory
• Row Operations
• Transactions
                                          www.percona.com
-----------------
BACKGROUND THREAD
-----------------

srv_master_thread loops: 11938931 1_second, 11935492 sleeps,
  1193884 10_second, 365 background, 365 flush
srv_master_thread log flush and writes: 12087852




                    statistics about InnoDB main thread




                                                      www.percona.com
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 43659756, signal count 371748016



--Thread 1276582208 has waited at log/log0log.c line 1393 for 0.0000 seconds
   the semaphore:
Mutex at 0x2ab19a048de8 '&log_sys->mutex', lock var 1
waiters flag 1
                                    contention on InnoDB log file.
                                          problems in I/O?
Mutex spin waits 919370636, rounds 1883832361, OS waits 21271702
RW-shared spins 104920102, OS waits 11414698; RW-excl spins 139844907, OS
   waits 9956101
Spin rounds per wait: 2.05 mutex, 4.42 RW-shared, 6.16 RW-excl




                                     statistics about mutexes.
                              high OS waits indicates lots of contention

                                                            www.percona.com
------------------------
LATEST FOREIGN KEY ERROR
------------------------
030709 13:00:59 Transaction:
TRANSACTION 0 290328284, ACTIVE 0 sec, process no 3195, OS thread id 34831
inserting
15 lock struct(s), heap size 2496, undo log entries 9               these values failed
MySQL thread id 25, query id 4668733 localhost heikki update
insert into ibtest11a (D, B, C) values (5, 'khDk' ,'khDk')
Foreign key constraint fails for table test/ibtest11a:
  CONSTRAINT `0_219242` FOREIGN KEY (`A`, `D`) REFERENCES `ibtest11b` (`A`,`D`) ON
   DELETE CASCADE ON UPDATE CASCADE
Trying to add in child table, in index PRIMARY tuple:
 0: len 4; hex 80000101; asc ....;; 1: len 4; hex 80000005; asc ....;; 2:
 len 4; hex 6b68446b; asc khDk;; 3: len 6; hex 0000114e0edc; asc ...N..;; 4:
 len 7; hex 00000000c3e0a7; asc .......;; 5: len 4; hex 6b68446b; asc khDk;;
But in parent table test/ibtest11b, in index PRIMARY,
the closest match we can find is record:                           because no match
RECORD: info bits 0 0: len 4; hex 8000015b; asc ...[;; 1: len 4; hex
80000005; asc ....;; 2: len 3; hex 6b6864; asc khd;; 3: len 6; hex
0000111ef3eb; asc ......;; 4: len 7; hex 800001001e0084; asc .......;; 5:
len 3; hex 6b6864; asc khd;;




                                                                 www.percona.com
------------------------
  LATEST DETECTED DEADLOCK
  ------------------------

Transaction 1                                  Transaction 2
                                                    UPDATE
                                                   gets X lock
                                   X
 SELECT JOIN                  S?
                         X?
requests S lock,
 waits for T2...                   package_
                   package         object_x_
                                    article        UPDATE
                                                requests X lock,
                                                 waits for T1...



                    * DEADLOCK! *
                                                www.percona.com
------------------------
LATEST DETECTED DEADLOCK (1 of 5)
------------------------
110919 8:08:12
*** (1) TRANSACTION:
TRANSACTION A4BA03E, ACTIVE 10 sec, process no 17229, OS thread id
   1357232448 starting index read
mysql tables in use 3, locked 3                             waiting
LOCK WAIT 288 lock struct(s), heap size 47544, 4025 row lock(s), undo log
   entries 45046
MySQL thread id 959109, query id 171532998 192.168.30.61 ads
   Copying to tmp table
INSERT INTO ad_article_conflicts (article_id, object_id, object_type,
   created_dts, proc_id, conflict_count, country)
SELECT distinct article_id, package.orig_package_id,
   'package', now(), 1316437206, 1,'US'
   FROM package_object_x_article, package
   WHERE package_object_x_article.object_id = package.package_id
   AND package_object_x_article.object_type= 'package'
   AND package.package_id IN (...)

                                                        needs S locks


                                                            www.percona.com
------------------------
LATEST DETECTED DEADLOCK (2 of 5)
------------------------
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 102 page no 1784 n bits 1192 index
   `object_id_object_type` of table `ads`.`package_object_x_article` trx id
   A4BA03E lock mode S waiting
Record lock, heap no 13 PHYSICAL RECORD: n_fields 3; compact format; info
   bits 32
0: len 4; hex 0000060f; asc ;;
1: len 1; hex 01; asc ;;
2: len 4; hex 00000001; asc ;;

                                     waiting for S lock on this table

                                      already got the S lock on the
                                          other table `package`




                                                            www.percona.com
------------------------
LATEST DETECTED DEADLOCK (3 of 5)
------------------------
*** (2) TRANSACTION:
TRANSACTION A4B9F50, ACTIVE 11 sec, process no 17229, OS thread id
   1274140992 starting index read
mysql tables in use 1, locked 1                             waiting
984 lock struct(s), heap size 145848, 1115 row lock(s), undo log entries
   2221
MySQL thread id 959226, query id 171538155 192.168.30.150 ads Updating
UPDATE package SET live_dts = '2011-09-16 19:00:00', section_type =
   'exampleradio', display_type = 'old_style', expiration_dts = '2011-09-20
   00:00:00', title = 'Example Radio', package_type = 'with_landing',
   content_source = NULL WHERE package . . .




             needs X lock on `package`




                                                            www.percona.com
------------------------
LATEST DETECTED DEADLOCK (4 of 5)
------------------------
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 102 page no 1784 n bits 1192 index
   `object_id_object_type` of table `ads`.`package_object_x_article` trx id
   A4B9F50 lock_mode X locks rec but not gap
Record lock, heap no 13 PHYSICAL RECORD: n_fields 3; compact format; info
   bits 32
0: len 4; hex 0000060f; asc ;;
1: len 1; hex 01; asc ;;
                                                holds X lock on one table
2: len 4; hex 00000001; asc ;;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 305 page no 74 n bits 104 index `PRIMARY` of table
   `ads`.`package` trx id A4B9F50 lock_mode X locks rec but not gap waiting
Record lock, heap no 7 PHYSICAL RECORD: n_fields 50; compact format; info
   bits 0



                                                  waiting for X lock
                                               on other table `package`

                                                            www.percona.com
------------------------
LATEST DETECTED DEADLOCK (5 of 5)
------------------------


*** WE ROLL BACK TRANSACTION (2)




                             why this transaction?

                        because it judges transaction 2
                           has modified fewer rows




                                                     www.percona.com
--------
FILE I/O (1 of 2)
--------
I/O   thread   0   state:   waiting   for   i/o   request   (insert buffer thread)
I/O   thread   1   state:   waiting   for   i/o   request   (log thread)
I/O   thread   2   state:   waiting   for   i/o   request   (read thread)
I/O   thread   3   state:   waiting   for   i/o   request   (read thread)
I/O   thread   4   state:   waiting   for   i/o   request   (read thread)
I/O   thread   5   state:   waiting   for   i/o   request   (read thread)
I/O   thread   6   state:   waiting   for   i/o   request   (write thread)
I/O   thread   7   state:   waiting   for   i/o   request   (write thread)
I/O   thread   8   state:   waiting   for   i/o   request   (write thread)
I/O   thread   9   state:   waiting   for   i/o   request   (write thread)




                               if these are busy, you can increase
                                     innodb_read_io_threads,
                                     innodb_write_io_threads


                                                                            www.percona.com
--------
FILE I/O (2 of 2)
--------
Pending normal aio reads: 0, aio writes: 0,
 ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
907300503 OS file reads, 570173314 OS file writes, 440124224 OS fsyncs
2 pending preads, 0 pending pwrites
1182.86 reads/s, 16384 avg bytes/read, 37.52 writes/s, 31.87 fsyncs/s




                                        these are all zero,
                                    but high numbers indicate
                                        you are I/O bound




                                                            www.percona.com
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 5, seg size 7,
8146267 inserts, 8146267 merged recs, 1054076 merges



                            ratio of insert buffer efficiency
Hash table size 55249463, node heap has 990 buffer(s)
25018.43 hash searches/s, 12373.20 non-hash searches/s




          ratio of hash lookups done in
               lieu of B-tree lookups



                                                          www.percona.com
The Buffer Pool




                  www.percona.com
The Buffer Pool
• All reads/writes use the buffer pool
• SQL reads from the buffer pool many times

                         disk read




            ~100ns                   ~10,000,000ns
         memory access                 disk seek

                                               www.percona.com
The Buffer Pool
• The buffer pool is the best use of system memory.
                                                     OS needs ~2GB
                                                   MySQL needs 2 to 4GB



                                                      allocate the rest to
                                                    the InnoDB buffer pool




  http://www.mysqlperformanceblog.com/2007/11/03/choosing-innodb_buffer_pool_size/

                                                                   www.percona.com
The Buffer Pool
• Random writes to disk are very slow.




                                         www.percona.com
The Buffer Pool
• Instead, keep “dirty” pages in buffer pool,
   to be written down later



               X




• But what happens to dirty pages in a crash?
                                           www.percona.com
The Log File




                   Simon Law
               www.percona.com
The Log File
• Sequential writes to log are much quicker.



              X




                                         www.percona.com
The Log File
• Many dirty pages can be recorded in the log file.



                X
                    X
            X




                                          www.percona.com
The Log File
• As log file fills up, pressure rises to write down
   dirty pages.



                 X
                     X
             X


• This is called a log checkpoint.
                                            www.percona.com
The Log File
• As pages are written down, they no longer dirty.




• Checkpointing frees up space in the log.
                                         www.percona.com
The Log File
• Pressure to checkpoint rises because:
  - The log files have a fixed size.
  - The log files contain “redo” information to replay
       changes for all dirty pages in case of crash.
  - If log files are getting full, InnoDB throttles incoming
       INSERT/UPDATE/DELETE.




 http://www.mysqlperformanceblog.com/2011/04/04/innodb-flushing-theory-and-solutions/

                                                                    www.percona.com
The Log File
• 1 hour’s worth of changes is a good log file size.

                             30 minutes          30 minutes



                         X
                             X
                     X



http://www.mysqlperformanceblog.com/2008/11/21/how-to-calculate-a-good-innodb-log-file-size/

                                                                        www.percona.com
---
LOG
---
Log sequence number 16557482601459
Log flushed up to   16557473340329            bytes written to log
Last checkpoint at 16557036774612
1 pending log writes, 0 pending chkp writes
429764749 log i/o's done, 28.82 log i/o's/second


...15 minutes later...                            LSN is 12MB higher.
                                                  4 × 12M = 48MB/hour
Log sequence number 16557494601459



• innodb_log_file_size = 24M
                                                 because there are two
                                                   log files by default

                                                     www.percona.com
The Log File
• Not all dirty pages are written at every checkpoint.




                 X
            X



• How many pages are written? Depends...
                                          www.percona.com
IO Capacity




              Shyaulis Andrjus
              www.percona.com
IO Capacity
• Faster disks can handle greater write load.




            X




                                         www.percona.com
IO Capacity
• Tuning innodb_io_capacity
  - Default is 200, good for a single 7200rpm disk.
  - Match the IOPS your disk system can sustain.
  - Not unusual to see 800-1000 for RAID system.
  - Not unusual to see 2000-4000 for SSD system.




                                            www.percona.com
---
LOG (extra info from Percona Server)
---
Log sequence number 16557482601459
Log flushed up to   16557473340329
Last checkpoint at 16557036774612
Max checkpoint age    677822424
Checkpoint age target 656640474
Modified age          436863883
Checkpoint age        445826847
1 pending log writes, 0 pending chkp writes
429764749 log i/o's done, 28.82 log i/o's/second




                                                   www.percona.com
----------------------
BUFFER POOL AND MEMORY (1 of 3)
----------------------
Total memory allocated 28626124800; in additional pool allocated 0
Internal hash tables (constant factor + variable factor)
    Adaptive hash index 458220080 ! (441995704 + 16224376)
    Page hash           27625592
    Dictionary cache    403718221 ! (110500528 + 293217693)
    File system         83536 ! (82672 + 864)
    Lock system         71993872 ! (71910152 + 83720)
    Recovery system     0 ! 0 + 0)
                          (
    Threads             409288 ! (406936 + 2352)




                                                  www.percona.com
----------------------
BUFFER POOL AND MEMORY (2 of 3)
----------------------
Dictionary memory allocated 293217693
Buffer pool size        1703935
Buffer pool size, bytes 27917271040
Free buffers            0
Database pages          1702944
Old database pages      628605
Modified db pages       29305
Pending reads 1
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1251203063, not young 0
1194.38 youngs/s, 0.00 non-youngs/s




                                                     www.percona.com
----------------------
BUFFER POOL AND MEMORY (3 of 3)
----------------------
Pages read 1222502280, created 49476044, written 260566544
1184.30 reads/s, 61.52 creates/s, 116.82 writes/s
Buffer pool hit rate 991 / 1000, young-making rate 9 / 1000 not
  0 / 1000
Pages read ahead 0.00/s, evicted without access 0.09/s
LRU len: 1702944, unzip_LRU len: 0
I/O sum[70075]:cur[288], unzip sum[0]:cur[0]




                                                  www.percona.com
--------------
ROW OPERATIONS
--------------
3 queries inside InnoDB, 0 queries in queue
13 read views open inside InnoDB
Main thread process no. 7741, id 1211353408, state: sleeping
Number of rows inserted 2832396721, updated 5386467044, deleted
  427453434, read 166901591413
2008.17 inserts/s, 172.43 updates/s, 2.22 deletes/s, 4403.94
  reads/s




                                                  www.percona.com
------------
TRANSACTIONS
------------
Trx id counter 1FE1D5398
Purge done for trx's n:o < 1FE1D4F1D undo n:o < 0
History list length 240
LIST OF TRANSACTIONS FOR EACH SESSION:       keeping old row versions

---TRANSACTION 1FE1D5334, not started, process no 7741,
  OS thread id 1268595008 flushing log
  MySQL thread id 116454235, query id 10469901493 10.80.1.110
  c_106
  COMMIT
                                        trying to flush to log
                                             on COMMIT




                                                       www.percona.com
END

----------------------------
END OF INNODB MONITOR OUTPUT
============================




                               www.percona.com
Best Tuning Parameters
• innodb_buffer_pool_size
   - As much as you can spare after OS and MySQL.

• innodb_log_file_size
   - At least enough for 60 minutes of log writes.

• innodb_io_capacity
   - Based on your disk IOPS.


                                             www.percona.com
SQL Antipatterns
20% discount code: ZendConSQL
             (until 10/28/2011)




http://www.pragprog.com/titles/bksqla/
                                  www.percona.com

More Related Content

What's hot

Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Mydbops
 
The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLMorgan Tocker
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바NeoClova
 
InnoDB Internal
InnoDB InternalInnoDB Internal
InnoDB Internalmysqlops
 
Maxscale_메뉴얼
Maxscale_메뉴얼Maxscale_메뉴얼
Maxscale_메뉴얼NeoClova
 
InnoDB MVCC Architecture (by 권건우)
InnoDB MVCC Architecture (by 권건우)InnoDB MVCC Architecture (by 권건우)
InnoDB MVCC Architecture (by 권건우)I Goo Lee.
 
InnoDB Performance Optimisation
InnoDB Performance OptimisationInnoDB Performance Optimisation
InnoDB Performance OptimisationMydbops
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability Mydbops
 
MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용I Goo Lee
 
Handling Schema Changes Using pt-online-schema change.
Handling Schema Changes Using pt-online-schema change.Handling Schema Changes Using pt-online-schema change.
Handling Schema Changes Using pt-online-schema change.Mydbops
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기NeoClova
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxMySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxNeoClova
 
State transfer With Galera
State transfer With GaleraState transfer With Galera
State transfer With GaleraMydbops
 
mysql 8.0 architecture and enhancement
mysql 8.0 architecture and enhancementmysql 8.0 architecture and enhancement
mysql 8.0 architecture and enhancementlalit choudhary
 
Maxscale 소개 1.1.1
Maxscale 소개 1.1.1Maxscale 소개 1.1.1
Maxscale 소개 1.1.1NeoClova
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep InternalEXEM
 
Evolution of MongoDB Replicaset and Its Best Practices
Evolution of MongoDB Replicaset and Its Best PracticesEvolution of MongoDB Replicaset and Its Best Practices
Evolution of MongoDB Replicaset and Its Best PracticesMydbops
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바NeoClova
 
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docxKeepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docxNeoClova
 
MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)Mydbops
 

What's hot (20)

Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0
 
The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQL
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바
 
InnoDB Internal
InnoDB InternalInnoDB Internal
InnoDB Internal
 
Maxscale_메뉴얼
Maxscale_메뉴얼Maxscale_메뉴얼
Maxscale_메뉴얼
 
InnoDB MVCC Architecture (by 권건우)
InnoDB MVCC Architecture (by 권건우)InnoDB MVCC Architecture (by 권건우)
InnoDB MVCC Architecture (by 권건우)
 
InnoDB Performance Optimisation
InnoDB Performance OptimisationInnoDB Performance Optimisation
InnoDB Performance Optimisation
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability
 
MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용
 
Handling Schema Changes Using pt-online-schema change.
Handling Schema Changes Using pt-online-schema change.Handling Schema Changes Using pt-online-schema change.
Handling Schema Changes Using pt-online-schema change.
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxMySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptx
 
State transfer With Galera
State transfer With GaleraState transfer With Galera
State transfer With Galera
 
mysql 8.0 architecture and enhancement
mysql 8.0 architecture and enhancementmysql 8.0 architecture and enhancement
mysql 8.0 architecture and enhancement
 
Maxscale 소개 1.1.1
Maxscale 소개 1.1.1Maxscale 소개 1.1.1
Maxscale 소개 1.1.1
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep Internal
 
Evolution of MongoDB Replicaset and Its Best Practices
Evolution of MongoDB Replicaset and Its Best PracticesEvolution of MongoDB Replicaset and Its Best Practices
Evolution of MongoDB Replicaset and Its Best Practices
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바
 
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docxKeepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
 
MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)
 

Viewers also liked

FOSDEM 2015: gdb tips and tricks for MySQL DBAs
FOSDEM 2015: gdb tips and tricks for MySQL DBAsFOSDEM 2015: gdb tips and tricks for MySQL DBAs
FOSDEM 2015: gdb tips and tricks for MySQL DBAsValerii Kravchuk
 
Hierarchical data models in Relational Databases
Hierarchical data models in Relational DatabasesHierarchical data models in Relational Databases
Hierarchical data models in Relational Databasesnavicorevn
 
Storage Methods for Nonstandard Data Patterns
Storage Methods for Nonstandard Data PatternsStorage Methods for Nonstandard Data Patterns
Storage Methods for Nonstandard Data PatternsBob Burgess
 
Visualizing Data in Elasticsearch DevFest DC 2016
Visualizing Data in Elasticsearch DevFest DC 2016Visualizing Data in Elasticsearch DevFest DC 2016
Visualizing Data in Elasticsearch DevFest DC 2016David Erickson
 

Viewers also liked (20)

InnoDB Locking Explained with Stick Figures
InnoDB Locking Explained with Stick FiguresInnoDB Locking Explained with Stick Figures
InnoDB Locking Explained with Stick Figures
 
SQL Outer Joins for Fun and Profit
SQL Outer Joins for Fun and ProfitSQL Outer Joins for Fun and Profit
SQL Outer Joins for Fun and Profit
 
Schemadoc
SchemadocSchemadoc
Schemadoc
 
How to Design Indexes, Really
How to Design Indexes, ReallyHow to Design Indexes, Really
How to Design Indexes, Really
 
Mentor Your Indexes
Mentor Your IndexesMentor Your Indexes
Mentor Your Indexes
 
Percona toolkit
Percona toolkitPercona toolkit
Percona toolkit
 
Survey of Percona Toolkit
Survey of Percona ToolkitSurvey of Percona Toolkit
Survey of Percona Toolkit
 
Requirements the Last Bottleneck
Requirements the Last BottleneckRequirements the Last Bottleneck
Requirements the Last Bottleneck
 
Extensible Data Modeling
Extensible Data ModelingExtensible Data Modeling
Extensible Data Modeling
 
Sql query patterns, optimized
Sql query patterns, optimizedSql query patterns, optimized
Sql query patterns, optimized
 
Models for hierarchical data
Models for hierarchical dataModels for hierarchical data
Models for hierarchical data
 
Sql Injection Myths and Fallacies
Sql Injection Myths and FallaciesSql Injection Myths and Fallacies
Sql Injection Myths and Fallacies
 
Sql Antipatterns Strike Back
Sql Antipatterns Strike BackSql Antipatterns Strike Back
Sql Antipatterns Strike Back
 
Practical Object Oriented Models In Sql
Practical Object Oriented Models In SqlPractical Object Oriented Models In Sql
Practical Object Oriented Models In Sql
 
Full Text Search In PostgreSQL
Full Text Search In PostgreSQLFull Text Search In PostgreSQL
Full Text Search In PostgreSQL
 
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
FOSDEM 2015: gdb tips and tricks for MySQL DBAsFOSDEM 2015: gdb tips and tricks for MySQL DBAs
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
 
Optimizing MySQL
Optimizing MySQLOptimizing MySQL
Optimizing MySQL
 
Hierarchical data models in Relational Databases
Hierarchical data models in Relational DatabasesHierarchical data models in Relational Databases
Hierarchical data models in Relational Databases
 
Storage Methods for Nonstandard Data Patterns
Storage Methods for Nonstandard Data PatternsStorage Methods for Nonstandard Data Patterns
Storage Methods for Nonstandard Data Patterns
 
Visualizing Data in Elasticsearch DevFest DC 2016
Visualizing Data in Elasticsearch DevFest DC 2016Visualizing Data in Elasticsearch DevFest DC 2016
Visualizing Data in Elasticsearch DevFest DC 2016
 

Similar to MySQL 5.5 Guide to InnoDB Status

11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01Karam Abuataya
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11gfcamachob
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTanel Poder
 
Oracle Diagnostics : Locks and Lock Trees
Oracle Diagnostics :  Locks and Lock TreesOracle Diagnostics :  Locks and Lock Trees
Oracle Diagnostics : Locks and Lock TreesHemant K Chitale
 
OakTable World Sep14 clonedb
OakTable World Sep14 clonedb OakTable World Sep14 clonedb
OakTable World Sep14 clonedb Connor McDonald
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Kyle Hailey
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersConnor McDonald
 
Oracle 10g Performance: chapter 00 sampling
Oracle 10g Performance: chapter 00 samplingOracle 10g Performance: chapter 00 sampling
Oracle 10g Performance: chapter 00 samplingKyle Hailey
 
UKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction LocksUKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction LocksKyle Hailey
 
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTroubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTanel Poder
 
Lightweight Transactions at Lightning Speed
Lightweight Transactions at Lightning SpeedLightweight Transactions at Lightning Speed
Lightweight Transactions at Lightning SpeedScyllaDB
 
MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527Saewoong Lee
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersKyle Hailey
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and ArchitectureSidney Chen
 
DRP for Big Data - Stream Processing Architectures
DRP for Big Data - Stream Processing ArchitecturesDRP for Big Data - Stream Processing Architectures
DRP for Big Data - Stream Processing ArchitecturesMohamed Mehdi Ben Aissa
 
Oracle数据库日志满导致错误
Oracle数据库日志满导致错误Oracle数据库日志满导致错误
Oracle数据库日志满导致错误Zianed Hou
 

Similar to MySQL 5.5 Guide to InnoDB Status (20)

11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
 
Oracle Diagnostics : Locks and Lock Trees
Oracle Diagnostics :  Locks and Lock TreesOracle Diagnostics :  Locks and Lock Trees
Oracle Diagnostics : Locks and Lock Trees
 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
 
OakTable World Sep14 clonedb
OakTable World Sep14 clonedb OakTable World Sep14 clonedb
OakTable World Sep14 clonedb
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
 
Flashback ITOUG
Flashback ITOUGFlashback ITOUG
Flashback ITOUG
 
Oracle 10g Performance: chapter 00 sampling
Oracle 10g Performance: chapter 00 samplingOracle 10g Performance: chapter 00 sampling
Oracle 10g Performance: chapter 00 sampling
 
UKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction LocksUKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction Locks
 
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTroubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
 
Lightweight Transactions at Lightning Speed
Lightweight Transactions at Lightning SpeedLightweight Transactions at Lightning Speed
Lightweight Transactions at Lightning Speed
 
MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and Architecture
 
Operation outbreak
Operation outbreakOperation outbreak
Operation outbreak
 
DRP for Big Data - Stream Processing Architectures
DRP for Big Data - Stream Processing ArchitecturesDRP for Big Data - Stream Processing Architectures
DRP for Big Data - Stream Processing Architectures
 
Rac 12c optimization
Rac 12c optimizationRac 12c optimization
Rac 12c optimization
 
Oracle数据库日志满导致错误
Oracle数据库日志满导致错误Oracle数据库日志满导致错误
Oracle数据库日志满导致错误
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

MySQL 5.5 Guide to InnoDB Status

  • 1. MySQL 5.5 Guide to InnoDB Status Bill Karwin, Percona Inc.
  • 2. Me • Software developer • C, Java, Perl, PHP, Ruby • SQL maven • MySQL Consultant at Percona • Author of SQL Antipatterns: Avoiding the Pitfalls of Database Programming Bill Karwin www.percona.com
  • 3. MyISAM or InnoDB? • MyISAM can store more compactly • MyISAM supports FULLTEXT indexes • MyISAM uses primary keys and secondary keys in the same way BUT... • MyISAM does not support transactions • MyISAM allows updates to write non-atomically • MyISAM is susceptible to corruption on crashes • MyISAM relies on filesystem cache www.percona.com
  • 4. InnoDB Plugin 1.0 • Enable in /etc/my.cnf: [mysqld] ignore-builtin-innodb plugin-load=innodb=ha_innodb_plugin.so • Verify InnoDB plugin is enabled: mysql> SHOW PLUGINS; +------------+----------+----------------+---------------------+---------+ | Name | Status | Type | Library | License | +------------+----------+----------------+---------------------+---------+ | InnoDB | ACTIVE | STORAGE ENGINE | ha_innodb_plugin.so | GPL | +------------+----------+----------------+---------------------+---------+ www.percona.com
  • 5. InnoDB Plugin 1.1 • Not necessary to enable InnoDB Plugin 1.1 • Default storage engine in MySQL 5.5 www.percona.com
  • 6. How to Show InnoDB Status mysql> SHOW ENGINE INNODB STATUS G required keyword in 5.5 output without long table borders www.percona.com
  • 7. ===================================== INNODB MONITOR OUTPUT ===================================== ===================================== 111001 19:29:44 INNODB MONITOR OUTPUT ===================================== Per second averages calculated from the last 23 seconds if this is less than 20-30 seconds, statistics may be inaccurate. run this command again. www.percona.com
  • 8. InnoDB Monitor Sections • Background Thread • Semaphores • Latest Foreign Key Error • Latest Detect Deadlock • File I/O • Insert Buffer and Adaptive Hash Index • Log • Buffer Pool and Memory • Row Operations • Transactions www.percona.com
  • 9. ----------------- BACKGROUND THREAD ----------------- srv_master_thread loops: 11938931 1_second, 11935492 sleeps, 1193884 10_second, 365 background, 365 flush srv_master_thread log flush and writes: 12087852 statistics about InnoDB main thread www.percona.com
  • 10. ---------- SEMAPHORES ---------- OS WAIT ARRAY INFO: reservation count 43659756, signal count 371748016 --Thread 1276582208 has waited at log/log0log.c line 1393 for 0.0000 seconds the semaphore: Mutex at 0x2ab19a048de8 '&log_sys->mutex', lock var 1 waiters flag 1 contention on InnoDB log file. problems in I/O? Mutex spin waits 919370636, rounds 1883832361, OS waits 21271702 RW-shared spins 104920102, OS waits 11414698; RW-excl spins 139844907, OS waits 9956101 Spin rounds per wait: 2.05 mutex, 4.42 RW-shared, 6.16 RW-excl statistics about mutexes. high OS waits indicates lots of contention www.percona.com
  • 11. ------------------------ LATEST FOREIGN KEY ERROR ------------------------ 030709 13:00:59 Transaction: TRANSACTION 0 290328284, ACTIVE 0 sec, process no 3195, OS thread id 34831 inserting 15 lock struct(s), heap size 2496, undo log entries 9 these values failed MySQL thread id 25, query id 4668733 localhost heikki update insert into ibtest11a (D, B, C) values (5, 'khDk' ,'khDk') Foreign key constraint fails for table test/ibtest11a: CONSTRAINT `0_219242` FOREIGN KEY (`A`, `D`) REFERENCES `ibtest11b` (`A`,`D`) ON DELETE CASCADE ON UPDATE CASCADE Trying to add in child table, in index PRIMARY tuple: 0: len 4; hex 80000101; asc ....;; 1: len 4; hex 80000005; asc ....;; 2: len 4; hex 6b68446b; asc khDk;; 3: len 6; hex 0000114e0edc; asc ...N..;; 4: len 7; hex 00000000c3e0a7; asc .......;; 5: len 4; hex 6b68446b; asc khDk;; But in parent table test/ibtest11b, in index PRIMARY, the closest match we can find is record: because no match RECORD: info bits 0 0: len 4; hex 8000015b; asc ...[;; 1: len 4; hex 80000005; asc ....;; 2: len 3; hex 6b6864; asc khd;; 3: len 6; hex 0000111ef3eb; asc ......;; 4: len 7; hex 800001001e0084; asc .......;; 5: len 3; hex 6b6864; asc khd;; www.percona.com
  • 12. ------------------------ LATEST DETECTED DEADLOCK ------------------------ Transaction 1 Transaction 2 UPDATE gets X lock X SELECT JOIN S? X? requests S lock, waits for T2... package_ package object_x_ article UPDATE requests X lock, waits for T1... * DEADLOCK! * www.percona.com
  • 13. ------------------------ LATEST DETECTED DEADLOCK (1 of 5) ------------------------ 110919 8:08:12 *** (1) TRANSACTION: TRANSACTION A4BA03E, ACTIVE 10 sec, process no 17229, OS thread id 1357232448 starting index read mysql tables in use 3, locked 3 waiting LOCK WAIT 288 lock struct(s), heap size 47544, 4025 row lock(s), undo log entries 45046 MySQL thread id 959109, query id 171532998 192.168.30.61 ads Copying to tmp table INSERT INTO ad_article_conflicts (article_id, object_id, object_type, created_dts, proc_id, conflict_count, country) SELECT distinct article_id, package.orig_package_id, 'package', now(), 1316437206, 1,'US' FROM package_object_x_article, package WHERE package_object_x_article.object_id = package.package_id AND package_object_x_article.object_type= 'package' AND package.package_id IN (...) needs S locks www.percona.com
  • 14. ------------------------ LATEST DETECTED DEADLOCK (2 of 5) ------------------------ *** (1) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 102 page no 1784 n bits 1192 index `object_id_object_type` of table `ads`.`package_object_x_article` trx id A4BA03E lock mode S waiting Record lock, heap no 13 PHYSICAL RECORD: n_fields 3; compact format; info bits 32 0: len 4; hex 0000060f; asc ;; 1: len 1; hex 01; asc ;; 2: len 4; hex 00000001; asc ;; waiting for S lock on this table already got the S lock on the other table `package` www.percona.com
  • 15. ------------------------ LATEST DETECTED DEADLOCK (3 of 5) ------------------------ *** (2) TRANSACTION: TRANSACTION A4B9F50, ACTIVE 11 sec, process no 17229, OS thread id 1274140992 starting index read mysql tables in use 1, locked 1 waiting 984 lock struct(s), heap size 145848, 1115 row lock(s), undo log entries 2221 MySQL thread id 959226, query id 171538155 192.168.30.150 ads Updating UPDATE package SET live_dts = '2011-09-16 19:00:00', section_type = 'exampleradio', display_type = 'old_style', expiration_dts = '2011-09-20 00:00:00', title = 'Example Radio', package_type = 'with_landing', content_source = NULL WHERE package . . . needs X lock on `package` www.percona.com
  • 16. ------------------------ LATEST DETECTED DEADLOCK (4 of 5) ------------------------ *** (2) HOLDS THE LOCK(S): RECORD LOCKS space id 102 page no 1784 n bits 1192 index `object_id_object_type` of table `ads`.`package_object_x_article` trx id A4B9F50 lock_mode X locks rec but not gap Record lock, heap no 13 PHYSICAL RECORD: n_fields 3; compact format; info bits 32 0: len 4; hex 0000060f; asc ;; 1: len 1; hex 01; asc ;; holds X lock on one table 2: len 4; hex 00000001; asc ;; *** (2) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 305 page no 74 n bits 104 index `PRIMARY` of table `ads`.`package` trx id A4B9F50 lock_mode X locks rec but not gap waiting Record lock, heap no 7 PHYSICAL RECORD: n_fields 50; compact format; info bits 0 waiting for X lock on other table `package` www.percona.com
  • 17. ------------------------ LATEST DETECTED DEADLOCK (5 of 5) ------------------------ *** WE ROLL BACK TRANSACTION (2) why this transaction? because it judges transaction 2 has modified fewer rows www.percona.com
  • 18. -------- FILE I/O (1 of 2) -------- I/O thread 0 state: waiting for i/o request (insert buffer thread) I/O thread 1 state: waiting for i/o request (log thread) I/O thread 2 state: waiting for i/o request (read thread) I/O thread 3 state: waiting for i/o request (read thread) I/O thread 4 state: waiting for i/o request (read thread) I/O thread 5 state: waiting for i/o request (read thread) I/O thread 6 state: waiting for i/o request (write thread) I/O thread 7 state: waiting for i/o request (write thread) I/O thread 8 state: waiting for i/o request (write thread) I/O thread 9 state: waiting for i/o request (write thread) if these are busy, you can increase innodb_read_io_threads, innodb_write_io_threads www.percona.com
  • 19. -------- FILE I/O (2 of 2) -------- Pending normal aio reads: 0, aio writes: 0, ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0 Pending flushes (fsync) log: 0; buffer pool: 0 907300503 OS file reads, 570173314 OS file writes, 440124224 OS fsyncs 2 pending preads, 0 pending pwrites 1182.86 reads/s, 16384 avg bytes/read, 37.52 writes/s, 31.87 fsyncs/s these are all zero, but high numbers indicate you are I/O bound www.percona.com
  • 20. ------------------------------------- INSERT BUFFER AND ADAPTIVE HASH INDEX ------------------------------------- Ibuf: size 1, free list len 5, seg size 7, 8146267 inserts, 8146267 merged recs, 1054076 merges ratio of insert buffer efficiency Hash table size 55249463, node heap has 990 buffer(s) 25018.43 hash searches/s, 12373.20 non-hash searches/s ratio of hash lookups done in lieu of B-tree lookups www.percona.com
  • 21. The Buffer Pool www.percona.com
  • 22. The Buffer Pool • All reads/writes use the buffer pool • SQL reads from the buffer pool many times disk read ~100ns ~10,000,000ns memory access disk seek www.percona.com
  • 23. The Buffer Pool • The buffer pool is the best use of system memory. OS needs ~2GB MySQL needs 2 to 4GB allocate the rest to the InnoDB buffer pool http://www.mysqlperformanceblog.com/2007/11/03/choosing-innodb_buffer_pool_size/ www.percona.com
  • 24. The Buffer Pool • Random writes to disk are very slow. www.percona.com
  • 25. The Buffer Pool • Instead, keep “dirty” pages in buffer pool, to be written down later X • But what happens to dirty pages in a crash? www.percona.com
  • 26. The Log File Simon Law www.percona.com
  • 27. The Log File • Sequential writes to log are much quicker. X www.percona.com
  • 28. The Log File • Many dirty pages can be recorded in the log file. X X X www.percona.com
  • 29. The Log File • As log file fills up, pressure rises to write down dirty pages. X X X • This is called a log checkpoint. www.percona.com
  • 30. The Log File • As pages are written down, they no longer dirty. • Checkpointing frees up space in the log. www.percona.com
  • 31. The Log File • Pressure to checkpoint rises because: - The log files have a fixed size. - The log files contain “redo” information to replay changes for all dirty pages in case of crash. - If log files are getting full, InnoDB throttles incoming INSERT/UPDATE/DELETE. http://www.mysqlperformanceblog.com/2011/04/04/innodb-flushing-theory-and-solutions/ www.percona.com
  • 32. The Log File • 1 hour’s worth of changes is a good log file size. 30 minutes 30 minutes X X X http://www.mysqlperformanceblog.com/2008/11/21/how-to-calculate-a-good-innodb-log-file-size/ www.percona.com
  • 33. --- LOG --- Log sequence number 16557482601459 Log flushed up to 16557473340329 bytes written to log Last checkpoint at 16557036774612 1 pending log writes, 0 pending chkp writes 429764749 log i/o's done, 28.82 log i/o's/second ...15 minutes later... LSN is 12MB higher. 4 × 12M = 48MB/hour Log sequence number 16557494601459 • innodb_log_file_size = 24M because there are two log files by default www.percona.com
  • 34. The Log File • Not all dirty pages are written at every checkpoint. X X • How many pages are written? Depends... www.percona.com
  • 35. IO Capacity Shyaulis Andrjus www.percona.com
  • 36. IO Capacity • Faster disks can handle greater write load. X www.percona.com
  • 37. IO Capacity • Tuning innodb_io_capacity - Default is 200, good for a single 7200rpm disk. - Match the IOPS your disk system can sustain. - Not unusual to see 800-1000 for RAID system. - Not unusual to see 2000-4000 for SSD system. www.percona.com
  • 38. --- LOG (extra info from Percona Server) --- Log sequence number 16557482601459 Log flushed up to 16557473340329 Last checkpoint at 16557036774612 Max checkpoint age 677822424 Checkpoint age target 656640474 Modified age 436863883 Checkpoint age 445826847 1 pending log writes, 0 pending chkp writes 429764749 log i/o's done, 28.82 log i/o's/second www.percona.com
  • 39. ---------------------- BUFFER POOL AND MEMORY (1 of 3) ---------------------- Total memory allocated 28626124800; in additional pool allocated 0 Internal hash tables (constant factor + variable factor) Adaptive hash index 458220080 ! (441995704 + 16224376) Page hash 27625592 Dictionary cache 403718221 ! (110500528 + 293217693) File system 83536 ! (82672 + 864) Lock system 71993872 ! (71910152 + 83720) Recovery system 0 ! 0 + 0) ( Threads 409288 ! (406936 + 2352) www.percona.com
  • 40. ---------------------- BUFFER POOL AND MEMORY (2 of 3) ---------------------- Dictionary memory allocated 293217693 Buffer pool size 1703935 Buffer pool size, bytes 27917271040 Free buffers 0 Database pages 1702944 Old database pages 628605 Modified db pages 29305 Pending reads 1 Pending writes: LRU 0, flush list 0, single page 0 Pages made young 1251203063, not young 0 1194.38 youngs/s, 0.00 non-youngs/s www.percona.com
  • 41. ---------------------- BUFFER POOL AND MEMORY (3 of 3) ---------------------- Pages read 1222502280, created 49476044, written 260566544 1184.30 reads/s, 61.52 creates/s, 116.82 writes/s Buffer pool hit rate 991 / 1000, young-making rate 9 / 1000 not 0 / 1000 Pages read ahead 0.00/s, evicted without access 0.09/s LRU len: 1702944, unzip_LRU len: 0 I/O sum[70075]:cur[288], unzip sum[0]:cur[0] www.percona.com
  • 42. -------------- ROW OPERATIONS -------------- 3 queries inside InnoDB, 0 queries in queue 13 read views open inside InnoDB Main thread process no. 7741, id 1211353408, state: sleeping Number of rows inserted 2832396721, updated 5386467044, deleted 427453434, read 166901591413 2008.17 inserts/s, 172.43 updates/s, 2.22 deletes/s, 4403.94 reads/s www.percona.com
  • 43. ------------ TRANSACTIONS ------------ Trx id counter 1FE1D5398 Purge done for trx's n:o < 1FE1D4F1D undo n:o < 0 History list length 240 LIST OF TRANSACTIONS FOR EACH SESSION: keeping old row versions ---TRANSACTION 1FE1D5334, not started, process no 7741, OS thread id 1268595008 flushing log MySQL thread id 116454235, query id 10469901493 10.80.1.110 c_106 COMMIT trying to flush to log on COMMIT www.percona.com
  • 44. END ---------------------------- END OF INNODB MONITOR OUTPUT ============================ www.percona.com
  • 45. Best Tuning Parameters • innodb_buffer_pool_size - As much as you can spare after OS and MySQL. • innodb_log_file_size - At least enough for 60 minutes of log writes. • innodb_io_capacity - Based on your disk IOPS. www.percona.com
  • 46. SQL Antipatterns 20% discount code: ZendConSQL (until 10/28/2011) http://www.pragprog.com/titles/bksqla/ www.percona.com