+ All Categories
Home > Documents > MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL...

MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL...

Date post: 21-Apr-2020
Category:
Upload: others
View: 7 times
Download: 0 times
Share this document with a friend
46
MYSQL 5.6 Online Operations and Improved Diagnostics Tuesday, 20 August, 13
Transcript
Page 1: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

MYSQL 5.6Online Operations and Improved Diagnostics

Tuesday, 20 August, 13

Page 2: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

ABOUT ME

1998 2013

Web designerDeveloper (PHP)DBAArchitect/Devops

Tuesday, 20 August, 13

Page 3: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

MYSQL RELEASES IN HISTORY

• MySQL 5.0 - October 2005

• Many New Features (Triggers, SPs, Views)• Officially acknowledged as too buggy / a

bad release• MySQL 5.1 - November 2008

• Delayed by 5.0 bug fixing distractions• Row based replication• Partitioning

• MySQL 6.0 - Canceled

• Falcon Storage Engine as default• Some features reimplemented in 5.6

• MySQL 5.5 - December 2010

• “The InnoDB Release”• Performance_schema• Semi-sync replication• 4 byte UTF8

• MySQL 5.6 - February 2013

• Many new features (Server and InnoDB)• MySQL 5.7

• TBA

Tuesday, 20 August, 13

Page 4: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

NEW FEATURES IN 5.6

http://www.mysqlperformanceblog.com/2013/01/27/mysql-5-6-improvements-in-the-nutshell/

Scalable Read Only Transactions Improvement to Buffer Pool Flushing Precise spatial operations in GISConcurrent Innodb data file extension Subquery Optimizations Password hashes instead of plain passwords in Query LogsNon-Recursive Deadlock Detection More efficient Optimizer SHA256 hashing with Salt for Authentication

Faster Locking Primitives Optimized ROW Based Replication Use obfuscated password storage for command line toolsImproved Innodb Thread Concurrency Multi-Threaded Slave Policy Based password validation

Multiple background Purge Threads Global Transaction Identifiers Plugin authentication support for ReplicationImproved Purge lag control (now works) Crash Safe Slave and Binlog INNODB_METRICS (I_S)

Split of “Kernel Mutex” Replication Event Checksums Meta Data Information Tables (I_S)Data Dictionary Cache Time Delayed Replication Buffer Pool Information Tables (I_S)

Improved Adaptive Flushing Server UUID Reduced Overhead (PS)Page Cleaner/Separate Flush Thread Improved Logging for Row based Replication Simplified Configuration (PS)

Group Commit for Binary Log Replication Utilities for Failover and Admin Table Access instrumentation (PS)Fight Cache Coherence and False Sharing issues Separate Tablespaces for Innodb Undo Logs Statements instrumentation (PS)

Reduced Innodb Memory Fragmentation Fast Restart – Preloading Innodb Buffer Pool Stages Instrumentation (PS)Reduced Locking for Partitioned tables Online DDL Aggregations by User, Host etc (PS)Reduced Contention for LOCK_open Import/Export for Partitioned Tables Network IO Instrumentation (PS)

Support for multiple table_open_cache instances Remote Binlog Backup Show Host Cache Contents (PS)Large (over 4GB) redo logs support Innodb Transportable Tablespaces Improved File I/O Instrumentation (PS)

Index Condition pushdown (ICP) New configuration files defaults Explain for UPDATE/DELETE queriesMulti-Range-Read (MRR) User Defined DATA DIRECTORY for Innodb Tables JSON output with more information

Faster ORDER BY nidxcol LIMIT N Connection Attributes Optimizer TracingPersistent Statistics for Innodb MemcacheD API in Innodb Deadlock Logging

Improvements to Innodb Compression Explicit Partition Selection in queries GET DIAGNOSTICSFast Page Checksums (CRC32) Full Text Search index for Innodb4K and 8K Page sizes for Innodb Microsecond TIME precision

Tuesday, 20 August, 13

Page 5: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

BY LINES OF CODE

“MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time we saw anything like this was with the merging of MySQL Cluster in 4.1. At the very least, Oracle is paying people to write lines of code to extent that nobody has before.” - Stewart Smith

https://www.flamingspork.com/blog/2013/03/05/mysql-code-size/Tuesday, 20 August, 13

Page 6: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

MOST PUBLICIZED FEATURES

• Improved Replication

