SlideShare a Scribd company logo
1 of 141
Download to read offline
MySQL Performance for DevOps
October 26, 2020
Sveta Smirnova
• MySQL Support engineer
• Author of
• MySQL Troubleshooting
• JSON UDF functions
• FILTER clause for MySQL
• Speaker
• Percona Live, OOW, Fosdem,
DevConf, HighLoad...
Sveta Smirnova
2
•Introduction
•Hardware
Memory
Disk
CPU
Network
•Configuration
Important Options
•Query Tuning on the Server Side
Indexes
Optimizer Histograms
Optimizer Configuration
Table of Contents
3
Introduction
• Database server
• 25 years of history
• Popular forks
•
Percona Server for MySQL
•
MariaDB Server
• Replication support from the beginning
What is MySQL?
5
Connectors: C, JDBC, ODBC, Python, ...
Connection Pool: Authentication, Caches
SQL interface
Parser
Optimizer
Caches and Buffers:
Global
Engine-specific
Storage engines: InnoDB, MyRocks, ...
File system: Data, Index, logs, other files
•
mysqld and its files
•
Connectors
•
Optimizer
• Caches
• Storage Engines
• Management
MySQL Architecture
6
• Bare hardware
• Cloud
• Container-orchestration systems
Where MySQL Installed in 2020?
7
Percona Kubernetes Operator for PXC
MySQL Operator
MySQL Kubernetes Operators
8
Query
ConfigurationHardware
What Affects Performance?
9
Hardware
• Bare hardware
•
Operating system options
How to Tune?
11
• Bare hardware
•
Operating system options
•
Clouds
• Administrator console
How to Tune?
11
• Bare hardware
•
Operating system options
•
Clouds
• Administrator console
• Percona Kubernetes Operator for PXC
cr.yaml
pxc.resources.requests.memory
pxc.resources.requests.cpu
pxc.resources.limits.memory
pxc.volumeSpec.resources.requests.storage
How to Tune?
11
• Memory
• Disk
• CPU
•
Network
What to Tune?
12
Hardware
Memory
• No swapping: sysctl vm.swappiness=1
Memory Configuration
14
• No swapping: sysctl vm.swappiness=1
• NUMA interleave: enable in BIOS
Memory Configuration
14
• No swapping: sysctl vm.swappiness=1
• NUMA interleave: enable in BIOS
• More is better
Memory Configuration
14
• No swapping: sysctl vm.swappiness=1
• NUMA interleave: enable in BIOS
• More is better
•
Memory access is faster than disk access
Memory Configuration
14
• No swapping: sysctl vm.swappiness=1
• NUMA interleave: enable in BIOS
• More is better
•
Memory access is faster than disk access
•
Frequently accessed data should be in memory
Memory Configuration
14
• Global buffers
• Allocated up to the limit and freed at shutdown
InnoDB Buffer Pool Size
Performance Schema tables
How MySQL Uses Memory
15
• Global buffers
• Session buffers
•
Allocated when session starts
• Freed at the disconnect
Connection and result buffers: from net buffer length up to max allowed packet
How MySQL Uses Memory
15
• Global buffers
• Session buffers
• Operation-specific buffers
• Allocated for the operation life time
• Can be allocated multiple times
join buffer size: for each tables pair in JOIN
tmp table size: for each temporary table
How MySQL Uses Memory
15
Hardware
Disk
• Faster is better
•
SSD
• NVMe
• Spinning disk
Disk Configuration
17
• Faster is better
•
SSD
• NVMe
• Spinning disk
•
Parallel writes
Disk Configuration
17
• Faster is better
•
SSD
• NVMe
• Spinning disk
•
Parallel writes
•
Battery-backed cache
Disk Configuration
17
• Tables data
How MySQL Uses Disk
18
• Tables data
•
Log files
• Binary
• Storage engine
InnoDB redo log file
• Error, general, audit, ...
How MySQL Uses Disk
18
• Tables data
•
Log files
• Binary
• Storage engine
InnoDB redo log file
• Error, general, audit, ...
•
Disk-based temporary tables
How MySQL Uses Disk
18
• Tables data
•
Log files
• Binary
• Storage engine
InnoDB redo log file
• Error, general, audit, ...
•
Disk-based temporary tables
• You may put these on different disks
How MySQL Uses Disk
18
Hardware
CPU
•
IO scheduler [noop] or [deadline]
• sudo echo noop >
/sys/block/YOUR DISK/queue/scheduler
or sudo echo deadline >
/sys/block/YOUR DISK/queue/scheduler
CPU Configuration
20
•
IO scheduler [noop] or [deadline]
• sudo echo noop >
/sys/block/YOUR DISK/queue/scheduler
or sudo echo deadline >
/sys/block/YOUR DISK/queue/scheduler
•
CPU governor: set to performance
CPU Configuration
20
•
IO scheduler [noop] or [deadline]
• sudo echo noop >
/sys/block/YOUR DISK/queue/scheduler
or sudo echo deadline >
/sys/block/YOUR DISK/queue/scheduler
•
CPU governor: set to performance
•
More cores is better
CPU Configuration
20
• One thread per connection
•
CPU used only for active threads
How MySQL Uses CPU
21
• One thread per connection
•
CPU used only for active threads
• Background work by storage engines
How MySQL Uses CPU
21
Server
Storage Engine
Connection and Engine Threads
22
? <= CPU cores?
What Happens with Threads
23
? <= CPU cores?
Yes Executed simultaneously
What Happens with Threads
23
? <= CPU cores?
Yes Executed simultaneously
No Wait in a queue
What Happens with Threads
23
? <= CPU cores?
Yes Executed simultaneously
No Wait in a queue
? Does the disk support parallel write?
What Happens with Threads
23
? <= CPU cores?
Yes Executed simultaneously
No Wait in a queue
? Does the disk support parallel write?
Yes Write happens
What Happens with Threads
23
? <= CPU cores?
Yes Executed simultaneously
No Wait in a queue
? Does the disk support parallel write?
Yes Write happens
No Wait in a queue
What Happens with Threads
23
Hardware
Network
• As fast as possible
• Speed of the line
RTT
•
Bandwidth
• Stability
To avoid TCP packet re-submission
Network Configuration
25
• As fast as possible
• On the Internet connection
•
Clients can work
• Asynchronous replica will delay
• Synchronous clusters will be not functional
Node disconnects with default options
Very slow response times with adjusted configuration
Network Configuration
25
• Communication between server and client
•
Regular client
• Application
• Replication connection (IO) thread
•
Traffic between synchronous nodes
How MySQL Uses Network
26
Configuration
• Server options
•
Components
• Storage engines
InnoDB
•
Plugins
• Server
Binary logging
Optimizer
What can be Configured?
28
• Global
• Parameters, necessary for all server processes
Location of server files: datadir etc.
Shared buffers
More
•
Session
• Control connection-specific parameters
MySQL Option Tables
System Variables and Options: Scope
29
•
SET [GLOBAL|PERSIST] var = NEW VALUE
System Variables: How to Change
30
•
SET [GLOBAL|PERSIST] var = NEW VALUE
•
Command-line option: --var=new value
System Variables: How to Change
30
•
SET [GLOBAL|PERSIST] var = NEW VALUE
•
Command-line option: --var=new value
• Configuration file
In the default location
• Specified by option --defaults-file
[mysqld]
var=new_value
System Variables: How to Change
30
• PXC Operator Configuration
• In cr.yaml
spec:
secretsName: my-cluster-secrets
pxc:
...
configuration: |
[mysqld]
innodb_log_file_size=8G
System Variables: How to Change
30
• PXC Operator Configuration
• In ConfigMap
Create custom configuration file my.cnf
[mysqld]
innodb_log_file_size=8G
System Variables: How to Change
30
• PXC Operator Configuration
• In ConfigMap
Create custom configuration file my.cnf
[mysqld]
innodb_log_file_size=8G
Create ConfigMap: kubectl create configmap cluster1-pxc --from-file=my.cnf
System Variables: How to Change
30
• PXC Operator Configuration
• In ConfigMap
Create custom configuration file my.cnf
[mysqld]
innodb_log_file_size=8G
Create ConfigMap: kubectl create configmap cluster1-pxc --from-file=my.cnf
Restart PXC
System Variables: How to Change
30
• Global options and few session options
< 8.0 A user with privilege SUPER
8.0 + A user with privilege SYSTEM VARIABLES ADMIN
Dynamic Variables: Who Can Change
31
• Global options and few session options
< 8.0 A user with privilege SUPER
8.0 + A user with privilege SYSTEM VARIABLES ADMIN
• Session options
< 8.0 Anybody
8.0 + Restricted privileges
SYSTEM VARIABLES ADMIN
SESSION VARIABLES ADMIN
8.0 + Not restricted privileges: anybody
Dynamic Variables: Who Can Change
31
• Global options and few session options
< 8.0 A user with privilege SUPER
8.0 + A user with privilege SYSTEM VARIABLES ADMIN
• Session options
< 8.0 Anybody
8.0 + Restricted privileges
SYSTEM VARIABLES ADMIN
SESSION VARIABLES ADMIN
8.0 + Not restricted privileges: anybody
• There are no limits!
Dynamic Variables: Who Can Change
31
• Those which control behavior of whole server
• Once at server startup
• Can start with low values, then grow to specified
Buffers: When Allocated
32
• Those which control behavior of whole server
• Once at server startup
• Can start with low values, then grow to specified
• Connection options
•
For every connection when connection opens
Buffers: When Allocated
32
• Those which control behavior of whole server
• Once at server startup
• Can start with low values, then grow to specified
• Connection options
•
For every connection when connection opens
•
Operation-specific
• For every operation when needed
•
Can be allocated more than once
Buffers: When Allocated
32
Configuration
Important Options
•
innodb buffer pool size
• Ideally should hold active data set
InnoDB
34
•
innodb buffer pool size
• innodb log file size
• Should hold changes for an hour
InnoDB
34
•
innodb buffer pool size
• innodb log file size
• Should hold changes for an hour
• Too low
InnoDB
34
•
innodb buffer pool size
• innodb log file size
• Should hold changes for an hour
• Good
InnoDB
34
•
innodb buffer pool size
• innodb log file size
• innodb thread concurrency
• 0 or number of CPU cores
InnoDB
34
•
innodb buffer pool size
• innodb log file size
• innodb thread concurrency
• innodb io capacity
•
Default is too small for fast disks
• Up to number of IOPS your disk can handle
InnoDB
34
•
innodb buffer pool size
• innodb log file size
• innodb thread concurrency
• innodb io capacity
•
innodb flush method
•
In most cases: O DIRECT
•
Test on your filesystem!
InnoDB
34
• Changing these compromize durability!
Synchronization
35
• Changing these compromize durability!
• innodb flush log at trx commit
1: full ACID, default
Synchronization
35
• Changing these compromize durability!
• innodb flush log at trx commit
1: full ACID, default
2: logs written at each commit, flushed per second
MySQL can handle up to 1M INSERTs per second
Safe with PXC and InnoDB Cluster
Synchronization
35
• Changing these compromize durability!
• innodb flush log at trx commit
1: full ACID, default
2: logs written at each commit, flushed per second
0: logs are written and flushed once per second
Synchronization
35
• Changing these compromize durability!
• innodb flush log at trx commit
1: full ACID, default
2: logs written at each commit, flushed per second
0: logs are written and flushed once per second
• Once per second not guaranteed for 0 and 2
DDL can cause faster flushing
Scheduling may delay flushing
Synchronization
35
• Changing these compromize durability!
• innodb flush log at trx commit
• sync binlog
0: Synchronization handled by the system
1: At each transaction commit, default
No transaction lost
N: After N binary log group commits
In case of power or OS crash not flushed transactions can be lost
Synchronization
35
•
table open cache
• The number of open tables for all threads
•
Increase when
Connections in the PROCESSLIST are waiting for opening a table
Value of global status variable Opened tables is larger than Open tables
Table Handlers
36
•
table open cache
• table definition cache
• Size of the cache for table definitions
• Increase when
Value of Opened table definitions is larger than Open table definitions
Table Handlers
36
•
table open cache
• table definition cache
• Increase OS open files limit if needed
Table Handlers
36
Query Tuning on the Server Side
• You communicate with database using queries
•
Even via NoSQL interface
• They are not SQL queries, but still queries
Heart of the application
38
• You communicate with database using queries
•
Even via NoSQL interface
• They are not SQL queries, but still queries
• Data, which you request, matters
•
1,000,000,000 rows
vs 1 row
Heart of the application
38
Query sent
Connection Pool: Authentication, Caches; SQL interface; Parser
Optimizer
Storage engines
Hardware
Query execution workflow
39
• Selecting a lot of data
• SELECT * FROM many columns table
You May not Be Able to Change Slow Query
40
• Selecting a lot of data
• SELECT * FROM many columns table
• Badly written
•
LEFT JOIN instead of INNER JOIN
•
Many values in IN()
• Retrieving large result set, then discarding
•
Not effective SQL
For particular MySQL version
You May not Be Able to Change Slow Query
40
• Selecting a lot of data
• SELECT * FROM many columns table
• Badly written
•
LEFT JOIN instead of INNER JOIN
•
Many values in IN()
• Retrieving large result set, then discarding
•
Not effective SQL
For particular MySQL version
•
We still can improve performance
You May not Be Able to Change Slow Query
40
Query Tuning on the Server Side
Indexes
SELECT name FROM users SELECT name FROM users WHERE id=12
1 2 5 6 7 9 12 16 18 21 22 23 24 25
Full Table Scan
42
SELECT name FROM users SELECT name FROM users WHERE id=12
1 2 5 6 7 9 12 16 18 21 22 23 24 25
After Index Added
43
d001
d003
d008
d009
d003******
d009******
d008******
d009******
d001******
d003******
d009******
d008******
d009******
d001******
d008******
d008******
d001******
• B-Tree (Mostly)
• Fractal Tree
• LSM Tree
• R-Tree (Spatial)
• Hash (Memory SE)
• Engine-dependent
MySQL Indexes
44
• Single column
CREATE INDEX index name ON
the table(the column)
• Multiple columns
CREATE INDEX index name ON
the table(column1, column2)
How to Create an Index
45
• Single column
ALTER TABLE table name ADD INDEX
[index name] (the column)
• Multiple columns
ALTER TABLE table name ADD INDEX
[index name] (column1, column2)
How to Create an Index
45
•
WHERE the column = a value
• WHERE the column IN(value1, value2,
value3)
• WHERE the column LIKE ’value%’
• WHERE the column LIKE ’%value’
When MySQL Uses Indexes: Conditions
46
•
WHERE left part = value1 AND
right part = value2
• WHERE left part = value1 OR
right part = value2
• WHERE right part = value1 AND
left part = value2
•
WHERE right part = value1 OR left part =
value2
When MySQL Uses Indexes: Conditions
46
•
table1 JOIN table2 ON table1.column1
= table2.column2
When MySQL Uses Indexes: Joins
47
•
table1 JOIN table2 ON table1.column1
= table2.column2
• Same as FROM table1, table2 WHERE
table1.column1 = table2.column2
When MySQL Uses Indexes: Joins
47
•
GROUP BY the column
• GROUP BY left part, right part
• GROUP BY right part, left part
• GROUP BY the index, another index
When MySQL Uses Indexes: GROUP BY
48
•
ORDER BY the column
• ORDER BY left part, right part
• ORDER BY right part, left part
• ORDER BY the index, another index
When MySQL Uses Indexes: ORDER BY
49
5.7 ORDER BY left part DESC, right part ASC
8.0 ORDER BY left part DESC, right part
ASC
• left part must be descending
• right part must be ascending
• the index(left part DESC, right part ASC)
When MySQL Uses Indexes: ORDER BY
49
• Deterministic, built-in
•
Return same value for the same argument
• WHERE the column = FLOOR(123.45)
When MySQL Uses Indexes: Expressions
50
• Deterministic, built-in
•
Return same value for the same argument
• WHERE the column = FLOOR(123.45)
• Non-deterministic
•
Return different values for different invocations
• WHERE the column = RAND() ∗ 100
When MySQL Uses Indexes: Expressions
50
• Deterministic, built-in
•
Return same value for the same argument
• WHERE the column = FLOOR(123.45)
• Non-deterministic
•
Return different values for different invocations
• WHERE the column = RAND() ∗ 100
•
Stored functions and UDFs
• Indexes are not used
Use generated column indexes
When MySQL Uses Indexes: Expressions
50
• Identify which queries do not use indexes
•
Status variables
mysql> select * from performance_schema.session_status
-> where variable_name in (’Created_tmp_tables’,
-> ’Created_tmp_disk_tables’, ’Select_full_join’,
-> ’Select_full_range_join’, ’Select_range’,
-> ’Select_range_check’, ’Select_scan’, ’Sort_merge_passes’,
-> ’Sort_range’, ’Sort_rows’, ’Sort_scan’) and variable_value>0;
+------------------------+----------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+------------------------+----------------+
| Select_scan | 2 |
+------------------------+----------------+
Add Indexes
51
• Identify which queries do not use indexes
mysql> show global status like ’Handler_read%’;
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| Handler_read_first | 31 |
| Handler_read_key | 1909 |
| Handler_read_last | 0 |
| Handler_read_next | 4393 |
| Handler_read_prev | 0 |
| Handler_read_rnd | 0 |
| Handler_read_rnd_next | 1135 |
+-----------------------+-------+
Add Indexes
51
• Identify which queries do not use indexes
•
PERFORMANCE SCHEMA.EVENTS STATEMENTS *
mysql> select * from events_statements_history_long
-> where sql_text like ’select count(*) from employees join %’G
*************************** 1. row ****************************
...
ROWS_SENT: 1 SELECT_RANGE_CHECK: 0
ROWS_EXAMINED: 541058 SELECT_SCAN: 1
CREATED_TMP_DISK_TABLES: 0 SORT_MERGE_PASSES: 0
CREATED_TMP_TABLES: 0 SORT_RANGE: 0
SELECT_FULL_JOIN: 0 SORT_ROWS: 0
SELECT_FULL_RANGE_JOIN: 0 SORT_SCAN: 0
SELECT_RANGE: 0 NO_INDEX_USED: 0
Add Indexes
51
• Identify which queries do not use indexes
•
Slow query log
# Time: 2020-10-11T23:34:03.701871Z
# User@Host: root[root] @ localhost [127.0.0.1] Id: 506
# Query_time: 0.024106 Lock_time: 0.000091
Rows_sent: 1 Rows_examined: 1000
SET timestamp=1602459243;
SELECT c FROM sbtest1 WHERE id=996;
Add Indexes
51
• Identify which queries do not use indexes
•
QAN in PMM
Add Indexes
51
• Identify which queries do not use indexes
• Analyze if adding an index will help
Add Indexes
51
• Identify which queries do not use indexes
• Analyze if adding an index will help
• Add the index
Add Indexes
51
• Identify which queries do not use indexes
• Analyze if adding an index will help
• Add the index
• Test first!
• ADD INDEX is expensive operation
Use pt-online-schema-change
Add Indexes
51
Query Tuning on the Server Side
Optimizer Histograms
• Since version 8.0
Histogram Statistics
53
• Since version 8.0
• Collected and used by the Optimizer
Histogram Statistics
53
• Since version 8.0
• Collected and used by the Optimizer
• Can be examined in Information Schema
mysql> select HISTOGRAM from information_schema.column_statistics
-> where table_name=’example’G
*************************** 1. row ***************************
HISTOGRAM: {"buckets": [[1, 0.6], [2, 0.8], [3, 1.0]],
"data-type": "int", "null-values": 0.0, "collation-id": 8,
"last-updated": "2018-11-07 09:07:19.791470",
"sampling-rate": 1.0, "histogram-type": "singleton",
"number-of-buckets-specified": 3}
1 row in set (0.00 sec)
Histogram Statistics
53
• Since version 8.0
• Collected and used by the Optimizer
• Can be examined in Information Schema
• Affects query execution plan, but not access
• SELECT ... FROM a JOIN b
vs SELECT ... FROM b JOIN a
Histogram Statistics
53
• Since version 8.0
• Collected and used by the Optimizer
• Can be examined in Information Schema
• Affects query execution plan, but not access
More details
Histogram Statistics
53
1 2 3 4 5 6 7 8 9 10
0
200
400
600
800
Indexes: Number of Items with Same Value
54
1 2 3 4 5 6 7 8 9 10
0
200
400
600
800
Indexes: Cardinality
55
1 2 3 4 5 6 7 8 9 10
0
200
400
600
800
Histograms: Number of Values in Each Bucket
56
1 2 3 4 5 6 7 8 9 10
0
0.2
0.4
0.6
0.8
1
Histograms: Data in the Histogram
57
• Data distribution is far from uniform
• Query accesses two or more tables
•
Indexes cannot be used
•
Maintaining them is too expensive
•
They are already used for different condition
Create Histograms
58
Query Tuning on the Server Side
Optimizer Configuration
mysql> select @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,index_merge_intersection=on,
engine_condition_pushdown=on,index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,firstmatch=on,
duplicateweedout=on,subquery_materialization_cost_based=on,
use_index_extensions=on,condition_fanout_filter=on,derived_merge=on
1 row in set (0,00 sec)
Optimizer Switches
60
• Turn ON and OFF particular optimization
Optimizer Switches
60
• Turn ON and OFF particular optimization
• Can be not helpful
• Especially for queries, tuned for previous versions
Optimizer Switches
60
• Turn ON and OFF particular optimization
• Can be not helpful
• Work with them as with any other option
• Turn OFF and try
SET optimizer_switch = ’use_index_extensions=off’;
SELECT ...
EXPLAIN SELECT ...
Optimizer Switches
60
• Turn ON and OFF particular optimization
• Can be not helpful
• Work with them as with any other option
•
If helps implement in queries
SELECT /*+ SEMIJOIN(FIRSTMATCH, LOOSESCAN) */ * FROM t1 ...;
SELECT /*+ BKA(t1) NO_BKA(t2) */ * FROM t1 INNER JOIN t2 WHERE ...;
Optimizer Switches
60
• Temporary tables
•
tmp table size
•
max heap table size
• default tmp storage engine
Increase Size of Optimizer Temporary Objects
61
• Temporary tables
• Buffers for query execution
•
join buffer size
JOIN conditions, not using indexes
Increase Size of Optimizer Temporary Objects
61
• Temporary tables
• Buffers for query execution
•
join buffer size
• read buffer size
Caching indexes for ORDER BY
Bulk insert into partitions
Caching result of nesting queries
Increase Size of Optimizer Temporary Objects
61
• Temporary tables
• Buffers for query execution
•
join buffer size
• read buffer size
• read rnd buffer size
Multi-Range Read optimization
Increase Size of Optimizer Temporary Objects
61
• Temporary tables
• Buffers for query execution
•
join buffer size
• read buffer size
• read rnd buffer size
• select into buffer size
SEELCT INTO OUTFILE
SEELCT INTO DUMPFILE
Increase Size of Optimizer Temporary Objects
61
• Temporary tables
• Buffers for query execution
•
join buffer size
• read buffer size
• read rnd buffer size
• select into buffer size
•
sort buffer size
ORDER BY
GROUP BY
Increase Size of Optimizer Temporary Objects
61
• Temporary tables
• Buffers for query execution
•
join buffer size
• read buffer size
• read rnd buffer size
• select into buffer size
•
sort buffer size
• Change only at the session level!
Increase Size of Optimizer Temporary Objects
61
• Hardware
RAM: more is better
Disk: SSD or NVMe
CPU: more cores, better concurrency
Net: highest speed possible
Conclusion
62
• Hardware
• Configuration
•
InnoDB
innodb buffer pool size
innodb log file size
innodb thread concurrency
innodb io capacity
innodb flush method
innodb flush log at trx commit
• Server
sync binlog
table open cache
table definition cache
Conclusion
62
• Hardware
• Configuration
• Query Performance
•
Add indexes, histograms
•
Tune Optimizer
• Adjust Optimization buffers
tmp table size
join buffer size
read buffer size
read rnd buffer size
select into buffer size
sort buffer size
Conclusion
62
Troubleshooting hardware resource usage
Troubleshooting configuration issues
MySQL Query Tuning for DevOps
Percona Monitoring and Management
Percona Kubernetes Operators
More information
63
www.slideshare.net/SvetaSmirnova
twitter.com/svetsmirnova
github.com/svetasmirnova
Thank you!
64

