0% found this document useful (0 votes)
107 views32 pages

Innodb Performance Optimisation: Mydbops Database Meetup

Karthik P R from Mydbops presented on InnoDB performance optimization. He discussed InnoDB's history and architecture, including its B-Tree indexing, buffer pool, change buffer, log buffer, and adaptive hash index. He provided recommendations for tuning the buffer pool size and configuration, log file size, flush methods, isolation levels, and other variables to optimize InnoDB performance based on the workload. Attendees were advised to ensure primary keys on tables, avoid shared tablespaces, consider partitioning large tables, and tweak the top 4-6 variables for most performance gains.

Uploaded by

Jackey Lin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views32 pages

Innodb Performance Optimisation: Mydbops Database Meetup

Karthik P R from Mydbops presented on InnoDB performance optimization. He discussed InnoDB's history and architecture, including its B-Tree indexing, buffer pool, change buffer, log buffer, and adaptive hash index. He provided recommendations for tuning the buffer pool size and configuration, log file size, flush methods, isolation levels, and other variables to optimize InnoDB performance based on the workload. Attendees were advised to ensure primary keys on tables, avoid shared tablespaces, consider partitioning large tables, and tweak the top 4-6 variables for most performance gains.

Uploaded by

Jackey Lin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

InnoDB Performance Optimisation

Mydbops Database
Meetup

Presented by
Karthik P R

www.mydbops.com [email protected]
About Mydbops

Mydbops is into MySQL/MongoDB Support and Consulting. It is founded by experts


who have scaled database at Yahoo! ,Percona and Datavail. We are providing an
expert level support and 24*7 monitoring for MySQL databases and its related
technologies like MariaDB , Percona ( also clustering ) . We support modern
database technologies in MySQL which includes Galera ( Clustering ), Group
Replication , SQL aware Load balancers like Maxscale / ProxySQL.
About Me

CEO / DB Architect
Agenda
● InnoDB History

● InnoDB Features

● InnoDB Architecture

● InnoDB Performance Tuning

● General Recommendations
InnoDB History
● Introduced in 1995 by Finland based company called Innobase

● In 2000, Innobase started collaboration with MySQL AB

● Oracle acquired Innobase in October 2005

● Become Default storage engine for Mysql 5.5 in 2010

● JSON Support introduced in MySQL 5.7

● Separated Undo Log in MySQL 8.0


InnoDB Features
● ACID transaction Engine

● B+Tree Based Indexing

● Index Organised tables

● MVCC Support.

● Efficiently designed for OLTP workload.

● Foreign Key Support.

● Virtual column and Full text search support


InnoDB Architecture
Why InnoDB Architecture ?

● Fine Tuning needs Architecture Knowledge

● Awareness about Internals

● Data Structures ( on disk / In Memory )

● Transaction , locking . MVCC

● Checkpoint , Flushing , Purging


InnoDB Architecture
InnoDB Architecture
InnoDB Architecture
InnoDB Architecture
InnoDB Performance Tuning
InnoDB Buffer Pool

● Global memory for InnoDB

● Caches the Index and data pages

● Locks and Dictionary cache

● Adaptive hash index

● Change buffering

InnoDB buffer pool can be resized online in MySQL 5.7


InnoDB Performance Tuning
InnoDB Buffer Pool

● LRU based Flushing

● Young and Old ( LRU )

● O_Direct is best flushing

● Compressed and Uncompressed


pages in memory
InnoDB Performance Tuning
InnoDB Buffer Pool Config

● InnoDB_buffer_pool_size (70%-80% of Memory)

● innodb_buffer_pool_instances ( No of CPU core )

● innodb_buffer_pool_dump_pct ( > 70 % is good )

● innodb_buffer_pool_chunk_size
InnoDB Performance Tuning
InnODB Change Buffer
InnoDB Performance Tuning
InnoDB Change Buffer

● Present on both Disk and in memory