• GTIDs, checksums, parallel slaves, optimized row images, delayed slaves, crash safety, informational log events...

• Performance Enhancements

• Kernel mutex split, tablecache mutex split, group commit improved, read only transactions, statistics, optimizer...

• Memcached API

• MySQL speaks memcached protocol.

• Fulltext for InnoDB

• Addresses common limitation preventing MyISAM->InnoDB migrations.

• Not as full-featured as Sphinx or Lucene.

Tuesday, 20 August, 13

Page 7: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

FOCUS TODAY:

IT’S EASIER TO RUN IN PRODUCTION.

Tuesday, 20 August, 13

Page 8: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

WHICH IS...

http://www.mysqlperformanceblog.com/2013/01/27/mysql-5-6-improvements-in-the-nutshell/

Scalable Read Only Transactions Improvement to Buffer Pool Flushing Precise spatial operations in GISConcurrent Innodb data file extension Subquery Optimizations Password hashes instead of plain passwords in Query LogsNon-Recursive Deadlock Detection More efficient Optimizer SHA256 hashing with Salt for Authentication

Faster Locking Primitives Optimized ROW Based Replication Use obfuscated password storage for command line toolsImproved Innodb Thread Concurrency Multi-Threaded Slave Policy Based password validation

Multiple background Purge Threads Global Transaction Identifiers Plugin authentication support for ReplicationImproved Purge lag control (now works) Crash Safe Slave and Binlog INNODB_METRICS (I_S)

Split of “Kernel Mutex” Replication Event Checksums Meta Data Information Tables (I_S)

Data Dictionary Cache Time Delayed Replication Buffer Pool Information Tables (I_S)

Improved Adaptive Flushing Server UUID Reduced Overhead (PS)

Page Cleaner/Separate Flush Thread Improved Logging for Row based Replication Simplified Configuration (PS)

Group Commit for Binary Log Replication Utilities for Failover and Admin Table Access instrumentation (PS)

Fight Cache Coherence and False Sharing issues Separate Tablespaces for Innodb Undo Logs Statements instrumentation (PS)

Reduced Innodb Memory Fragmentation Fast Restart – Preloading Innodb Buffer Pool Stages Instrumentation (PS)

Reduced Locking for Partitioned tables Online DDL Aggregations by User, Host etc (PS)

Reduced Contention for LOCK_open Import/Export for Partitioned Tables Network IO Instrumentation (PS)

Support for multiple table_open_cache instances Remote Binlog Backup Show Host Cache Contents (PS)

Large (over 4GB) redo logs support Innodb Transportable Tablespaces Improved File I/O Instrumentation (PS)

Index Condition pushdown (ICP) New configuration files defaults Explain for UPDATE/DELETE queries

Multi-Range-Read (MRR) User Defined DATA DIRECTORY for Innodb Tables JSON output with more information

Faster ORDER BY nidxcol LIMIT N Connection Attributes Optimizer Tracing

Persistent Statistics for Innodb MemcacheD API in Innodb Deadlock Logging

Improvements to Innodb Compression Explicit Partition Selection in queries GET DIAGNOSTICSFast Page Checksums (CRC32) Full Text Search index for Innodb4K and 8K Page sizes for Innodb Microsecond TIME precision

Tuesday, 20 August, 13

Page 9: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

OPERATIONAL ENHANCEMENTS

Tuesday, 20 August, 13

Page 10: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

INNODB ONLINE DDL

•MySQL 5.0 (and below): All DDL requires the table to be recreated, along with all indexes.

•MySQL 5.1: Fast Alter table added. Some changes to ENUMs/SETs and extending varchars is online.

•MySQL 5.5: Fast index creation added. Adding indexes changes to SHARED lock, dropping indexes immediate*