More Related Content

What's hot

Performance Schema in Action: demo
Performance Schema in Action: demoPerformance Schema in Action: demo
Performance Schema in Action: demoSveta Smirnova
 
How to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tearsHow to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tearsSveta Smirnova
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
 
Highload Perf Tuning
Highload Perf TuningHighload Perf Tuning
Highload Perf TuningHighLoad2009
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionSveta Smirnova
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraSveta Smirnova
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
 
Preparse Query Rewrite Plugins
Preparse Query Rewrite PluginsPreparse Query Rewrite Plugins
Preparse Query Rewrite PluginsSveta Smirnova
 
Troubleshooting MySQL Performance
Troubleshooting MySQL PerformanceTroubleshooting MySQL Performance
Troubleshooting MySQL PerformanceSveta Smirnova
 
Basic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsBasic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsSveta Smirnova
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performanceguest9912e5
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
MySQL Performance Schema in Action: the Complete Tutorial
MySQL Performance Schema in Action: the Complete TutorialMySQL Performance Schema in Action: the Complete Tutorial
MySQL Performance Schema in Action: the Complete TutorialSveta Smirnova
 
Need for Speed: Mysql indexing
Need for Speed: Mysql indexingNeed for Speed: Mysql indexing
Need for Speed: Mysql indexingFromDual GmbH
 
