SlideShare a Scribd company logo
MySQL Performance
for DevOps
Sveta Smirnova
Principal Support
Engineering Coordinator
l
• MySQL Support engineer
• Author of
• MySQL Troubleshooting
• JSON UDF functions
• FILTER clause for MySQL
• Speaker
• Percona Live, OOW, Fosdem,
DevConf, HighLoad...
Sveta Smirnova
•Introduction
•Memory
•Disk
•CPU
•Network
•Query Tuning
Table of Contents
3 ©2022 | Percona
Introduction
• Database server
• 25+ years of history
• Popular forks
• Percona Server for MySQL
• MariaDB Server
• Replication support from the beginning
Percona Operator for MySQL
What is MySQL?
5 ©2022 | Percona
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
- Connectors
- Optimizer
- Caches
- Storage Engines
- Management
MySQL Architecture
6 ©2022 | Percona
Query
Configuration
Hardware
What Affects Performance?
7 ©2022 | Percona
• SET [GLOBAL] var = NEW VALUE
How to Change System Variables
8 ©2022 | Percona
• SET [GLOBAL] var = NEW VALUE
• Command-line option
--var=new value
How to Change System Variables
9 ©2022 | Percona
• SET [GLOBAL] var = NEW VALUE
• Command-line option
--var=new value
• Configuration file
In the default location
• Specified by option --defaults-file
How to Change System Variables
10 ©2022 | Percona
In deploy/cr.yaml
spec:
secretsName: my-cluster-secrets
pxc:
...
configuration: |
[mysqld]
wsrep_debug=CLIENT
max_connections=250
How to Change with Kubernetes
11 ©2022 | Percona
In deploy/cr.yaml
In a ConfigMap
kubectl create configmap cluster1-pxc --from-file=my.cnf
How to Change with Kubernetes
12 ©2022 | Percona
In deploy/cr.yaml
In a ConfigMap
Using a Secret Object
How to Change with Kubernetes
13 ©2022 | Percona
Memory
• Frequently accessed data
• InnoDB buffer pool
• MyRocks recently inserted data
• Table and thread cache
Memory is Faster than Disk
15 ©2022 | Percona
• Frequently accessed data
• InnoDB buffer pool
• MyRocks recently inserted data
• Table and thread cache
• Temporary objects
• Implicit temporary tables
• Prepared statements
• User variables
Memory is Faster than Disk
16 ©2022 | Percona
• Frequently accessed data
• InnoDB buffer pool
• MyRocks recently inserted data
• Table and thread cache
• Temporary objects
• Implicit temporary tables
• Prepared statements
• User variables
• Frequently accessed data
should be in memory
Memory is Faster than Disk
17 ©2022 | Percona
• No swapping
• sysctl vm.swappiness=1
System Memory Configuration
18 ©2022 | Percona
• No swapping
• sysctl vm.swappiness=1
• NUMA interleave
• Enable in BIOS
System Memory Configuration
19 ©2022 | Percona
• No swapping
• sysctl vm.swappiness=1
• NUMA interleave
• Enable in BIOS
• Kubernetes
resources:
requests:
memory: 32G
...
# limits:
# memory: 32G
System Memory Configuration
20 ©2022 | Percona
• innodb buffer pool size
• Ideally should hold active data set
MySQL Memory Configuration
21 ©2022 | Percona
• innodb buffer pool size
• 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
MySQL Memory Configuration
22 ©2022 | Percona
• innodb buffer pool size
• 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
MySQL Memory Configuration
23 ©2022 | Percona
• innodb buffer pool size
• table open cache
• table definition cache
• Increase OS open files limit if needed
MySQL Memory Configuration
24 ©2022 | Percona
Disk
• Tables
• Log files
• Engine
• Replication
• Diagnostic
• Temporary files
MySQL Stores Data on the Disk
26 ©2022 | Percona
• Faster is better
• SSD
• NVMe
• Spinning disk
System Disk Configuration
27 ©2022 | Percona
• Faster is better
• SSD
• NVMe
• Spinning disk
• Parallel writes
System Disk Configuration
28 ©2022 | Percona
• Faster is better
• SSD
• NVMe
• Spinning disk
• Parallel writes
• Battery-backed cache
System Disk Configuration
29 ©2022 | Percona
• innodb log file size
• Should hold changes for an hour
InnoDB Disk Configuraiton
30 ©2022 | Percona
• innodb log file size
• Should hold changes for an hour
• Too low
InnoDB Disk Configuraiton
31 ©2022 | Percona
• innodb log file size
• Should hold changes for an hour
• Good
InnoDB Disk Configuraiton
32 ©2022 | Percona
• innodb log file size
• innodb io capacity
• Default is too small for fast disks
• Up to number of IOPS your disk can handle
• Do not set too high!
InnoDB Disk Configuraiton
33 ©2022 | Percona
• innodb log file size
• innodb io capacity
• innodb flush method
• In most cases: O DIRECT
• Test on your filesystem!
InnoDB Disk Configuraiton
34 ©2022 | Percona
• Changing these
compromize durability!
Synchronization
35 ©2022 | Percona
• Changing these
compromize durability!
• innodb flush log at trx commit
1: full ACID, default
Synchronization
36 ©2022 | Percona
• 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, Galera and InnoDB Clusters
Synchronization
37 ©2022 | Percona
• 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
38 ©2022 | Percona
• 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 or 2
DDL can cause faster flushing
Scheduling may delay flushing
Synchronization
39 ©2022 | Percona
• 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
40 ©2022 | Percona
CPU
• One thread per connection
• CPU used only for active threads
How MySQL Uses CPU
42 ©2022 | Percona
• One thread per connection
• CPU used only for active threads
• Background work by storage engines
How MySQL Uses CPU
43 ©2022 | Percona
Server
Storage Engine
Connection and Engine Threads
44 ©2022 | Percona
? <= CPU cores?
What Happens with Threads
45 ©2022 | Percona
? <= CPU cores?
Yes Executed simultaneously
What Happens with Threads
46 ©2022 | Percona
? <= CPU cores?
Yes Executed simultaneously
No Wait in a queue
What Happens with Threads
47 ©2022 | Percona
? <= CPU cores?
Yes Executed simultaneously
No Wait in a queue
? Does the disk support parallel write?
What Happens with Threads
48 ©2022 | Percona
? <= CPU cores?
Yes Executed simultaneously
No Wait in a queue
? Does the disk support parallel write?
Yes Write happens
What Happens with Threads
49 ©2022 | Percona
? <= 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
50 ©2022 | Percona
• IO scheduler
• [noop] or [deadline]
• sudo echo noop >
/sys/block/DISK/queue/scheduler
or sudo echo deadline >
/sys/block/DISK/queue/scheduler
System CPU Configuration
51 ©2022 | Percona
• IO scheduler
• [noop] or [deadline]
• sudo echo noop >
/sys/block/DISK/queue/scheduler
or sudo echo deadline >
/sys/block/DISK/queue/scheduler
• CPU governor
• Set to performance
System CPU Configuration
52 ©2022 | Percona
• IO scheduler
• [noop] or [deadline]
• sudo echo noop >
/sys/block/DISK/queue/scheduler
or sudo echo deadline >
/sys/block/DISK/queue/scheduler
• CPU governor
• Set to performance
• More cores is better
System CPU Configuration
53 ©2022 | Percona
• Kubernetes
resources:
requests:
cpu: "16"
limits:
cpu: "32"
Kuberetes CPU Configuration
54 ©2022 | Percona
• innodb thread concurrency
• 0 or number of CPU cores
Thread Pool
MySQL CPU Configuration
55 ©2022 | Percona
Network
• User connections
• Replication
• Each replica creates one connection to the
source server
MySQL Uses Network for
57 ©2022 | Percona
• As fast as possible
• Speed of the line
RTT
• Bandwidth
• Stability
To avoid TCP packet re-submission
Network Should Be
58 ©2022 | Percona
• 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
On the Internet connection
59 ©2022 | Percona
Query Tuning
• You communicate with database using
queries
• Even via NoSQL interface
• They are not SQL queries, but still queries
Heart of the application
61 ©2022 | Percona
• You communicate with database using
queries
• Even via NoSQL interface
• They are not SQL queries, but still queries
• Data, that you request, matters
• 1,000,000,000 rows
vs 1 row
Heart of the application
62 ©2022 | Percona
Query sent
Connection Pool:
Authentication, Caches;
SQL interface; Parser
Optimizer
Storage engines
Hardware
Query execution workflow
63 ©2022 | Percona
d001
d003
d008
d009
d003******
d009******
d008******
d009******
d001******
d003******
d009******
d008******
d009******
d001******
d008******
d008******
- B-Tree Mostly
- LSM Tree
- R-Tree Spatial
- Hash Memory SE
- Engine’s
MySQL Indexes
64 ©2022 | Percona
mysql> SELECT first_name, last_name, salary FROM employees
-> JOIN salaries USING(emp_no)
-> WHERE salary = (SELECT MAX(salary) FROM salaries);
+------------+-----------+--------+
| first_name | last_name | salary |
+------------+-----------+--------+
| Tokuyasu | Pesch | 158220 |
+------------+-----------+--------+
1 row in set (2,05 sec)
Effect of an Index
65 ©2022 | Percona
mysql> ALTER TABLE salaries ADD INDEX(salary);
Query OK, 0 rows affected (9,65 sec)
Records: 0 Duplicates: 0 Warnings: 0
Effect of an Index
66 ©2022 | Percona
mysql> SELECT first_name, last_name, salary FROM employees
-> JOIN salaries USING(emp_no)
-> WHERE salary = (SELECT MAX(salary) FROM salaries);
+------------+-----------+--------+
| first_name | last_name | salary |
+------------+-----------+--------+
| Tokuyasu | Pesch | 158220 |
+------------+-----------+--------+
1 row in set (0,00 sec)
Effect of an Index
67 ©2022 | Percona
MySQL Query Tuning for DevOps
How MySQL Indexes Work
68 ©2022 | Percona
• Temporary tables
• tmp table size
• max heap table size
• default tmp storage engine
Optimizer Configuration
69 ©2022 | Percona
• Temporary tables
• Buffers for query execution
• join buffer size
JOIN conditions, not using indexes
Optimizer Configuration
70 ©2022 | Percona
• 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
Optimizer Configuration
71 ©2022 | Percona
• Temporary tables
• Buffers for query execution
• join buffer size
• read buffer size
• read rnd buffer size
Multi-Range Read optimization
Optimizer Configuration
72 ©2022 | Percona
• Temporary tables
• Buffers for query execution
• join buffer size
• read buffer size
• read rnd buffer size
• select into buffer size
SELECT INTO OUTFILE
SELECT INTO DUMPFILE
Optimizer Configuration
73 ©2022 | Percona
• 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
Optimizer Configuration
74 ©2022 | Percona
• 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!
Optimizer Configuration
75 ©2022 | Percona
• Hardware
RAM: more is better
Disk: SSD or NVMe
CPU: more cores, better concurrency
Net: highest speed possible
Conclusion
76 ©2022 | Percona
• 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
77 ©2022 | Percona
• Hardware
• Configuration
• Query Performance
• Add indexes
• Adjust Optimization buffers
tmp table size
join buffer size
read buffer size
read rnd buffer size
select into buffer size
sort buffer size
Conclusion
78 ©2022 | Percona
Troubleshooting hardware resources
Troubleshooting configuration issues
MySQL Query Tuning for DevOps
Percona Monitoring and Management
Percona Kubernetes Operators
More information
79 ©2022 | Percona
SvetaSmirnova
svetasmirnova
@svetsmirnova
svetsmirnova
Thank you!
80 ©2022 | Percona
Ad