* Unless UTF-8 :(Tuesday, 20 August, 13

Page 11: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

Operation In-Place? Copies Table? Allows Concurrent DML?

Allows Concurrent Query?

CREATE INDEX,ADD INDEX

ADD FULLTEXT INDEX

DROP INDEX

Set default value for a column

Change auto-increment value for a column

Add a foreign key constraint

Drop a foreign key constraint

Rename a column

Add a column

Drop a column

Reorder columns

Change ROW_FORMAT property

Change KEY_BLOCK_SIZE property

Make column NULL

Make column NOT NULL

Change data type of column

Add primary key

Drop primary key and add another

Drop primary key

Convert character set

Specify character set

Rebuild with FORCE option

Yes* No* Yes YesYes No* No YesYes No Yes YesYes No Yes YesYes No Yes YesYes* No* Yes YesYes No Yes YesYes* No* Yes* YesYes Yes Yes* YesYes Yes Yes YesYes Yes Yes YesYes Yes Yes YesYes Yes Yes YesYes Yes Yes YesYes* Yes Yes YesNo Yes No YesYes* Yes Yes YesYes Yes Yes YesNo Yes No YesNo Yes No YesNo Yes No YesNo Yes No Yes

Notes explained at:http://dev.mysql.com/doc/refman/5.6/en/innodb-create-index-overview.html

MyS

QL

5.6 O

nline

DD

L

Tuesday, 20 August, 13

Page 12: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

INNODB ONLINE DDL (CONT.)

• Also supports additional syntax ALTER TABLE my_table LOCK=NONE ALGORITHM=INPLACE;

Tuesday, 20 August, 13

Page 13: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

BUFFER POOL DUMP AND RESTORE

• Automatic cache priming feature.

• Important for big buffer pools, high throughput OLTP systems with good memory fit:

•innodb_buffer_pool_load_at_startup = 1

•innodb_buffer_pool_dump_at_shutdown = 1

http://www.tocker.ca/2013/05/03/when-does-MySQL-data-get-loaded-in-and-out-of-cache.htmlTuesday, 20 August, 13

Page 14: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

IMPORT/EXPORT PARTITIONED TABLES

• Swap partitions with regular tables:

ALTER TABLE pt EXCHANGE PARTITION p WITH TABLE t;

• I use partitioning a lot more than I thought I would for aging out data.

Tuesday, 20 August, 13

Page 15: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

TRANSPORTABLE TABLESPACES

• InnoDB data can be copied to a different server without using mysqldump.

• Syntax is to FLUSH TABLES tableName FOR EXPORT; then ALTER TABLE tableName IMPORT TABLESPACE; on destination side.

http://dev.mysql.com/doc/refman/5.6/en/tablespace-copying.htmlTuesday, 20 August, 13

Page 16: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

“OTHER STUFF”

• InnoDB not complaining when innodb_log_file_size has changed between restarts:

• Some of the items I said I wouldn’t talk about are useful:

• GTIDs + Crash safe slaves.•Multi-threaded slaves.

2013-08-18 20:49:29 17883 [Warning] InnoDB: Resizing redo log from 2*3072 to 2*8192 pages, LSN=59800912013-08-18 20:49:29 17883 [Warning] InnoDB: Starting to delete and rewrite log files.2013-08-18 20:49:29 17883 [Note] InnoDB: Setting log file ./ib_logfile101 size to 128 MBInnoDB: Progress in MB: 1002013-08-18 20:49:30 17883 [Note] InnoDB: Setting log file ./ib_logfile1 size to 128 MBInnoDB: Progress in MB: 1002013-08-18 20:49:30 17883 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

Tuesday, 20 August, 13

Page 17: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

DIAGNOSTIC ENHANCEMENTS

Tuesday, 20 August, 13

Page 18: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

EXPLAIN

Tuesday, 20 August, 13

Page 19: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

EXPLAIN

• Explain for UPDATE/DELETE

• Format=JSON

• Parseable, includes additional output.

Tuesday, 20 August, 13

Page 20: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

PERFORMANCE SCHEMA

Tuesday, 20 August, 13

Page 21: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

THE “OLD WAY”

• SHOW GLOBAL STATUS + SHOW ENGINE INNODB STATUS tuning.

Tuesday, 20 August, 13

Page 22: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

RATIO VS RATE

• The tuning-primer scripts look at ratios over long periods of time.

• They need to model a rate (numberof cache misses per second).

• Best read in Cacti on 1 or 5 minute interval.

Tuesday, 20 August, 13

Page 23: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

NOT INSTRUMENTED TO A USEABLE DETAIL

•With SHOW GLOBAL STATUS, you can see a ratio of Temp tables in memory versus Temp tables on disk.

•OK, How many rows per temp table on disk?

• If it’s a couple, it might just be logical IO.

Tuesday, 20 August, 13

Page 24: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

DIFFICULT FOR TOOLING

• InnoDB status contains a lot of magic numbers. Tools like cacti-templates require light weight parsers just to be able to read the information:

------------TRANSACTIONS------------Trx id counter 0 290328385Purge done for trx's n:o < 0 290315608 undo n:o < 0 17History list length 20Total number of lock structs in row lock hash table 70LIST OF TRANSACTIONS FOR EACH SESSION:---TRANSACTION 0 0, not started, process no 3491MySQL thread id 32, query id 4668737 localhost heikkishow innodb status---TRANSACTION 0 290328384, ACTIVE 0 sec, process no 320538929 inserting1 lock struct(s), heap size 320MySQL thread id 29, query id 4668736 localhost heikki updateinsert into speedc values (1519229,1, 'hgjhjgghggjgjgjgjgjggjgjgjgjgjgggjgjgjlhhgghggggghhjhghgggggghjhghghghghghhhhghghghjhhjghjghjkghjghjghjghjfhjfh

Tuesday, 20 August, 13

Page 25: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

NOT QUERY-ORIENTED

•Q: So it looks like I’m creating temporary tables on disk, or loading pages from disk. Which queries are doing it?

Tuesday, 20 August, 13

Page 26: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

NOT QUERY-ORIENTED

•Q: So it looks like I’m creating temporary tables on disk, or loading pages from disk. Which queries are doing it?

• A: <Crickets>

Tuesday, 20 August, 13

Page 27: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

NOT QUERY-ORIENTED

•Q: So it looks like I’m creating temporary tables on disk, or loading pages from disk. Which queries are doing it?

• A: <Crickets>

• (If I find the queries I can run SHOW PROFILE, but finding is the issue in MySQL releases.)

Tuesday, 20 August, 13

Page 28: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

THE “NEW WAY”

• Series of tables which represent internal state.

•With timing information :)