Billion Goods in Few Categories: how Histograms Save a Life?
Billion Goods in Few Categories: how Histograms Save a Life?Billion Goods in Few Categories: how Histograms Save a Life?
Billion Goods in Few Categories: how Histograms Save a Life?Sveta Smirnova
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Mydbops
 
MariaDB Optimizer
MariaDB OptimizerMariaDB Optimizer
MariaDB OptimizerJongJin Lee
 
Why MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it BackWhy MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it BackSveta Smirnova
 
MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MYXPLAIN
 
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013Sergey Petrunya
 

What's hot (20)

Performance Schema in Action: demo
Performance Schema in Action: demoPerformance Schema in Action: demo
Performance Schema in Action: demo
 
How to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tearsHow to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tears
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
Highload Perf Tuning
Highload Perf TuningHighload Perf Tuning
Highload Perf Tuning
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in action
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with Galera
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
Preparse Query Rewrite Plugins
Preparse Query Rewrite PluginsPreparse Query Rewrite Plugins
Preparse Query Rewrite Plugins
 
Troubleshooting MySQL Performance
Troubleshooting MySQL PerformanceTroubleshooting MySQL Performance
Troubleshooting MySQL Performance
 
Basic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsBasic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database Administrators
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
MySQL Performance Schema in Action: the Complete Tutorial
MySQL Performance Schema in Action: the Complete TutorialMySQL Performance Schema in Action: the Complete Tutorial
MySQL Performance Schema in Action: the Complete Tutorial
 