● Buffer pool hold Change buffer

● B+tree writes are buffered

● Restrict the size of change buffer

Innodb_change_buffering=all
Innodb_change_buffer_max_size ( 20-30 )
InnoDB Performance Tuning
InnoDB Adaptive Hash Index

● Hash table lookup to B+tree

● Fasten the access inside buffer pool

● Works for Primary and Secondary keys ( OLTP )

● Do not work well with text or queries with multiple join

innodb_adaptive_hash_index
innodb_adaptive_hash_index_parts
InnoDB Performance Tuning
InnoDB Log Buffer

● Holds the data in memory before flushing to disk

● Larger log file reduce contention

● Can Flush on every commit ( for Durability )

● Defaults work pretty well for most workloads.

Innodb_log_buffer_size
InnoDB Performance Tuning
InnoDB flush log at trx commit

● Controls the flushing of data from log buffer to log file.

● Supports 3 different flush behaviour

● More durability set is as default value 1

● innodb_flush_log_at_timeout controls the flush frequency


InnoDB Performance Tuning
InnoDB Flush log at trx commit
InnoDB Performance Tuning
InnoDB log File Size

● Two physical log files of equal size.

● Records all changes to tablespace

● Helps in crash recovery

● Overwritten when the page is flushed from buffer pool ( Checkpoint )

● innodb_log_files_in_group controls the number of files


InnoDB Performance Tuning
InnoDB log File Size

● Two physical log files of equal size.

● Records all changes to tablespace

● Helps in crash recovery

● Overwritten when the page is flushed from buffer pool ( Checkpoint )

● innodb_log_files_in_group controls the number of redo log files


InnoDB Performance Tuning
InnoDB log File Size

● Larger log file better write performance

● Tradeoff longer recovery time

● Defaults is 48 MB is low for any production workload

innodb_log_file_size=(>512M) ( Size can be calculated by innodb_os_log_written)


innodb_log_files_in_group=2

Note : PMM calculates very efficiently co-relate with checkpoint


InnoDB Performance Tuning
Innodb Flush method

● How data to InnoDB data files and log files is flushed ?

● default is FSYNC

● It can be numeral in MySQL 8.0 ( 0,1,2,3,4,5)

innodb_flush_method=O_DIRECT(4)
InnoDB Performance Tuning
Isolation Level

● How transaction isolated from each other ?

● A major role in locking along with work load

● Default Repeatable read.

transaction_isolation=read_committed/repeatable_read
InnoDB Performance Tuning
innodb_dedicated_server (8.0)

● Manages major tuning parameter based on your system memory

○ innodb_buffer_pool_size
○ innodb_log_file_size
○ innodb_log_file_in_group
○ innodb_flush_method
● Enable it only on dedicated MySQL server.
InnoDB Performance Tuning
● innodb_io_capacity

● innodb_io_capacity_max

● innodb_doublewrite

● innodb_checksum_algorithm

● innodb_autoinc_lock_mode

● innodb_purge_threads
InnoDB Performance Tuning
● innodb_flush_neighbors

● innodb_stats_on_metadata

● innodb_stats_persistent_sample_pages

● innodb_max_dirty_pages_pct

● innodb_max_purge_lag

● innodb_max_purge_lag_delay
InnoDB Performance Tuning
● innodb_thread_concurrency

● innodb_concurrency_tickets

● innodb_file_format

● innodb_page_size

● innodb_write_io_threads

● innodb_read_io_threads
General Recommendations
● Ensure there is primary key or Unique key in all tables.

● Smaller the primary key better they will be.

● Avoid shared tablespace for innodb tables.

● Consider partition for huge tables ( query might need changes ).

● Do not make config changes without knowing its production impact.

● 80-90% of performance gain can be achieved by tweaking 4-6 variables.


Contact us

[email protected]
www.mydbops.com
080-48505683
Thank You

You might also like