• Similar to “Oracle Wait Interface”.

Tuesday, 20 August, 13

Page 29: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

PERFORMANCE SCHEMA

• Allows you to monitor server events/stages of execution.

• Place “probes” at instrumentation points.

• P_S enabled by default in 5.6, and level of instrumentation can be changed dynamically to minimize impact.

• Focus is on low overhead/fast collection.

• Uses fixed memory, designed to be able to use in production.

Tuesday, 20 August, 13

Page 30: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

INTRODUCED IN 5.5

• Instrumented features which are mainly useful to developers:

• File I/O

• Mutexes

• RW Locks

• Did not yet include query level instrumentation :(

• Was not enabled by default.

Tuesday, 20 August, 13

Page 31: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

5.6 INTRODUCED...

• Network IO, Table IO, Stages of execution time.

• Brings number of instruments up to 545.

• Performance_schema is now 52 tables.

Tuesday, 20 August, 13

Page 32: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

accounts events_statements_summary_global_by_event_name rwlock_instances

cond_instances events_waits_current session_account_connect_attrs

events_stages_current events_waits_history session_connect_attrs

events_stages_history events_waits_history_long setup_actors

events_stages_history_long events_waits_summary_by_account_by_event_name setup_consumers

events_stages_summary_by_account_by_event_name events_waits_summary_by_host_by_event_name setup_instruments

events_stages_summary_by_host_by_event_name events_waits_summary_by_instance setup_objects

events_stages_summary_by_thread_by_event_name events_waits_summary_by_thread_by_event_name setup_timers

events_stages_summary_by_user_by_event_name events_waits_summary_by_user_by_event_name socket_instances

events_stages_summary_global_by_event_name events_waits_summary_global_by_event_name socket_summary_by_event_name

events_statements_current file_instances socket_summary_by_instance

events_statements_history file_summary_by_event_name table_io_waits_summary_by_index_usage

events_statements_history_long file_summary_by_instance table_io_waits_summary_by_table

events_statements_summary_by_account_by_event_name host_cache table_lock_waits_summary_by_table

events_statements_summary_by_digest hosts threads

events_statements_summary_by_host_by_event_name mutex_instances users

events_statements_summary_by_thread_by_event_name objects_summary_global_by_type

events_statements_summary_by_user_by_event_name performance_timers

Tuesday, 20 August, 13

Page 33: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

5.7 WILL INTRODUCE

• 5.7.1 already includes memory allocation information :D

• Likely more to come.

Tuesday, 20 August, 13

Page 34: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

EXAMPLES

•Mark Leithhttp://www.markleith.co.uk/ps_helper/

• Todd Farmerhttp://mysqlblog.fivefarmers.com

Tuesday, 20 August, 13

Page 35: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

PS_HELPER (MYSQL 5.6)Feature

View: statement_analysisView: statements_with_runtimes_in_95th_percentileView: statements_with_temp_tablesView: statements_with_sortingView: statements_with_full_table_scansView: statements_with_errors_or_warningsView: schema_table_statisticsView: schema_index_statisticsView: schema_unused_indexesView: schema_tables_with_full_table_scansProcedure: dump_thread_stack()Procedure: disable_current_thread()Procedure: enable_current_thread()Procedure: disable_background_threads()Procedure: enable_background_threads()Procedure: currently_enabled()Function: format_statement()

Tuesday, 20 August, 13

Page 36: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

PS_HELPER (MYSQL 5.5)Feature

View: latest_file_io

View: top_io_by_file

View: top_io_by_thread

View: top_global_consumers_by_avg_latency

View: top_global_consumers_by_total_latency

View: top_global_io_consumers_by_latency

View: top_global_io_consumers_by_bytes_usage

Procedure: only_enable()

Procedure: currently_enabled()

Function: format_bytes()

Function: format_time()

Function: format_path()

Function: extract_schema_from_file_name()

Function: extract_table_from_file_name()

Tuesday, 20 August, 13

Page 37: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

VIEW: STATEMENT_ANALYSISmysql> select * from statement_analysis where query IS NOT NULL limit 10;+-------------------------------------------------------------------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+--------------+----------------------------------+| query                                                             | full_scan | exec_count | err_count | warn_count | total_latency | max_latency | avg_latency | rows_sent | rows_sent_avg | rows_scanned | digest                           |+-------------------------------------------------------------------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+--------------+----------------------------------+| COMMIT                                                            |           |      14477 |         0 |          0 | 2.68 s        | 319.99 ms   | 185.07 µs   |         0 |             0 |            0 | 08467ba5a1c5748b32cd7518509ef9a9 || SELECT `maptimeser0_` . `id` A ...  `maptimeser0_` . `hash` = ?   |           |       2190 |         0 |          0 | 399.22 ms     | 12.85 ms    | 182.09 µs   |      2190 |             1 |         2190 | a39256afecc105bb49acb266134f00be || SELECT `environmen0_` . `hid`  ... 393_0_` , `environmen0_` . ... |           |        996 |         0 |          0 | 347.44 ms     | 8.91 ms     | 348.61 µs   |       996 |             1 |          996 | ecea708cfd3d0909be4dedf676798e56 || SELECT `mysqlserve0_` . `hid`  ... , `mysqlserve0_` . `os` AS ... | *         |       1080 |         0 |          0 | 337.56 ms     | 6.49 ms     | 312.53 µs   |      1572 |             1 |         1572 | e9eac5233c5cb73ecb2e336283da0f55 || SELECT `this_` . `instance_att ... his_` . `attribute_id` = ? )   |           |       1070 |         0 |          0 | 201.62 ms     | 2.01 ms     | 188.38 µs   |         2 |             0 |            2 | 971dc9b0e9a864b40b1218ecf00ec66d || SELECT `identityna0_` . `id` A ... RE `identityna0_` . `id` = ?   |           |       1074 |         0 |          0 | 158.70 ms     | 7.43 ms     | 147.66 µs   |         0 |             0 |            0 | 0c55d5168c602404fdcd414ced10e2ee || SELECT `mysqlserve2_` . `hid`  ... ` WHERE `agent0_` . `id` = ?   | *         |        518 |         0 |          0 | 143.75 ms     | 2.65 ms     | 277.43 µs   |      1036 |             2 |         2072 | 3a0b0da99b4faaceb4ce7ecea64cd2ed || SELECT `agent0_` . `hid` AS `h ... ventory` . `Agent` `agent0_`   | *         |        510 |         0 |          0 | 115.21 ms     | 3.50 ms     | 225.79 µs   |       510 |             1 |          510 | 0d705eeb9f631f35f08bb828a995e0b8 || SELECT `network_in2_` . `hid`  ... WHERE `network0_` . `id` = ?   |           |        522 |         0 |          0 | 98.86 ms      | 422.11 µs   | 189.37 µs   |       108 |             0 |          216 | dc23c65f7d6201455c9da09214ca8bc9 || SELECT `network0_` . `hid` AS  ... 21_394_0_` , `network0_` . ... |           |        522 |         0 |          0 | 89.75 ms      | 374.44 µs   | 171.82 µs   |       522 |             1 |          522 | 759bfff4b6c0155fe043a5ad38c4a9f0 |+-------------------------------------------------------------------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+--------------+----------------------------------+

mysql> select * from statement_analysis where query IS NOT NULL limit 10;+-------------------------------------------------------------------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+--------------+----------------------------------+| query                                                             | full_scan | exec_count | err_count | warn_count | total_latency | max_latency | avg_latency | rows_sent | rows_sent_avg | rows_scanned | digest                           |+-------------------------------------------------------------------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+--------------+----------------------------------+| COMMIT                                                            |           |      14477 |         0 |          0 | 2.68 s        | 319.99 ms   | 185.07 µs   |         0 |             0 |            0 | 08467ba5a1c5748b32cd7518509ef9a9 || SELECT `maptimeser0_` . `id` A ...  `maptimeser0_` . `hash` = ?   |           |       2190 |         0 |          0 | 399.22 ms     | 12.85 ms    | 182.09 µs   |      2190 |             1 |         2190 | a39256afecc105bb49acb266134f00be || SELECT `environmen0_` . `hid`  ... 393_0_` , `environmen0_` . ... |           |        996 |         0 |          0 | 347.44 ms     | 8.91 ms     | 348.61 µs   |       996 |             1 |          996 | ecea708cfd3d0909be4dedf676798e56 || SELECT `mysqlserve0_` . `hid`  ... , `mysqlserve0_` . `os` AS ... | *         |       1080 |         0 |          0 | 337.56 ms     | 6.49 ms     | 312.53 µs   |      1572 |             1 |         1572 | e9eac5233c5cb73ecb2e336283da0f55 || SELECT `this_` . `instance_att ... his_` . `attribute_id` = ? )   |           |       1070 |         0 |          0 | 201.62 ms     | 2.01 ms     | 188.38 µs   |         2 |             0 |            2 | 971dc9b0e9a864b40b1218ecf00ec66d || SELECT `identityna0_` . `id` A ... RE `identityna0_` . `id` = ?   |           |       1074 |         0 |          0 | 158.70 ms     | 7.43 ms     | 147.66 µs   |         0 |             0 |            0 | 0c55d5168c602404fdcd414ced10e2ee || SELECT `mysqlserve2_` . `hid`  ... ` WHERE `agent0_` . `id` = ?   | *         |        518 |         0 |          0 | 143.75 ms     | 2.65 ms     | 277.43 µs   |      1036 |             2 |         2072 | 3a0b0da99b4faaceb4ce7ecea64cd2ed || SELECT `agent0_` . `hid` AS `h ... ventory` . `Agent` `agent0_`   | *         |        510 |         0 |          0 | 115.21 ms     | 3.50 ms     | 225.79 µs   |       510 |             1 |          510 | 0d705eeb9f631f35f08bb828a995e0b8 || SELECT `network_in2_` . `hid`  ... WHERE `network0_` . `id` = ?   |           |        522 |         0 |          0 | 98.86 ms      | 422.11 µs   | 189.37 µs   |       108 |             0 |          216 | dc23c65f7d6201455c9da09214ca8bc9 || SELECT `network0_` . `hid` AS  ... 21_394_0_` , `network0_` . ... |           |        522 |         0 |          0 | 89.75 ms      | 374.44 µs   | 171.82 µs   |       522 |             1 |          522 | 759bfff4b6c0155fe043a5ad38c4a9f0 |+-------------------------------------------------------------------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+--------------+----------------------------------+