Need for Speed: Mysql indexing
Need for Speed: Mysql indexingNeed for Speed: Mysql indexing
Need for Speed: Mysql indexing
 
Billion Goods in Few Categories: how Histograms Save a Life?
Billion Goods in Few Categories: how Histograms Save a Life?Billion Goods in Few Categories: how Histograms Save a Life?
Billion Goods in Few Categories: how Histograms Save a Life?
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.
 
MariaDB Optimizer
MariaDB OptimizerMariaDB Optimizer
MariaDB Optimizer
 
Why MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it BackWhy MySQL Replication Fails, and How to Get it Back
Why MySQL Replication Fails, and How to Get it Back
 
MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6
 
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
MySQL/MariaDB query optimizer tuning tutorial from Percona Live 2013
 

Similar to MySQL Performance for DevOps

MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOpsSveta Smirnova
 
Optimizing MySQL for Cascade Server
Optimizing MySQL for Cascade ServerOptimizing MySQL for Cascade Server
Optimizing MySQL for Cascade Serverhannonhill
 
iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...
iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...
iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...DataStax Academy
 
Leveraging Cassandra for real-time multi-datacenter public cloud analytics
Leveraging Cassandra for real-time multi-datacenter public cloud analyticsLeveraging Cassandra for real-time multi-datacenter public cloud analytics
Leveraging Cassandra for real-time multi-datacenter public cloud analyticsJulien Anguenot
 
Running MongoDB 3.0 on AWS
Running MongoDB 3.0 on AWSRunning MongoDB 3.0 on AWS
Running MongoDB 3.0 on AWSMongoDB
 
2010 12 mysql_clusteroverview
2010 12 mysql_clusteroverview2010 12 mysql_clusteroverview
2010 12 mysql_clusteroverviewDimas Prasetyo
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpSander Temme
 
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters Ceph Community
 
Databases love nutanix
Databases love nutanixDatabases love nutanix
Databases love nutanixNEXTtour
 
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld
 
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...MongoDB
 
Sql server 2005 memory internal
Sql server 2005 memory internalSql server 2005 memory internal
Sql server 2005 memory internalshuwutong
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringSveta Smirnova
 