Recommended

MySQL Performance Schema in Action
MySQL Performance Schema in Action
Sveta Smirnova
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
Aurimas Mikalauskas
 
MySQL Database Architectures - 2020-10
MySQL Database Architectures - 2020-10
Kenny Gryp
 
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
Kenny Gryp
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바
NeoClova
 
Upgrade to MySQL 8.0!
Upgrade to MySQL 8.0!
Ted Wennmark
 
[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기
NHN FORWARD
 
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Mydbops
 
How to upgrade like a boss to MySQL 8.0 - PLE19
How to upgrade like a boss to MySQL 8.0 - PLE19
Alkin Tezuysal
 
The Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication Tutorial
Jean-François Gagné
 
MariaDB 10.11 key features overview for DBAs
MariaDB 10.11 key features overview for DBAs
Federico Razzoli
 
Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0
Mydbops
 
MySQL Shell for DBAs
MySQL Shell for DBAs
Frederic Descamps
 
Reducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQL
Kenny Gryp
 
Intro ProxySQL
Intro ProxySQL
I Goo Lee
 
High performance and high availability proxies for MySQL
High performance and high availability proxies for MySQL
Mydbops
 
How to upgrade like a boss to my sql 8.0?
How to upgrade like a boss to my sql 8.0?
Alkin Tezuysal
 
Galera cluster for high availability
Galera cluster for high availability
Mydbops
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바
NeoClova
 
InnoDB Internal
InnoDB Internal
mysqlops
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to Have
Sveta Smirnova
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
Jean-François Gagné
 
InnoDB Performance Optimisation
InnoDB Performance Optimisation
Mydbops
 
Sharding Methods for MongoDB
Sharding Methods for MongoDB
MongoDB
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptx
NeoClova
 
My sql failover test using orchestrator
My sql failover test using orchestrator
YoungHeon (Roy) Kim
 
MySQL Shell - The Best MySQL DBA Tool
MySQL Shell - The Best MySQL DBA Tool
Miguel Araújo
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptx
NeoClova
 
MySQL Performance for DevOps
MySQL Performance for DevOps
Sveta Smirnova
 
MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017
Ivan Zoratti
 

More Related Content

What's hot (20)

How to upgrade like a boss to MySQL 8.0 - PLE19
How to upgrade like a boss to MySQL 8.0 - PLE19
Alkin Tezuysal
 
The Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication Tutorial
Jean-François Gagné
 
MariaDB 10.11 key features overview for DBAs
MariaDB 10.11 key features overview for DBAs
Federico Razzoli
 
Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0
Mydbops
 
MySQL Shell for DBAs
MySQL Shell for DBAs
Frederic Descamps
 
Reducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQL
Kenny Gryp
 
Intro ProxySQL
Intro ProxySQL
I Goo Lee
 
High performance and high availability proxies for MySQL
High performance and high availability proxies for MySQL
Mydbops
 
How to upgrade like a boss to my sql 8.0?
How to upgrade like a boss to my sql 8.0?
Alkin Tezuysal
 
Galera cluster for high availability
Galera cluster for high availability
Mydbops
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바
NeoClova
 
InnoDB Internal
InnoDB Internal
mysqlops
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to Have
Sveta Smirnova
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
Jean-François Gagné
 
InnoDB Performance Optimisation
InnoDB Performance Optimisation
Mydbops
 
Sharding Methods for MongoDB
Sharding Methods for MongoDB
MongoDB
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptx
NeoClova
 
My sql failover test using orchestrator
My sql failover test using orchestrator
YoungHeon (Roy) Kim
 
MySQL Shell - The Best MySQL DBA Tool
MySQL Shell - The Best MySQL DBA Tool
Miguel Araújo
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptx
NeoClova
 
How to upgrade like a boss to MySQL 8.0 - PLE19
How to upgrade like a boss to MySQL 8.0 - PLE19
Alkin Tezuysal
 
The Full MySQL and MariaDB Parallel Replication Tutorial
The Full MySQL and MariaDB Parallel Replication Tutorial
Jean-François Gagné
 
MariaDB 10.11 key features overview for DBAs
MariaDB 10.11 key features overview for DBAs
Federico Razzoli
 
Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0
Mydbops
 
Reducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQL
Kenny Gryp
 
Intro ProxySQL
Intro ProxySQL
I Goo Lee
 
High performance and high availability proxies for MySQL
High performance and high availability proxies for MySQL
Mydbops
 
How to upgrade like a boss to my sql 8.0?
How to upgrade like a boss to my sql 8.0?
Alkin Tezuysal
 
Galera cluster for high availability
Galera cluster for high availability
Mydbops
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바
NeoClova
 
InnoDB Internal
InnoDB Internal
mysqlops
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to Have
Sveta Smirnova
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
Jean-François Gagné
 
InnoDB Performance Optimisation
InnoDB Performance Optimisation
Mydbops
 
Sharding Methods for MongoDB
Sharding Methods for MongoDB
MongoDB
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptx
NeoClova
 
My sql failover test using orchestrator
My sql failover test using orchestrator
YoungHeon (Roy) Kim
 
MySQL Shell - The Best MySQL DBA Tool
MySQL Shell - The Best MySQL DBA Tool
Miguel Araújo
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptx
NeoClova
 

Similar to MySQL Performance for DevOps (20)

MySQL Performance for DevOps
MySQL Performance for DevOps
Sveta Smirnova
 
MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017
Ivan Zoratti
 
Running MySQL on Linux
Running MySQL on Linux
Great Wide Open
 
Performance optimisations PHP meetup Rotterdam
Performance optimisations PHP meetup Rotterdam
Dimitri Vanoverbeke
 
Percona Server 8.0
Percona Server 8.0
Laurynas Biveinis
 
Why are we excited about MySQL 8? / Петр Зайцев (Percona)
Why are we excited about MySQL 8? / Петр Зайцев (Percona)
Ontico
 
介绍 Percona 服务器 XtraDB 和 Xtrabackup
介绍 Percona 服务器 XtraDB 和 Xtrabackup
YUCHENG HU
 
OSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin Charles
NETWAYS
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016
Colin Charles
 
Infrastructure review - Shining a light on the Black Box
Infrastructure review - Shining a light on the Black Box
Miklos Szel
 
Fosdem managing my sql with percona toolkit
Fosdem managing my sql with percona toolkit
Frederic Descamps
 
Pldc2012 innodb architecture and internals
Pldc2012 innodb architecture and internals
mysqlops
 
Mysql ecosystem in 2019
Mysql ecosystem in 2019
Alkin Tezuysal
 
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Severalnines
 
MySQL Ecosystem in 2020
MySQL Ecosystem in 2020
Alkin Tezuysal
 
Peter Zaitsev "18 ways to fix MySQL bottlenecks"
Peter Zaitsev "18 ways to fix MySQL bottlenecks"
Fwdays
 
Percona Toolkit for Effective MySQL Administration
Percona Toolkit for Effective MySQL Administration
Mydbops
 
Percona Live UK 2014 Part III
Percona Live UK 2014 Part III
Alkin Tezuysal
 
Percona Server for MySQL 8.0 @ Percona Live 2019
Percona Server for MySQL 8.0 @ Percona Live 2019
Laurynas Biveinis
 
Webinar slides: The Holy Grail Webinar: Become a MySQL DBA - Database Perform...
Webinar slides: The Holy Grail Webinar: Become a MySQL DBA - Database Perform...
Severalnines
 
MySQL Performance for DevOps
MySQL Performance for DevOps
Sveta Smirnova
 
MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017
Ivan Zoratti
 
Performance optimisations PHP meetup Rotterdam
Performance optimisations PHP meetup Rotterdam
Dimitri Vanoverbeke
 
Why are we excited about MySQL 8? / Петр Зайцев (Percona)
Why are we excited about MySQL 8? / Петр Зайцев (Percona)
Ontico
 
介绍 Percona 服务器 XtraDB 和 Xtrabackup
介绍 Percona 服务器 XtraDB 和 Xtrabackup
YUCHENG HU
 
OSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin Charles
NETWAYS
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016
Colin Charles
 
Infrastructure review - Shining a light on the Black Box
Infrastructure review - Shining a light on the Black Box
Miklos Szel
 
Fosdem managing my sql with percona toolkit
Fosdem managing my sql with percona toolkit
Frederic Descamps
 
Pldc2012 innodb architecture and internals
Pldc2012 innodb architecture and internals
mysqlops
 
Mysql ecosystem in 2019
Mysql ecosystem in 2019
Alkin Tezuysal
 
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Severalnines
 
MySQL Ecosystem in 2020
MySQL Ecosystem in 2020
Alkin Tezuysal
 
Peter Zaitsev "18 ways to fix MySQL bottlenecks"
Peter Zaitsev "18 ways to fix MySQL bottlenecks"
Fwdays
 
Percona Toolkit for Effective MySQL Administration
Percona Toolkit for Effective MySQL Administration
Mydbops
 
Percona Live UK 2014 Part III
Percona Live UK 2014 Part III
Alkin Tezuysal
 
Percona Server for MySQL 8.0 @ Percona Live 2019
Percona Server for MySQL 8.0 @ Percona Live 2019
Laurynas Biveinis
 
Webinar slides: The Holy Grail Webinar: Become a MySQL DBA - Database Perform...
Webinar slides: The Holy Grail Webinar: Become a MySQL DBA - Database Perform...
Severalnines
 
Ad

More from Sveta Smirnova (20)

War Story: Removing Offensive Language from Percona Toolkit
War Story: Removing Offensive Language from Percona Toolkit
Sveta Smirnova
 
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
Sveta Smirnova
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and Monitoring
Sveta Smirnova
 
MySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for Developers
Sveta Smirnova
 
MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации багов
Sveta Smirnova
 
MySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your Business
Sveta Smirnova
 
Introduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
Производительность MySQL для DevOps
Производительность MySQL для DevOps
Sveta Smirnova
 
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
Sveta Smirnova
 
How to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tears
Sveta Smirnova
 
Modern solutions for modern database load: improvements in the latest MariaDB...
Modern solutions for modern database load: improvements in the latest MariaDB...
Sveta Smirnova
 
How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
Sveta Smirnova
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Sveta Smirnova
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with Galera
Sveta Smirnova
 
How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
Sveta Smirnova
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
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 ...
Sveta Smirnova
 
Что нужно знать о трёх топовых фичах MySQL
Что нужно знать о трёх топовых фичах MySQL
Sveta Smirnova
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?
Sveta Smirnova
 
War Story: Removing Offensive Language from Percona Toolkit
War Story: Removing Offensive Language from Percona Toolkit
Sveta Smirnova
 
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
Sveta Smirnova
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and Monitoring
Sveta Smirnova
 
MySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for Developers
Sveta Smirnova
 
MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации багов
Sveta Smirnova
 
MySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your Business
Sveta Smirnova
 
Introduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
Производительность MySQL для DevOps
Производительность MySQL для DevOps
Sveta Smirnova
 
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
Sveta Smirnova
 
How to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tears
Sveta Smirnova
 
Modern solutions for modern database load: improvements in the latest MariaDB...
Modern solutions for modern database load: improvements in the latest MariaDB...
Sveta Smirnova
 
How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
Sveta Smirnova
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Sveta Smirnova
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with Galera
Sveta Smirnova
 
How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
Sveta Smirnova
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
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 ...
Sveta Smirnova
 
Что нужно знать о трёх топовых фичах MySQL
Что нужно знать о трёх топовых фичах MySQL
Sveta Smirnova
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?
Sveta Smirnova
 
Ad

Recently uploaded (20)

Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
 
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
 
Key Challenges in Troubleshooting Customer On-Premise Applications
Key Challenges in Troubleshooting Customer On-Premise Applications
Tier1 app
 
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
WSO2
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Canva Pro Crack Free Download 2025-FREE LATEST
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
 
IObit Driver Booster Pro 12 Crack Latest Version Download
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Philip Schwarz
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
 
Best Practice for LLM Serving in the Cloud
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
 
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
 
Key Challenges in Troubleshooting Customer On-Premise Applications
Key Challenges in Troubleshooting Customer On-Premise Applications
Tier1 app
 
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
WSO2
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Canva Pro Crack Free Download 2025-FREE LATEST
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
 
IObit Driver Booster Pro 12 Crack Latest Version Download
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Philip Schwarz
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
 
Best Practice for LLM Serving in the Cloud
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 

MySQL Performance for DevOps

  • 1. MySQL Performance for DevOps Sveta Smirnova Principal Support Engineering Coordinator
  • 2. l • MySQL Support engineer • Author of • MySQL Troubleshooting • JSON UDF functions • FILTER clause for MySQL • Speaker • Percona Live, OOW, Fosdem, DevConf, HighLoad... Sveta Smirnova
  • 5. • Database server • 25+ years of history • Popular forks • Percona Server for MySQL • MariaDB Server • Replication support from the beginning Percona Operator for MySQL What is MySQL? 5 ©2022 | Percona
  • 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 - Connectors - Optimizer - Caches - Storage Engines - Management MySQL Architecture 6 ©2022 | Percona
  • 8. • SET [GLOBAL] var = NEW VALUE How to Change System Variables 8 ©2022 | Percona
  • 9. • SET [GLOBAL] var = NEW VALUE • Command-line option --var=new value How to Change System Variables 9 ©2022 | Percona
  • 10. • SET [GLOBAL] var = NEW VALUE • Command-line option --var=new value • Configuration file In the default location • Specified by option --defaults-file How to Change System Variables 10 ©2022 | Percona
  • 11. In deploy/cr.yaml spec: secretsName: my-cluster-secrets pxc: ... configuration: | [mysqld] wsrep_debug=CLIENT max_connections=250 How to Change with Kubernetes 11 ©2022 | Percona
  • 12. In deploy/cr.yaml In a ConfigMap kubectl create configmap cluster1-pxc --from-file=my.cnf How to Change with Kubernetes 12 ©2022 | Percona
  • 13. In deploy/cr.yaml In a ConfigMap Using a Secret Object How to Change with Kubernetes 13 ©2022 | Percona
  • 15. • Frequently accessed data • InnoDB buffer pool • MyRocks recently inserted data • Table and thread cache Memory is Faster than Disk 15 ©2022 | Percona
  • 16. • Frequently accessed data • InnoDB buffer pool • MyRocks recently inserted data • Table and thread cache • Temporary objects • Implicit temporary tables • Prepared statements • User variables Memory is Faster than Disk 16 ©2022 | Percona
  • 17. • Frequently accessed data • InnoDB buffer pool • MyRocks recently inserted data • Table and thread cache • Temporary objects • Implicit temporary tables • Prepared statements • User variables • Frequently accessed data should be in memory Memory is Faster than Disk 17 ©2022 | Percona
  • 18. • No swapping • sysctl vm.swappiness=1 System Memory Configuration 18 ©2022 | Percona
  • 19. • No swapping • sysctl vm.swappiness=1 • NUMA interleave • Enable in BIOS System Memory Configuration 19 ©2022 | Percona
  • 20. • No swapping • sysctl vm.swappiness=1 • NUMA interleave • Enable in BIOS • Kubernetes resources: requests: memory: 32G ... # limits: # memory: 32G System Memory Configuration 20 ©2022 | Percona
  • 21. • innodb buffer pool size • Ideally should hold active data set MySQL Memory Configuration 21 ©2022 | Percona
  • 22. • innodb buffer pool size • 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 MySQL Memory Configuration 22 ©2022 | Percona
  • 23. • innodb buffer pool size • 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 MySQL Memory Configuration 23 ©2022 | Percona
  • 24. • innodb buffer pool size • table open cache • table definition cache • Increase OS open files limit if needed MySQL Memory Configuration 24 ©2022 | Percona
  • 25. Disk
  • 26. • Tables • Log files • Engine • Replication • Diagnostic • Temporary files MySQL Stores Data on the Disk 26 ©2022 | Percona
  • 27. • Faster is better • SSD • NVMe • Spinning disk System Disk Configuration 27 ©2022 | Percona
  • 28. • Faster is better • SSD • NVMe • Spinning disk • Parallel writes System Disk Configuration 28 ©2022 | Percona
  • 29. • Faster is better • SSD • NVMe • Spinning disk • Parallel writes • Battery-backed cache System Disk Configuration 29 ©2022 | Percona
  • 30. • innodb log file size • Should hold changes for an hour InnoDB Disk Configuraiton 30 ©2022 | Percona
  • 31. • innodb log file size • Should hold changes for an hour • Too low InnoDB Disk Configuraiton 31 ©2022 | Percona
  • 32. • innodb log file size • Should hold changes for an hour • Good InnoDB Disk Configuraiton 32 ©2022 | Percona
  • 33. • innodb log file size • innodb io capacity • Default is too small for fast disks • Up to number of IOPS your disk can handle • Do not set too high! InnoDB Disk Configuraiton 33 ©2022 | Percona
  • 34. • innodb log file size • innodb io capacity • innodb flush method • In most cases: O DIRECT • Test on your filesystem! InnoDB Disk Configuraiton 34 ©2022 | Percona
  • 35. • Changing these compromize durability! Synchronization 35 ©2022 | Percona
  • 36. • Changing these compromize durability! • innodb flush log at trx commit 1: full ACID, default Synchronization 36 ©2022 | Percona
  • 37. • 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, Galera and InnoDB Clusters Synchronization 37 ©2022 | Percona
  • 38. • 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 38 ©2022 | Percona
  • 39. • 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 or 2 DDL can cause faster flushing Scheduling may delay flushing Synchronization 39 ©2022 | Percona
  • 40. • 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 40 ©2022 | Percona
  • 41. CPU
  • 42. • One thread per connection • CPU used only for active threads How MySQL Uses CPU 42 ©2022 | Percona
  • 43. • One thread per connection • CPU used only for active threads • Background work by storage engines How MySQL Uses CPU 43 ©2022 | Percona
  • 44. Server Storage Engine Connection and Engine Threads 44 ©2022 | Percona
  • 45. ? <= CPU cores? What Happens with Threads 45 ©2022 | Percona
  • 46. ? <= CPU cores? Yes Executed simultaneously What Happens with Threads 46 ©2022 | Percona
  • 47. ? <= CPU cores? Yes Executed simultaneously No Wait in a queue What Happens with Threads 47 ©2022 | Percona
  • 48. ? <= CPU cores? Yes Executed simultaneously No Wait in a queue ? Does the disk support parallel write? What Happens with Threads 48 ©2022 | Percona
  • 49. ? <= CPU cores? Yes Executed simultaneously No Wait in a queue ? Does the disk support parallel write? Yes Write happens What Happens with Threads 49 ©2022 | Percona
  • 50. ? <= 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 50 ©2022 | Percona
  • 51. • IO scheduler • [noop] or [deadline] • sudo echo noop > /sys/block/DISK/queue/scheduler or sudo echo deadline > /sys/block/DISK/queue/scheduler System CPU Configuration 51 ©2022 | Percona
  • 52. • IO scheduler • [noop] or [deadline] • sudo echo noop > /sys/block/DISK/queue/scheduler or sudo echo deadline > /sys/block/DISK/queue/scheduler • CPU governor • Set to performance System CPU Configuration 52 ©2022 | Percona
  • 53. • IO scheduler • [noop] or [deadline] • sudo echo noop > /sys/block/DISK/queue/scheduler or sudo echo deadline > /sys/block/DISK/queue/scheduler • CPU governor • Set to performance • More cores is better System CPU Configuration 53 ©2022 | Percona
  • 54. • Kubernetes resources: requests: cpu: "16" limits: cpu: "32" Kuberetes CPU Configuration 54 ©2022 | Percona
  • 55. • innodb thread concurrency • 0 or number of CPU cores Thread Pool MySQL CPU Configuration 55 ©2022 | Percona
  • 57. • User connections • Replication • Each replica creates one connection to the source server MySQL Uses Network for 57 ©2022 | Percona
  • 58. • As fast as possible • Speed of the line RTT • Bandwidth • Stability To avoid TCP packet re-submission Network Should Be 58 ©2022 | Percona
  • 59. • 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 On the Internet connection 59 ©2022 | Percona
  • 61. • You communicate with database using queries • Even via NoSQL interface • They are not SQL queries, but still queries Heart of the application 61 ©2022 | Percona
  • 62. • You communicate with database using queries • Even via NoSQL interface • They are not SQL queries, but still queries • Data, that you request, matters • 1,000,000,000 rows vs 1 row Heart of the application 62 ©2022 | Percona
  • 63. Query sent Connection Pool: Authentication, Caches; SQL interface; Parser Optimizer Storage engines Hardware Query execution workflow 63 ©2022 | Percona
  • 65. mysql> SELECT first_name, last_name, salary FROM employees -> JOIN salaries USING(emp_no) -> WHERE salary = (SELECT MAX(salary) FROM salaries); +------------+-----------+--------+ | first_name | last_name | salary | +------------+-----------+--------+ | Tokuyasu | Pesch | 158220 | +------------+-----------+--------+ 1 row in set (2,05 sec) Effect of an Index 65 ©2022 | Percona
  • 66. mysql> ALTER TABLE salaries ADD INDEX(salary); Query OK, 0 rows affected (9,65 sec) Records: 0 Duplicates: 0 Warnings: 0 Effect of an Index 66 ©2022 | Percona
  • 67. mysql> SELECT first_name, last_name, salary FROM employees -> JOIN salaries USING(emp_no) -> WHERE salary = (SELECT MAX(salary) FROM salaries); +------------+-----------+--------+ | first_name | last_name | salary | +------------+-----------+--------+ | Tokuyasu | Pesch | 158220 | +------------+-----------+--------+ 1 row in set (0,00 sec) Effect of an Index 67 ©2022 | Percona
  • 68. MySQL Query Tuning for DevOps How MySQL Indexes Work 68 ©2022 | Percona
  • 69. • Temporary tables • tmp table size • max heap table size • default tmp storage engine Optimizer Configuration 69 ©2022 | Percona
  • 70. • Temporary tables • Buffers for query execution • join buffer size JOIN conditions, not using indexes Optimizer Configuration 70 ©2022 | Percona
  • 71. • 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 Optimizer Configuration 71 ©2022 | Percona
  • 72. • Temporary tables • Buffers for query execution • join buffer size • read buffer size • read rnd buffer size Multi-Range Read optimization Optimizer Configuration 72 ©2022 | Percona
  • 73. • Temporary tables • Buffers for query execution • join buffer size • read buffer size • read rnd buffer size • select into buffer size SELECT INTO OUTFILE SELECT INTO DUMPFILE Optimizer Configuration 73 ©2022 | Percona
  • 74. • 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 Optimizer Configuration 74 ©2022 | Percona
  • 75. • 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! Optimizer Configuration 75 ©2022 | Percona
  • 76. • Hardware RAM: more is better Disk: SSD or NVMe CPU: more cores, better concurrency Net: highest speed possible Conclusion 76 ©2022 | Percona
  • 77. • 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 77 ©2022 | Percona
  • 78. • Hardware • Configuration • Query Performance • Add indexes • Adjust Optimization buffers tmp table size join buffer size read buffer size read rnd buffer size select into buffer size sort buffer size Conclusion 78 ©2022 | Percona
  • 79. Troubleshooting hardware resources Troubleshooting configuration issues MySQL Query Tuning for DevOps Percona Monitoring and Management Percona Kubernetes Operators More information 79 ©2022 | Percona