Tuesday, 20 August, 13

Page 38: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

HOW IDLE ARE YOUR CONNECTIONS?

http://mysqlblog.fivefarmers.com/2013/08/01/practical-p_s-how-idle-are-your-connections/

mysql> SELECT -> user, -> host, -> 100 * (SUM(IF(event_name = 'idle', sum_timer_wait, 0)) -> / SUM(sum_timer_wait)) pct_idle, -> ps_helper.format_time( -> SUM(IF(event_name = 'idle', sum_timer_wait, 0)) -> ) total_idle -> FROM events_waits_summary_by_account_by_event_name -> WHERE host IS NOT NULL -> GROUP BY user, host;+---------+-----------------------------+----------+---------------+| user | host | pct_idle | total_idle |+---------+-----------------------------+----------+---------------+| root | localhost | 99.9919 | 00:18:55.3054 || test_hc | TFARMER-MYSQL.wh.oracle.com | 100.0000 | 20.61 s |+---------+-----------------------------+----------+---------------+2 rows in set (0.02 sec)

Tuesday, 20 August, 13

Page 39: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

EXTENDING PROCESSLISTmysql> SELECT->   p.*,->   CASE->     WHEN PORT = 0 AND IP = '' THEN 'Unix Socket'->     WHEN IP REGEXP '^(::ffff:)?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' THEN 'IPv4'->     WHEN PORT > 0 THEN 'IPv6'->     ELSE 'Undetermined'->     END AS interface-> FROM performance_schema.socket_instances si->   RIGHT JOIN performance_schema.threads t->     ON (t.thread_id = si.thread_id)->   JOIN information_schema.processlist p->     ON (t.processlist_id = p.id)\G*************************** 1. row ***************************ID: 6USER: rootHOST: localhost:2873DB: performance_schemaCOMMAND: QueryTIME: 0STATE: executingINFO: SELECTp.*,CASEWHEN PORT = 0 AND IP = '' THEN 'Unix Socket'WHEN IP REGEXP '^(::ffff:)?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'THEN 'IPv4'WHEN PORT > 0 THEN 'IPv6'ELSE 'Undetermined'END AS interfaceFROM performance_schema.socket_instances siRIGHT JOIN performance_schema.threads tON (t.thread_id = si.thread_id)JOIN information_schema.processlist pON (t.processlist_id = p.id)interface: IPv61 row in set (0.13 sec)