MongoDB World 2015 - A Technical Introduction to WiredTiger
MongoDB World 2015 - A Technical Introduction to WiredTigerMongoDB World 2015 - A Technical Introduction to WiredTiger
MongoDB World 2015 - A Technical Introduction to WiredTigerWiredTiger
 
Tuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadTuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadMarius Adrian Popa
 
Kubernetes for HCL Connections Component Pack - Build or Buy?
Kubernetes for HCL Connections Component Pack - Build or Buy?Kubernetes for HCL Connections Component Pack - Build or Buy?
Kubernetes for HCL Connections Component Pack - Build or Buy?Martin Schmidt
 
OSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin CharlesOSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin CharlesNETWAYS
 

Similar to MySQL Performance for DevOps (20)

MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOps
 
Optimizing MySQL for Cascade Server
Optimizing MySQL for Cascade ServerOptimizing MySQL for Cascade Server
Optimizing MySQL for Cascade Server
 
iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...
iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...
iland Internet Solutions: Leveraging Cassandra for real-time multi-datacenter...
 
Leveraging Cassandra for real-time multi-datacenter public cloud analytics
Leveraging Cassandra for real-time multi-datacenter public cloud analyticsLeveraging Cassandra for real-time multi-datacenter public cloud analytics
Leveraging Cassandra for real-time multi-datacenter public cloud analytics
 
Running MongoDB 3.0 on AWS
Running MongoDB 3.0 on AWSRunning MongoDB 3.0 on AWS
Running MongoDB 3.0 on AWS
 
2010 12 mysql_clusteroverview
2010 12 mysql_clusteroverview2010 12 mysql_clusteroverview
2010 12 mysql_clusteroverview
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling Up
 
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
Ceph Day Amsterdam 2015: Measuring and predicting performance of Ceph clusters
 
Databases love nutanix
Databases love nutanixDatabases love nutanix
Databases love nutanix
 
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
 
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
https://docs.google.com/presentation/d/1DcL4zK6i3HZRDD4xTGX1VpSOwyu2xBeWLT6a_...
 
NSCC Training Introductory Class
NSCC Training Introductory Class NSCC Training Introductory Class
NSCC Training Introductory Class
 
Sql server 2005 memory internal
Sql server 2005 memory internalSql server 2005 memory internal
Sql server 2005 memory internal
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and Monitoring
 
MongoDB World 2015 - A Technical Introduction to WiredTiger
MongoDB World 2015 - A Technical Introduction to WiredTigerMongoDB World 2015 - A Technical Introduction to WiredTiger
MongoDB World 2015 - A Technical Introduction to WiredTiger
 
Tuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadTuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy Workload
 
Running MySQL on Linux
Running MySQL on LinuxRunning MySQL on Linux
Running MySQL on Linux
 
Kubernetes for HCL Connections Component Pack - Build or Buy?
Kubernetes for HCL Connections Component Pack - Build or Buy?Kubernetes for HCL Connections Component Pack - Build or Buy?
Kubernetes for HCL Connections Component Pack - Build or Buy?
 
OSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin CharlesOSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin Charles
 
MySQL database
MySQL databaseMySQL database
MySQL database
 

More from Sveta Smirnova

MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?Sveta Smirnova
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveSveta Smirnova
 
MySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for DevelopersMySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for DevelopersSveta Smirnova
 
MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговMySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговSveta Smirnova
 
MySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your BusinessMySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your BusinessSveta Smirnova
 
Introduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sIntroduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sSveta Smirnova
 
Производительность MySQL для DevOps
 Производительность MySQL для DevOps Производительность MySQL для DevOps
Производительность MySQL для DevOpsSveta Smirnova
 
How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?Sveta Smirnova
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaСовременному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaSveta Smirnova
 
How Safe is Asynchronous Master-Master Setup?
 How Safe is Asynchronous Master-Master Setup? How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?Sveta Smirnova
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Sveta Smirnova
 
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...Sveta Smirnova
 
Что нужно знать о трёх топовых фичах MySQL
Что нужно знать  о трёх топовых фичах  MySQLЧто нужно знать  о трёх топовых фичах  MySQL
Что нужно знать о трёх топовых фичах MySQLSveta Smirnova
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Sveta Smirnova
 
Optimizer Histograms: When they Help and When Do Not?
Optimizer Histograms: When they Help and When Do Not?Optimizer Histograms: When they Help and When Do Not?
Optimizer Histograms: When they Help and When Do Not?Sveta Smirnova
 

More from Sveta Smirnova (15)

MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to Have
 
MySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for DevelopersMySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for Developers
 
MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговMySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации багов
 
MySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your BusinessMySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your Business
 
Introduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sIntroduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]s
 
Производительность MySQL для DevOps
 Производительность MySQL для DevOps Производительность MySQL для DevOps
Производительность MySQL для DevOps
 
How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaСовременному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
 
How Safe is Asynchronous Master-Master Setup?
 How Safe is Asynchronous Master-Master Setup? How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?
 
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
 
Что нужно знать о трёх топовых фичах MySQL
Что нужно знать  о трёх топовых фичах  MySQLЧто нужно знать  о трёх топовых фичах  MySQL
Что нужно знать о трёх топовых фичах MySQL
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?
 
Optimizer Histograms: When they Help and When Do Not?
Optimizer Histograms: When they Help and When Do Not?Optimizer Histograms: When they Help and When Do Not?
Optimizer Histograms: When they Help and When Do Not?
 

Recently uploaded

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 

Recently uploaded (20)

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 