Tuesday, 20 August, 13

Page 40: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

WHICH ACCOUNT FAILS TO CLOSE CONNECTIONS?

SELECT ess.USER, ess.HOST, (a.TOTAL_CONNECTIONS - a.CURRENT_CONNECTIONS) - ess.COUNT_STAR not_closed, ((a.TOTAL_CONNECTIONS - a.CURRENT_CONNECTIONS) - ess.COUNT_STAR) * 100 / (a.TOTAL_CONNECTIONS - a.CURRENT_CONNECTIONS) pct_not_closedFROM performance_schema.events_statements_summary_by_account_by_event_name ess JOIN performance_schema.accounts a ON (ess.USER = a.USER AND ess.HOST = a.HOST)WHERE ess.EVENT_NAME = 'statement/com/Quit' AND (a.TOTAL_CONNECTIONS - a.CURRENT_CONNECTIONS) > ess.COUNT_STAR;+------+-----------+------------+----------------+| USER | HOST | not_closed | pct_not_closed |+------+-----------+------------+----------------+| root | localhost | 4 | 44.4444 || ODBC | localhost | 1 | 100.0000 |+------+-----------+------------+----------------+2 rows in set (0.00 sec)

Tuesday, 20 August, 13

Page 41: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

INFORMATION SCHEMA

Tuesday, 20 August, 13

Page 42: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

INFORMATION SCHEMA TABLES (5.6)

INNODB_LOCKS INNODB_TRX INNODB_SYS_DATAFILES

INNODB_LOCK_WAITS INNODB_SYS_TABLESTATS INNODB_CMP

INNODB_METRICS INNODB_CMP_RESET INNODB_CMP_PER_INDEX

INNODB_CMPMEM_RESET INNODB_FT_DELETED INNODB_BUFFER_PAGE_LRU

INNODB_SYS_FOREIGN INNODB_SYS_COLUMNS INNODB_SYS_INDEXES

INNODB_FT_DEFAULT_STOPWORD INNODB_SYS_FIELDS INNODB_CMP_PER_INDEX_RESET

INNODB_BUFFER_PAGE INNODB_CMPMEM INNODB_FT_INDEX_TABLE

INNODB_FT_BEING_DELETED INNODB_SYS_TABLESPACES INNODB_FT_INDEX_CACHE

INNODB_SYS_FOREIGN_COLS INNODB_SYS_TABLES INNODB_BUFFER_POOL_STATS

INNODB_FT_CONFIG

Tuesday, 20 August, 13

Page 43: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

FIND WORKING SETmysql> call test.estimate_working_set(10, 30);+----------+| progress |+----------+| 1/30 |+----------+1 row in set (10.13 sec)