MySQL Performance for DevOps

  • 1. MySQL Performance for DevOps October 26, 2020 Sveta Smirnova
  • 2. • MySQL Support engineer • Author of • MySQL Troubleshooting • JSON UDF functions • FILTER clause for MySQL • Speaker • Percona Live, OOW, Fosdem, DevConf, HighLoad... Sveta Smirnova 2
  • 3. •Introduction •Hardware Memory Disk CPU Network •Configuration Important Options •Query Tuning on the Server Side Indexes Optimizer Histograms Optimizer Configuration Table of Contents 3
  • 5. • Database server • 25 years of history • Popular forks • Percona Server for MySQL • MariaDB Server • Replication support from the beginning What is MySQL? 5
  • 6. Connectors: C, JDBC, ODBC, Python, ... Connection Pool: Authentication, Caches SQL interface Parser Optimizer Caches and Buffers: Global Engine-specific Storage engines: InnoDB, MyRocks, ... File system: Data, Index, logs, other files • mysqld and its files • Connectors • Optimizer • Caches • Storage Engines • Management MySQL Architecture 6
  • 7. • Bare hardware • Cloud • Container-orchestration systems Where MySQL Installed in 2020? 7
  • 8. Percona Kubernetes Operator for PXC MySQL Operator MySQL Kubernetes Operators 8
  • 11. • Bare hardware • Operating system options How to Tune? 11
  • 12. • Bare hardware • Operating system options • Clouds • Administrator console How to Tune? 11
  • 13. • Bare hardware • Operating system options • Clouds • Administrator console • Percona Kubernetes Operator for PXC cr.yaml pxc.resources.requests.memory pxc.resources.requests.cpu pxc.resources.limits.memory pxc.volumeSpec.resources.requests.storage How to Tune? 11
  • 14. • Memory • Disk • CPU • Network What to Tune? 12
  • 16. • No swapping: sysctl vm.swappiness=1 Memory Configuration 14
  • 17. • No swapping: sysctl vm.swappiness=1 • NUMA interleave: enable in BIOS Memory Configuration 14
  • 18. • No swapping: sysctl vm.swappiness=1 • NUMA interleave: enable in BIOS • More is better Memory Configuration 14
  • 19. • No swapping: sysctl vm.swappiness=1 • NUMA interleave: enable in BIOS • More is better • Memory access is faster than disk access Memory Configuration 14
  • 20. • No swapping: sysctl vm.swappiness=1 • NUMA interleave: enable in BIOS • More is better • Memory access is faster than disk access • Frequently accessed data should be in memory Memory Configuration 14
  • 21. • Global buffers • Allocated up to the limit and freed at shutdown InnoDB Buffer Pool Size Performance Schema tables How MySQL Uses Memory 15
  • 22. • Global buffers • Session buffers • Allocated when session starts • Freed at the disconnect Connection and result buffers: from net buffer length up to max allowed packet How MySQL Uses Memory 15
  • 23. • Global buffers • Session buffers • Operation-specific buffers • Allocated for the operation life time • Can be allocated multiple times join buffer size: for each tables pair in JOIN tmp table size: for each temporary table How MySQL Uses Memory 15
  • 25. • Faster is better • SSD • NVMe • Spinning disk Disk Configuration 17
  • 26. • Faster is better • SSD • NVMe • Spinning disk • Parallel writes Disk Configuration 17
  • 27. • Faster is better • SSD • NVMe • Spinning disk • Parallel writes • Battery-backed cache Disk Configuration 17
  • 28. • Tables data How MySQL Uses Disk 18
  • 29. • Tables data • Log files • Binary • Storage engine InnoDB redo log file • Error, general, audit, ... How MySQL Uses Disk 18
  • 30. • Tables data • Log files • Binary • Storage engine InnoDB redo log file • Error, general, audit, ... • Disk-based temporary tables How MySQL Uses Disk 18
  • 31. • Tables data • Log files • Binary • Storage engine InnoDB redo log file • Error, general, audit, ... • Disk-based temporary tables • You may put these on different disks How MySQL Uses Disk 18
  • 33. • IO scheduler [noop] or [deadline] • sudo echo noop > /sys/block/YOUR DISK/queue/scheduler or sudo echo deadline > /sys/block/YOUR DISK/queue/scheduler CPU Configuration 20
  • 34. • IO scheduler [noop] or [deadline] • sudo echo noop > /sys/block/YOUR DISK/queue/scheduler or sudo echo deadline > /sys/block/YOUR DISK/queue/scheduler • CPU governor: set to performance CPU Configuration 20
  • 35. • IO scheduler [noop] or [deadline] • sudo echo noop > /sys/block/YOUR DISK/queue/scheduler or sudo echo deadline > /sys/block/YOUR DISK/queue/scheduler • CPU governor: set to performance • More cores is better CPU Configuration 20
  • 36. • One thread per connection • CPU used only for active threads How MySQL Uses CPU 21
  • 37. • One thread per connection • CPU used only for active threads • Background work by storage engines How MySQL Uses CPU 21
  • 39. ? <= CPU cores? What Happens with Threads 23
  • 40. ? <= CPU cores? Yes Executed simultaneously What Happens with Threads 23
  • 41. ? <= CPU cores? Yes Executed simultaneously No Wait in a queue What Happens with Threads 23
  • 42. ? <= CPU cores? Yes Executed simultaneously No Wait in a queue ? Does the disk support parallel write? What Happens with Threads 23
  • 43. ? <= CPU cores? Yes Executed simultaneously No Wait in a queue ? Does the disk support parallel write? Yes Write happens What Happens with Threads 23
  • 44. ? <= CPU cores? Yes Executed simultaneously No Wait in a queue ? Does the disk support parallel write? Yes Write happens No Wait in a queue What Happens with Threads 23
  • 46. • As fast as possible • Speed of the line RTT • Bandwidth • Stability To avoid TCP packet re-submission Network Configuration 25
  • 47. • As fast as possible • On the Internet connection • Clients can work • Asynchronous replica will delay • Synchronous clusters will be not functional Node disconnects with default options Very slow response times with adjusted configuration Network Configuration 25
  • 48. • Communication between server and client • Regular client • Application • Replication connection (IO) thread • Traffic between synchronous nodes How MySQL Uses Network 26
  • 50. • Server options • Components • Storage engines InnoDB • Plugins • Server Binary logging Optimizer What can be Configured? 28
  • 51. • Global • Parameters, necessary for all server processes Location of server files: datadir etc. Shared buffers More • Session • Control connection-specific parameters MySQL Option Tables System Variables and Options: Scope 29
  • 52. • SET [GLOBAL|PERSIST] var = NEW VALUE System Variables: How to Change 30
  • 53. • SET [GLOBAL|PERSIST] var = NEW VALUE • Command-line option: --var=new value System Variables: How to Change 30
  • 54. • SET [GLOBAL|PERSIST] var = NEW VALUE • Command-line option: --var=new value • Configuration file In the default location • Specified by option --defaults-file [mysqld] var=new_value System Variables: How to Change 30
  • 55. • PXC Operator Configuration • In cr.yaml spec: secretsName: my-cluster-secrets pxc: ... configuration: | [mysqld] innodb_log_file_size=8G System Variables: How to Change 30
  • 56. • PXC Operator Configuration • In ConfigMap Create custom configuration file my.cnf [mysqld] innodb_log_file_size=8G System Variables: How to Change 30
  • 57. • PXC Operator Configuration • In ConfigMap Create custom configuration file my.cnf [mysqld] innodb_log_file_size=8G Create ConfigMap: kubectl create configmap cluster1-pxc --from-file=my.cnf System Variables: How to Change 30
  • 58. • PXC Operator Configuration • In ConfigMap Create custom configuration file my.cnf [mysqld] innodb_log_file_size=8G Create ConfigMap: kubectl create configmap cluster1-pxc --from-file=my.cnf Restart PXC System Variables: How to Change 30
  • 59. • Global options and few session options < 8.0 A user with privilege SUPER 8.0 + A user with privilege SYSTEM VARIABLES ADMIN Dynamic Variables: Who Can Change 31
  • 60. • Global options and few session options < 8.0 A user with privilege SUPER 8.0 + A user with privilege SYSTEM VARIABLES ADMIN • Session options < 8.0 Anybody 8.0 + Restricted privileges SYSTEM VARIABLES ADMIN SESSION VARIABLES ADMIN 8.0 + Not restricted privileges: anybody Dynamic Variables: Who Can Change 31
  • 61. • Global options and few session options < 8.0 A user with privilege SUPER 8.0 + A user with privilege SYSTEM VARIABLES ADMIN • Session options < 8.0 Anybody 8.0 + Restricted privileges SYSTEM VARIABLES ADMIN SESSION VARIABLES ADMIN 8.0 + Not restricted privileges: anybody • There are no limits! Dynamic Variables: Who Can Change 31
  • 62. • Those which control behavior of whole server • Once at server startup • Can start with low values, then grow to specified Buffers: When Allocated 32
  • 63. • Those which control behavior of whole server • Once at server startup • Can start with low values, then grow to specified • Connection options • For every connection when connection opens Buffers: When Allocated 32
  • 64. • Those which control behavior of whole server • Once at server startup • Can start with low values, then grow to specified • Connection options • For every connection when connection opens • Operation-specific • For every operation when needed • Can be allocated more than once Buffers: When Allocated 32
  • 66. • innodb buffer pool size • Ideally should hold active data set InnoDB 34
  • 67. • innodb buffer pool size • innodb log file size • Should hold changes for an hour InnoDB 34
  • 68. • innodb buffer pool size • innodb log file size • Should hold changes for an hour • Too low InnoDB 34
  • 69. • innodb buffer pool size • innodb log file size • Should hold changes for an hour • Good InnoDB 34
  • 70. • innodb buffer pool size • innodb log file size • innodb thread concurrency • 0 or number of CPU cores InnoDB 34
  • 71. • innodb buffer pool size • innodb log file size • innodb thread concurrency • innodb io capacity • Default is too small for fast disks • Up to number of IOPS your disk can handle InnoDB 34
  • 72. • innodb buffer pool size • innodb log file size • innodb thread concurrency • innodb io capacity • innodb flush method • In most cases: O DIRECT • Test on your filesystem! InnoDB 34
  • 73. • Changing these compromize durability! Synchronization 35
  • 74. • Changing these compromize durability! • innodb flush log at trx commit 1: full ACID, default Synchronization 35
  • 75. • Changing these compromize durability! • innodb flush log at trx commit 1: full ACID, default 2: logs written at each commit, flushed per second MySQL can handle up to 1M INSERTs per second Safe with PXC and InnoDB Cluster Synchronization 35
  • 76. • Changing these compromize durability! • innodb flush log at trx commit 1: full ACID, default 2: logs written at each commit, flushed per second 0: logs are written and flushed once per second Synchronization 35
  • 77. • Changing these compromize durability! • innodb flush log at trx commit 1: full ACID, default 2: logs written at each commit, flushed per second 0: logs are written and flushed once per second • Once per second not guaranteed for 0 and 2 DDL can cause faster flushing Scheduling may delay flushing Synchronization 35
  • 78. • Changing these compromize durability! • innodb flush log at trx commit • sync binlog 0: Synchronization handled by the system 1: At each transaction commit, default No transaction lost N: After N binary log group commits In case of power or OS crash not flushed transactions can be lost Synchronization 35
  • 79. • table open cache • The number of open tables for all threads • Increase when Connections in the PROCESSLIST are waiting for opening a table Value of global status variable Opened tables is larger than Open tables Table Handlers 36
  • 80. • table open cache • table definition cache • Size of the cache for table definitions • Increase when Value of Opened table definitions is larger than Open table definitions Table Handlers 36
  • 81. • table open cache • table definition cache • Increase OS open files limit if needed Table Handlers 36
  • 82. Query Tuning on the Server Side
  • 83. • You communicate with database using queries • Even via NoSQL interface • They are not SQL queries, but still queries Heart of the application 38
  • 84. • You communicate with database using queries • Even via NoSQL interface • They are not SQL queries, but still queries • Data, which you request, matters • 1,000,000,000 rows vs 1 row Heart of the application 38
  • 85. Query sent Connection Pool: Authentication, Caches; SQL interface; Parser Optimizer Storage engines Hardware Query execution workflow 39
  • 86. • Selecting a lot of data • SELECT * FROM many columns table You May not Be Able to Change Slow Query 40
  • 87. • Selecting a lot of data • SELECT * FROM many columns table • Badly written • LEFT JOIN instead of INNER JOIN • Many values in IN() • Retrieving large result set, then discarding • Not effective SQL For particular MySQL version You May not Be Able to Change Slow Query 40
  • 88. • Selecting a lot of data • SELECT * FROM many columns table • Badly written • LEFT JOIN instead of INNER JOIN • Many values in IN() • Retrieving large result set, then discarding • Not effective SQL For particular MySQL version • We still can improve performance You May not Be Able to Change Slow Query 40
  • 89. Query Tuning on the Server Side Indexes
  • 90. SELECT name FROM users SELECT name FROM users WHERE id=12 1 2 5 6 7 9 12 16 18 21 22 23 24 25 Full Table Scan 42
  • 91. SELECT name FROM users SELECT name FROM users WHERE id=12 1 2 5 6 7 9 12 16 18 21 22 23 24 25 After Index Added 43
  • 93. • Single column CREATE INDEX index name ON the table(the column) • Multiple columns CREATE INDEX index name ON the table(column1, column2) How to Create an Index 45
  • 94. • Single column ALTER TABLE table name ADD INDEX [index name] (the column) • Multiple columns ALTER TABLE table name ADD INDEX [index name] (column1, column2) How to Create an Index 45
  • 95. • WHERE the column = a value • WHERE the column IN(value1, value2, value3) • WHERE the column LIKE ’value%’ • WHERE the column LIKE ’%value’ When MySQL Uses Indexes: Conditions 46
  • 96. • WHERE left part = value1 AND right part = value2 • WHERE left part = value1 OR right part = value2 • WHERE right part = value1 AND left part = value2 • WHERE right part = value1 OR left part = value2 When MySQL Uses Indexes: Conditions 46
  • 97. • table1 JOIN table2 ON table1.column1 = table2.column2 When MySQL Uses Indexes: Joins 47
  • 98. • table1 JOIN table2 ON table1.column1 = table2.column2 • Same as FROM table1, table2 WHERE table1.column1 = table2.column2 When MySQL Uses Indexes: Joins 47
  • 99. • GROUP BY the column • GROUP BY left part, right part • GROUP BY right part, left part • GROUP BY the index, another index When MySQL Uses Indexes: GROUP BY 48
  • 100. • ORDER BY the column • ORDER BY left part, right part • ORDER BY right part, left part • ORDER BY the index, another index When MySQL Uses Indexes: ORDER BY 49
  • 101. 5.7 ORDER BY left part DESC, right part ASC 8.0 ORDER BY left part DESC, right part ASC • left part must be descending • right part must be ascending • the index(left part DESC, right part ASC) When MySQL Uses Indexes: ORDER BY 49
  • 102. • Deterministic, built-in • Return same value for the same argument • WHERE the column = FLOOR(123.45) When MySQL Uses Indexes: Expressions 50
  • 103. • Deterministic, built-in • Return same value for the same argument • WHERE the column = FLOOR(123.45) • Non-deterministic • Return different values for different invocations • WHERE the column = RAND() ∗ 100 When MySQL Uses Indexes: Expressions 50
  • 104. • Deterministic, built-in • Return same value for the same argument • WHERE the column = FLOOR(123.45) • Non-deterministic • Return different values for different invocations • WHERE the column = RAND() ∗ 100 • Stored functions and UDFs • Indexes are not used Use generated column indexes When MySQL Uses Indexes: Expressions 50
  • 105. • Identify which queries do not use indexes • Status variables mysql> select * from performance_schema.session_status -> where variable_name in (’Created_tmp_tables’, -> ’Created_tmp_disk_tables’, ’Select_full_join’, -> ’Select_full_range_join’, ’Select_range’, -> ’Select_range_check’, ’Select_scan’, ’Sort_merge_passes’, -> ’Sort_range’, ’Sort_rows’, ’Sort_scan’) and variable_value>0; +------------------------+----------------+ | VARIABLE_NAME | VARIABLE_VALUE | +------------------------+----------------+ | Select_scan | 2 | +------------------------+----------------+ Add Indexes 51
  • 106. • Identify which queries do not use indexes mysql> show global status like ’Handler_read%’; +-----------------------+-------+ | Variable_name | Value | +-----------------------+-------+ | Handler_read_first | 31 | | Handler_read_key | 1909 | | Handler_read_last | 0 | | Handler_read_next | 4393 | | Handler_read_prev | 0 | | Handler_read_rnd | 0 | | Handler_read_rnd_next | 1135 | +-----------------------+-------+ Add Indexes 51
  • 107. • Identify which queries do not use indexes • PERFORMANCE SCHEMA.EVENTS STATEMENTS * mysql> select * from events_statements_history_long -> where sql_text like ’select count(*) from employees join %’G *************************** 1. row **************************** ... ROWS_SENT: 1 SELECT_RANGE_CHECK: 0 ROWS_EXAMINED: 541058 SELECT_SCAN: 1 CREATED_TMP_DISK_TABLES: 0 SORT_MERGE_PASSES: 0 CREATED_TMP_TABLES: 0 SORT_RANGE: 0 SELECT_FULL_JOIN: 0 SORT_ROWS: 0 SELECT_FULL_RANGE_JOIN: 0 SORT_SCAN: 0 SELECT_RANGE: 0 NO_INDEX_USED: 0 Add Indexes 51
  • 108. • Identify which queries do not use indexes • Slow query log # Time: 2020-10-11T23:34:03.701871Z # User@Host: root[root] @ localhost [127.0.0.1] Id: 506 # Query_time: 0.024106 Lock_time: 0.000091 Rows_sent: 1 Rows_examined: 1000 SET timestamp=1602459243; SELECT c FROM sbtest1 WHERE id=996; Add Indexes 51
  • 109. • Identify which queries do not use indexes • QAN in PMM Add Indexes 51
  • 110. • Identify which queries do not use indexes • Analyze if adding an index will help Add Indexes 51
  • 111. • Identify which queries do not use indexes • Analyze if adding an index will help • Add the index Add Indexes 51
  • 112. • Identify which queries do not use indexes • Analyze if adding an index will help • Add the index • Test first! • ADD INDEX is expensive operation Use pt-online-schema-change Add Indexes 51
  • 113. Query Tuning on the Server Side Optimizer Histograms
  • 114. • Since version 8.0 Histogram Statistics 53
  • 115. • Since version 8.0 • Collected and used by the Optimizer Histogram Statistics 53
  • 116. • Since version 8.0 • Collected and used by the Optimizer • Can be examined in Information Schema mysql> select HISTOGRAM from information_schema.column_statistics -> where table_name=’example’G *************************** 1. row *************************** HISTOGRAM: {"buckets": [[1, 0.6], [2, 0.8], [3, 1.0]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "last-updated": "2018-11-07 09:07:19.791470", "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 3} 1 row in set (0.00 sec) Histogram Statistics 53
  • 117. • Since version 8.0 • Collected and used by the Optimizer • Can be examined in Information Schema • Affects query execution plan, but not access • SELECT ... FROM a JOIN b vs SELECT ... FROM b JOIN a Histogram Statistics 53
  • 118. • Since version 8.0 • Collected and used by the Optimizer • Can be examined in Information Schema • Affects query execution plan, but not access More details Histogram Statistics 53
  • 119. 1 2 3 4 5 6 7 8 9 10 0 200 400 600 800 Indexes: Number of Items with Same Value 54
  • 120. 1 2 3 4 5 6 7 8 9 10 0 200 400 600 800 Indexes: Cardinality 55
  • 121. 1 2 3 4 5 6 7 8 9 10 0 200 400 600 800 Histograms: Number of Values in Each Bucket 56
  • 122. 1 2 3 4 5 6 7 8 9 10 0 0.2 0.4 0.6 0.8 1 Histograms: Data in the Histogram 57
  • 123. • Data distribution is far from uniform • Query accesses two or more tables • Indexes cannot be used • Maintaining them is too expensive • They are already used for different condition Create Histograms 58
  • 124. Query Tuning on the Server Side Optimizer Configuration
  • 125. mysql> select @@optimizer_switchG *************************** 1. row *************************** @@optimizer_switch: index_merge=on,index_merge_union=on, index_merge_sort_union=on,index_merge_intersection=on, engine_condition_pushdown=on,index_condition_pushdown=on, mrr=on,mrr_cost_based=on, block_nested_loop=on,batched_key_access=off, materialization=on,semijoin=on,loosescan=on,firstmatch=on, duplicateweedout=on,subquery_materialization_cost_based=on, use_index_extensions=on,condition_fanout_filter=on,derived_merge=on 1 row in set (0,00 sec) Optimizer Switches 60
  • 126. • Turn ON and OFF particular optimization Optimizer Switches 60
  • 127. • Turn ON and OFF particular optimization • Can be not helpful • Especially for queries, tuned for previous versions Optimizer Switches 60
  • 128. • Turn ON and OFF particular optimization • Can be not helpful • Work with them as with any other option • Turn OFF and try SET optimizer_switch = ’use_index_extensions=off’; SELECT ... EXPLAIN SELECT ... Optimizer Switches 60
  • 129. • Turn ON and OFF particular optimization • Can be not helpful • Work with them as with any other option • If helps implement in queries SELECT /*+ SEMIJOIN(FIRSTMATCH, LOOSESCAN) */ * FROM t1 ...; SELECT /*+ BKA(t1) NO_BKA(t2) */ * FROM t1 INNER JOIN t2 WHERE ...; Optimizer Switches 60
  • 130. • Temporary tables • tmp table size • max heap table size • default tmp storage engine Increase Size of Optimizer Temporary Objects 61
  • 131. • Temporary tables • Buffers for query execution • join buffer size JOIN conditions, not using indexes Increase Size of Optimizer Temporary Objects 61
  • 132. • Temporary tables • Buffers for query execution • join buffer size • read buffer size Caching indexes for ORDER BY Bulk insert into partitions Caching result of nesting queries Increase Size of Optimizer Temporary Objects 61
  • 133. • Temporary tables • Buffers for query execution • join buffer size • read buffer size • read rnd buffer size Multi-Range Read optimization Increase Size of Optimizer Temporary Objects 61
  • 134. • Temporary tables • Buffers for query execution • join buffer size • read buffer size • read rnd buffer size • select into buffer size SEELCT INTO OUTFILE SEELCT INTO DUMPFILE Increase Size of Optimizer Temporary Objects 61
  • 135. • Temporary tables • Buffers for query execution • join buffer size • read buffer size • read rnd buffer size • select into buffer size • sort buffer size ORDER BY GROUP BY Increase Size of Optimizer Temporary Objects 61
  • 136. • Temporary tables • Buffers for query execution • join buffer size • read buffer size • read rnd buffer size • select into buffer size • sort buffer size • Change only at the session level! Increase Size of Optimizer Temporary Objects 61
  • 137. • Hardware RAM: more is better Disk: SSD or NVMe CPU: more cores, better concurrency Net: highest speed possible Conclusion 62
  • 138. • Hardware • Configuration • InnoDB innodb buffer pool size innodb log file size innodb thread concurrency innodb io capacity innodb flush method innodb flush log at trx commit • Server sync binlog table open cache table definition cache Conclusion 62
  • 139. • Hardware • Configuration • Query Performance • Add indexes, histograms • Tune Optimizer • Adjust Optimization buffers tmp table size join buffer size read buffer size read rnd buffer size select into buffer size sort buffer size Conclusion 62
  • 140. Troubleshooting hardware resource usage Troubleshooting configuration issues MySQL Query Tuning for DevOps Percona Monitoring and Management Percona Kubernetes Operators More information 63