.. lines omitted for brevity .. +----------+| progress |+----------+| 30/30 |+----------+1 row in set (5 min 54.72 sec)

+----------------------+| pages_in_working_set |+----------------------+| 100679 |+----------------------+1 row in set (5 min 55.61 sec)

Query OK, 0 rows affected (5 min 55.71 sec)

100679/64 = 1573MB working set.

http://www.tocker.ca/2013/05/31/estimating-mysqls-working-set-with-information_schema.htmlTuesday, 20 August, 13

Page 44: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

FOREIGN KEY LOCKINGmysql> SELECT * FROM information_schema.innodb_locks\G*************************** 1. row ***************************    lock_id: 87035:1300:3:6lock_trx_id: 87035  lock_mode: X  lock_type: RECORD lock_table: `test`.`parent` lock_index: `PRIMARY` lock_space: 1300  lock_page: 3   lock_rec: 6  lock_data: 5*************************** 2. row ***************************    lock_id: 87034:1300:3:6lock_trx_id: 87034  lock_mode: S  lock_type: RECORD lock_table: `test`.`parent` lock_index: `PRIMARY` lock_space: 1300  lock_page: 3   lock_rec: 6  lock_data: 52 rows in set (0.00 sec)

http://www.mysqlperformanceblog.com/2010/09/20/instrumentation-and-the-cost-of-foreign-keys/Tuesday, 20 August, 13

Page 45: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

THE END

Tuesday, 20 August, 13

Page 46: MYSQL 5 - Meetupfiles.meetup.com/1799479/mysql-56-online-operations-and...BY LINES OF CODE “MySQL 5.6 is the largest MySQL code size increase in a MySQL version ever. The last time

NEW FEATURES

http://www.mysqlperformanceblog.com/2013/01/27/mysql-5-6-improvements-in-the-nutshell/

Scalable Read Only Transactions Improvement to Buffer Pool Flushing Precise spatial operations in GISConcurrent Innodb data file extension Subquery Optimizations Password hashes instead of plain passwords in Query LogsNon-Recursive Deadlock Detection More efficient Optimizer SHA256 hashing with Salt for Authentication

Faster Locking Primitives Optimized ROW Based Replication Use obfuscated password storage for command line toolsImproved Innodb Thread Concurrency Multi-Threaded Slave Policy Based password validation

Multiple background Purge Threads Global Transaction Identifiers Plugin authentication support for ReplicationImproved Purge lag control (now works) Crash Safe Slave and Binlog INNODB_METRICS (I_S)

Split of “Kernel Mutex” Replication Event Checksums Meta Data Information Tables (I_S)Data Dictionary Cache Time Delayed Replication Buffer Pool Information Tables (I_S)

Improved Adaptive Flushing Server UUID Reduced Overhead (PS)Page Cleaner/Separate Flush Thread Improved Logging for Row based Replication Simplified Configuration (PS)

Group Commit for Binary Log Replication Utilities for Failover and Admin Table Access instrumentation (PS)Fight Cache Coherence and False Sharing issues Separate Tablespaces for Innodb Undo Logs Statements instrumentation (PS)

Reduced Innodb Memory Fragmentation Fast Restart – Preloading Innodb Buffer Pool Stages Instrumentation (PS)Reduced Locking for Partitioned tables Online DDL Aggregations by User, Host etc (PS)Reduced Contention for LOCK_open Import/Export for Partitioned Tables Network IO Instrumentation (PS)

Support for multiple table_open_cache instances Remote Binlog Backup Show Host Cache Contents (PS)Large (over 4GB) redo logs support Innodb Transportable Tablespaces Improved File I/O Instrumentation (PS)

Index Condition pushdown (ICP) New configuration files defaults Explain for UPDATE/DELETE queriesMulti-Range-Read (MRR) User Defined DATA DIRECTORY for Innodb Tables JSON output with more information

Faster ORDER BY nidxcol LIMIT N Connection Attributes Optimizer TracingPersistent Statistics for Innodb MemcacheD API in Innodb Deadlock Logging

Improvements to Innodb Compression Explicit Partition Selection in queries GET DIAGNOSTICSFast Page Checksums (CRC32) Full Text Search index for Innodb4K and 8K Page sizes for Innodb Microsecond TIME precision

Tuesday, 20 August, 13


Recommended