SlideShare una empresa de Scribd logo
1 de 31
MYSQL Performance Tuning



Philip Zhong



© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   1
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   2
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   3
• Types of I/O schedulers (introduced in 2.6.10: RHEL5)

        – noop: Sorting incoming i/o requests by logical block
       address, that’s all
        – deadlilne: Prioritize read (sync) requests rather than write
       requests (async) to some extent (to avoid “write-starving-reads”
       problem)
         – cfq(default): Fairly scheduling i/o requests per i/o thread
         – anticipatory: Removed in 2.6.33 (bad scheduler. Don’t use it)
• Default is cfq, but noop / deadline is better in many cases

         # echo noop > /sys/block/sdX/queue/scheduler


© 2011 Cisco and/or its affiliates. All rights reserved.                 Cisco Confidential   4
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   5
• Make sure to use Flash Back Write Cache(FBWC) or
        Battery Backed up Write Cache (BBWC) on raid cards
            – 10,000+ fsync() per second, without BBWC less than 200 on HDD
            – Disable write cache on disks for safety reasons
• Do not set “write barrier” on file systems (enabled by default in some cases)
            – Write-through to disks even though BBWC is enabled (very slow)
            – ext3: mount -o barrier=0
            – xfs: mount -o nobarrier
            – drbd: no-disk-barrier in drbd.conf
• Consider disabling atime updates on files and directories
            – mount -o noatime,nodiratime

© 2011 Cisco and/or its affiliates. All rights reserved.                       Cisco Confidential   6
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   7
• Put sequentially written files on HDD
          – ibdata, ib_logfile, binary log files
          – HDD is fast enough for sequential writes
          – Write performance deterioration can be mitigated
          – Life expectancy of SSD will be longer
• Put randomly accessed files on SSD
          – *ibd files, index files(MYI), data files(MYD)
          – SSD is 10x -100x faster for random reads than HDD
          – Archive less active tables/records to HDD
          – SSD is still much expensive than HDD
• Use 5.1 InnoDB Plugin
          – Higher scalability & concurrency matters on faster storage
© 2011 Cisco and/or its affiliates. All rights reserved.                 Cisco Confidential   8
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   9
• RAM access speed is much faster than HDD/SSD

       RAM: -60ns
       HDD: -5ms
       SSD: 100-500us
• 16-100+GB RAM is now pretty common

• Sharding hot application data is important

• Do not create unnecessary indexes

• Delete records or move to archived tables, to keep hot tables
       smaller


© 2011 Cisco and/or its affiliates. All rights reserved.     Cisco Confidential   10
• Network

• CPU

• ……




© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   11
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   12
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   13
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   14
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   15
• EXPLAIN SELECT

         – Tells you what MYSQL is thinking
         – Which keys (indexes) can it use
         – Which keys will it use
         – How many rows must it examine (roughly)




© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   16
• EXPLAIN doesn’t tell you anything about how triggers, stored
       functions, or UDFs will affect your query.
• It doesn’t work for stored procedures, although you can extract
       the queries manually and EXPLAIN them individually.
• Some of the statistics it shows are estimates and can be very
       inaccurate.
• It doesn’t show you everything there is to know about a query’s
       execution plan.
• It doesn’t distinguish between some things with the same name.
       For example, it uses “file sort” for in-memory sorts and for
       temporary files, and it displays “Using temporary” for temporary
       tables on disk and in memory. It can be misleading

© 2011 Cisco and/or its affiliates. All rights reserved.          Cisco Confidential   17
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   18
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   19
SIMPLE:Simple SELECT (not using UNION or subqueries)
                     PRIMARY: outer select.
                     UNION:Second or later SELECT statement in a UNION
                     DEPENDENT UNION:Second or later SELECT statement in a UNION,
                     dependent on outer query
                     UNION RESULT:Result of a UNION.
                     SUBQUERY:First SELECT in subquery
                     DEPENDENT SUBQUERY: First SELECT in subquery, dependent on outer query
                     DERIVED:Derived table SELECT (subquery in FROM clause)
                     UNCACHEABLE SUBQUERY:A subquery for which the result cannot be cached and
                     must be reevaluated for each row of the outer query
                     UNCACHEABLE UNION:The second or later select in a UNION that belongs to an
                       uncacheable subquery (see UNCACHEABLE SUBQUERY)


© 2011 Cisco and/or its affiliates. All rights reserved.                                 Cisco Confidential   20
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   21
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   22
• Mysql>SET profiling = 1;

• Mysql>SHOW PROFILES;

• Mysql>SHOW PROFILE CPU FOR QUERY 1;




© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   23
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   24
select tag_id,tag_text from Tags where tag_id+1>1 and tag_id+1<11;




© 2011 Cisco and/or its affiliates. All rights reserved.            Cisco Confidential   25
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   26
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   27
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   28
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   29
© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   30
Thank you.




© 2011 Cisco and/or its affiliates. All rights reserved.   Cisco Confidential   31

Más contenido relacionado

Destacado

MySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsMySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsOSSCube
 
MySQL Performance Tuning für Entwickler
MySQL Performance Tuning für EntwicklerMySQL Performance Tuning für Entwickler
MySQL Performance Tuning für EntwicklerFromDual GmbH
 
MySQL Server Settings Tuning
MySQL Server Settings TuningMySQL Server Settings Tuning
MySQL Server Settings Tuningguest5ca94b
 
浅析My sql事务隔离级别与锁 seanlook
浅析My sql事务隔离级别与锁 seanlook浅析My sql事务隔离级别与锁 seanlook
浅析My sql事务隔离级别与锁 seanlook晓 周
 
MySQL Performance Tuning Variables
MySQL Performance Tuning VariablesMySQL Performance Tuning Variables
MySQL Performance Tuning VariablesFromDual GmbH
 
MySQL Performance Tuning
MySQL Performance TuningMySQL Performance Tuning
MySQL Performance TuningFromDual GmbH
 
Performance Tuning Best Practices
Performance Tuning Best PracticesPerformance Tuning Best Practices
Performance Tuning Best Practiceswebhostingguy
 
Join-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQLJoin-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQLZendCon
 
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查询优化浅析
MySQL查询优化浅析MySQL查询优化浅析
MySQL查询优化浅析frogd
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance TuningMark Swarbrick
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain ExplainedJeremy Coates
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)Aurimas Mikalauskas
 
Assessing enablers and constrainers of graduation
Assessing enablers and constrainers of graduationAssessing enablers and constrainers of graduation
Assessing enablers and constrainers of graduationfutureagricultures
 
Новогодний счастливый купон
Новогодний счастливый купонНовогодний счастливый купон
Новогодний счастливый купонЕлена Шальнова
 
Ig1 assignment 2011_to_2012_updated_17.01.12
Ig1 assignment 2011_to_2012_updated_17.01.12Ig1 assignment 2011_to_2012_updated_17.01.12
Ig1 assignment 2011_to_2012_updated_17.01.12FirstClassProductions
 

Destacado (20)

MySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsMySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 Tips
 
MySQL Performance Tuning für Entwickler
MySQL Performance Tuning für EntwicklerMySQL Performance Tuning für Entwickler
MySQL Performance Tuning für Entwickler
 
MySQL Server Settings Tuning
MySQL Server Settings TuningMySQL Server Settings Tuning
MySQL Server Settings Tuning
 
浅析My sql事务隔离级别与锁 seanlook
浅析My sql事务隔离级别与锁 seanlook浅析My sql事务隔离级别与锁 seanlook
浅析My sql事务隔离级别与锁 seanlook
 
Perf Tuning Short
Perf Tuning ShortPerf Tuning Short
Perf Tuning Short
 
MySQL Performance Tuning Variables
MySQL Performance Tuning VariablesMySQL Performance Tuning Variables
MySQL Performance Tuning Variables
 
MySQL Performance Tuning
MySQL Performance TuningMySQL Performance Tuning
MySQL Performance Tuning
 
Performance Tuning Best Practices
Performance Tuning Best PracticesPerformance Tuning Best Practices
Performance Tuning Best Practices
 
Join-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQLJoin-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQL
 
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查询优化浅析
MySQL查询优化浅析MySQL查询优化浅析
MySQL查询优化浅析
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance Tuning
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain Explained
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
How to Design Indexes, Really
How to Design Indexes, ReallyHow to Design Indexes, Really
How to Design Indexes, Really
 
Assessing enablers and constrainers of graduation
Assessing enablers and constrainers of graduationAssessing enablers and constrainers of graduation
Assessing enablers and constrainers of graduation
 
affTA03 - BAB III
affTA03 - BAB IIIaffTA03 - BAB III
affTA03 - BAB III
 
Adore global pvt ltd
Adore global pvt ltdAdore global pvt ltd
Adore global pvt ltd
 
Новогодний счастливый купон
Новогодний счастливый купонНовогодний счастливый купон
Новогодний счастливый купон
 
Ig1 assignment 2011_to_2012_updated_17.01.12
Ig1 assignment 2011_to_2012_updated_17.01.12Ig1 assignment 2011_to_2012_updated_17.01.12
Ig1 assignment 2011_to_2012_updated_17.01.12
 

Similar a Mysql performance tuning

DEFCON 23 - Etienne Martineau - inter vm data exfiltration
DEFCON 23 - Etienne Martineau - inter vm data exfiltrationDEFCON 23 - Etienne Martineau - inter vm data exfiltration
DEFCON 23 - Etienne Martineau - inter vm data exfiltrationFelipe Prado
 
Puppet for Production in WebEx - PuppetConf 2013
Puppet for Production in WebEx - PuppetConf 2013Puppet for Production in WebEx - PuppetConf 2013
Puppet for Production in WebEx - PuppetConf 2013Puppet
 
Cisco UCS Application acceleration data optimization
Cisco UCS Application acceleration data optimizationCisco UCS Application acceleration data optimization
Cisco UCS Application acceleration data optimizationsolarisyougood
 
BigData Clusters Redefined
BigData Clusters RedefinedBigData Clusters Redefined
BigData Clusters RedefinedDataWorks Summit
 
Considerations for Operating An OpenStack Cloud
Considerations for Operating An OpenStack CloudConsiderations for Operating An OpenStack Cloud
Considerations for Operating An OpenStack CloudMark Voelker
 
Devicemgmt
DevicemgmtDevicemgmt
Devicemgmtxyxz
 
Oracle Solaris 11.1 New Features
Oracle Solaris 11.1 New FeaturesOracle Solaris 11.1 New Features
Oracle Solaris 11.1 New FeaturesOrgad Kimchi
 
Chapter 2 Configure a Network Operating System
Chapter 2 Configure a Network Operating SystemChapter 2 Configure a Network Operating System
Chapter 2 Configure a Network Operating Systemnewbie2019
 
Brandon-Ellis-Showcase-PPT
Brandon-Ellis-Showcase-PPTBrandon-Ellis-Showcase-PPT
Brandon-Ellis-Showcase-PPTBrandon Ellis
 
BRKINI-3287.pdf
BRKINI-3287.pdfBRKINI-3287.pdf
BRKINI-3287.pdftuancq77
 
제3회난공불락 오픈소스 인프라세미나 - lustre
제3회난공불락 오픈소스 인프라세미나 - lustre제3회난공불락 오픈소스 인프라세미나 - lustre
제3회난공불락 오픈소스 인프라세미나 - lustreTommy Lee
 
Cisco UCS (Unified Computing System)
Cisco UCS (Unified Computing System)Cisco UCS (Unified Computing System)
Cisco UCS (Unified Computing System)NetWize
 
I can\'t believe this is butter - A Tour of btrfs
I can\'t believe this is butter - A Tour of btrfsI can\'t believe this is butter - A Tour of btrfs
I can\'t believe this is butter - A Tour of btrfsAvi Miller
 
I/O Microbenchmarking with Oracle in Mind
I/O Microbenchmarking with Oracle in MindI/O Microbenchmarking with Oracle in Mind
I/O Microbenchmarking with Oracle in MindBob Sneed
 
Поиск и устранение неисправностей в вычислительной системе Cisco UCS
Поиск и устранение неисправностей в вычислительной системе Cisco UCSПоиск и устранение неисправностей в вычислительной системе Cisco UCS
Поиск и устранение неисправностей в вычислительной системе Cisco UCSCisco Russia
 
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with AnsibleManaging Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansiblefmaccioni
 
AnsibleFest London 2016 - managing your cisco datacenter network with ansible
AnsibleFest London 2016 - managing your cisco datacenter network with ansibleAnsibleFest London 2016 - managing your cisco datacenter network with ansible
AnsibleFest London 2016 - managing your cisco datacenter network with ansiblefmaccioni
 
Considerations for Operating an OpenStack Cloud
Considerations for Operating an OpenStack CloudConsiderations for Operating an OpenStack Cloud
Considerations for Operating an OpenStack CloudAll Things Open
 

Similar a Mysql performance tuning (20)

DEFCON 23 - Etienne Martineau - inter vm data exfiltration
DEFCON 23 - Etienne Martineau - inter vm data exfiltrationDEFCON 23 - Etienne Martineau - inter vm data exfiltration
DEFCON 23 - Etienne Martineau - inter vm data exfiltration
 
Puppet for Production in WebEx - PuppetConf 2013
Puppet for Production in WebEx - PuppetConf 2013Puppet for Production in WebEx - PuppetConf 2013
Puppet for Production in WebEx - PuppetConf 2013
 
Cisco UCS Application acceleration data optimization
Cisco UCS Application acceleration data optimizationCisco UCS Application acceleration data optimization
Cisco UCS Application acceleration data optimization
 
BigData Clusters Redefined
BigData Clusters RedefinedBigData Clusters Redefined
BigData Clusters Redefined
 
Considerations for Operating An OpenStack Cloud
Considerations for Operating An OpenStack CloudConsiderations for Operating An OpenStack Cloud
Considerations for Operating An OpenStack Cloud
 
Devicemgmt
DevicemgmtDevicemgmt
Devicemgmt
 
Oracle Solaris 11.1 New Features
Oracle Solaris 11.1 New FeaturesOracle Solaris 11.1 New Features
Oracle Solaris 11.1 New Features
 
Chapter 2 Configure a Network Operating System
Chapter 2 Configure a Network Operating SystemChapter 2 Configure a Network Operating System
Chapter 2 Configure a Network Operating System
 
Brandon-Ellis-Showcase-PPT
Brandon-Ellis-Showcase-PPTBrandon-Ellis-Showcase-PPT
Brandon-Ellis-Showcase-PPT
 
BRKINI-3287.pdf
BRKINI-3287.pdfBRKINI-3287.pdf
BRKINI-3287.pdf
 
제3회난공불락 오픈소스 인프라세미나 - lustre
제3회난공불락 오픈소스 인프라세미나 - lustre제3회난공불락 오픈소스 인프라세미나 - lustre
제3회난공불락 오픈소스 인프라세미나 - lustre
 
Cisco UCS (Unified Computing System)
Cisco UCS (Unified Computing System)Cisco UCS (Unified Computing System)
Cisco UCS (Unified Computing System)
 
I can\'t believe this is butter - A Tour of btrfs
I can\'t believe this is butter - A Tour of btrfsI can\'t believe this is butter - A Tour of btrfs
I can\'t believe this is butter - A Tour of btrfs
 
I/O Microbenchmarking with Oracle in Mind
I/O Microbenchmarking with Oracle in MindI/O Microbenchmarking with Oracle in Mind
I/O Microbenchmarking with Oracle in Mind
 
Nagios-yating
Nagios-yatingNagios-yating
Nagios-yating
 
Поиск и устранение неисправностей в вычислительной системе Cisco UCS
Поиск и устранение неисправностей в вычислительной системе Cisco UCSПоиск и устранение неисправностей в вычислительной системе Cisco UCS
Поиск и устранение неисправностей в вычислительной системе Cisco UCS
 
Managing Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with AnsibleManaging Your Cisco Datacenter Network with Ansible
Managing Your Cisco Datacenter Network with Ansible
 
AnsibleFest London 2016 - managing your cisco datacenter network with ansible
AnsibleFest London 2016 - managing your cisco datacenter network with ansibleAnsibleFest London 2016 - managing your cisco datacenter network with ansible
AnsibleFest London 2016 - managing your cisco datacenter network with ansible
 
Considerations for Operating an OpenStack Cloud
Considerations for Operating an OpenStack CloudConsiderations for Operating an OpenStack Cloud
Considerations for Operating an OpenStack Cloud
 
Cisco DCACI
Cisco DCACICisco DCACI
Cisco DCACI
 

Más de Philip Zhong

How to Implement Distributed Data Store
How to Implement Distributed Data Store How to Implement Distributed Data Store
How to Implement Distributed Data Store Philip Zhong
 
MongoDB Knowledge Shareing
MongoDB Knowledge ShareingMongoDB Knowledge Shareing
MongoDB Knowledge ShareingPhilip Zhong
 
Adapter Poxy Pattern
Adapter Poxy PatternAdapter Poxy Pattern
Adapter Poxy PatternPhilip Zhong
 
How to estimate_oracle_cost
How to estimate_oracle_costHow to estimate_oracle_cost
How to estimate_oracle_costPhilip Zhong
 
Mongo db program_installation_guide
Mongo db program_installation_guideMongo db program_installation_guide
Mongo db program_installation_guidePhilip Zhong
 
Mongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guideMongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guidePhilip Zhong
 
Vitess percona 2012
Vitess percona 2012Vitess percona 2012
Vitess percona 2012Philip Zhong
 
Distributed_Database_System
Distributed_Database_SystemDistributed_Database_System
Distributed_Database_SystemPhilip Zhong
 
Mysql5.1 character set testing
Mysql5.1 character set testingMysql5.1 character set testing
Mysql5.1 character set testingPhilip Zhong
 
Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8Philip Zhong
 
Mysql handle socket
Mysql handle socketMysql handle socket
Mysql handle socketPhilip Zhong
 

Más de Philip Zhong (11)

How to Implement Distributed Data Store
How to Implement Distributed Data Store How to Implement Distributed Data Store
How to Implement Distributed Data Store
 
MongoDB Knowledge Shareing
MongoDB Knowledge ShareingMongoDB Knowledge Shareing
MongoDB Knowledge Shareing
 
Adapter Poxy Pattern
Adapter Poxy PatternAdapter Poxy Pattern
Adapter Poxy Pattern
 
How to estimate_oracle_cost
How to estimate_oracle_costHow to estimate_oracle_cost
How to estimate_oracle_cost
 
Mongo db program_installation_guide
Mongo db program_installation_guideMongo db program_installation_guide
Mongo db program_installation_guide
 
Mongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guideMongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guide
 
Vitess percona 2012
Vitess percona 2012Vitess percona 2012
Vitess percona 2012
 
Distributed_Database_System
Distributed_Database_SystemDistributed_Database_System
Distributed_Database_System
 
Mysql5.1 character set testing
Mysql5.1 character set testingMysql5.1 character set testing
Mysql5.1 character set testing
 
Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8
 
Mysql handle socket
Mysql handle socketMysql handle socket
Mysql handle socket
 

Último

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

Último (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Mysql performance tuning

  • 1. MYSQL Performance Tuning Philip Zhong © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 1
  • 2. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 2
  • 3. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 3
  • 4. • Types of I/O schedulers (introduced in 2.6.10: RHEL5) – noop: Sorting incoming i/o requests by logical block address, that’s all – deadlilne: Prioritize read (sync) requests rather than write requests (async) to some extent (to avoid “write-starving-reads” problem) – cfq(default): Fairly scheduling i/o requests per i/o thread – anticipatory: Removed in 2.6.33 (bad scheduler. Don’t use it) • Default is cfq, but noop / deadline is better in many cases # echo noop > /sys/block/sdX/queue/scheduler © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 4
  • 5. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 5
  • 6. • Make sure to use Flash Back Write Cache(FBWC) or Battery Backed up Write Cache (BBWC) on raid cards – 10,000+ fsync() per second, without BBWC less than 200 on HDD – Disable write cache on disks for safety reasons • Do not set “write barrier” on file systems (enabled by default in some cases) – Write-through to disks even though BBWC is enabled (very slow) – ext3: mount -o barrier=0 – xfs: mount -o nobarrier – drbd: no-disk-barrier in drbd.conf • Consider disabling atime updates on files and directories – mount -o noatime,nodiratime © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 6
  • 7. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 7
  • 8. • Put sequentially written files on HDD – ibdata, ib_logfile, binary log files – HDD is fast enough for sequential writes – Write performance deterioration can be mitigated – Life expectancy of SSD will be longer • Put randomly accessed files on SSD – *ibd files, index files(MYI), data files(MYD) – SSD is 10x -100x faster for random reads than HDD – Archive less active tables/records to HDD – SSD is still much expensive than HDD • Use 5.1 InnoDB Plugin – Higher scalability & concurrency matters on faster storage © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 8
  • 9. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 9
  • 10. • RAM access speed is much faster than HDD/SSD RAM: -60ns HDD: -5ms SSD: 100-500us • 16-100+GB RAM is now pretty common • Sharding hot application data is important • Do not create unnecessary indexes • Delete records or move to archived tables, to keep hot tables smaller © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 10
  • 11. • Network • CPU • …… © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 11
  • 12. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 12
  • 13. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 13
  • 14. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 14
  • 15. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 15
  • 16. • EXPLAIN SELECT – Tells you what MYSQL is thinking – Which keys (indexes) can it use – Which keys will it use – How many rows must it examine (roughly) © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 16
  • 17. • EXPLAIN doesn’t tell you anything about how triggers, stored functions, or UDFs will affect your query. • It doesn’t work for stored procedures, although you can extract the queries manually and EXPLAIN them individually. • Some of the statistics it shows are estimates and can be very inaccurate. • It doesn’t show you everything there is to know about a query’s execution plan. • It doesn’t distinguish between some things with the same name. For example, it uses “file sort” for in-memory sorts and for temporary files, and it displays “Using temporary” for temporary tables on disk and in memory. It can be misleading © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 17
  • 18. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 18
  • 19. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 19
  • 20. SIMPLE:Simple SELECT (not using UNION or subqueries) PRIMARY: outer select. UNION:Second or later SELECT statement in a UNION DEPENDENT UNION:Second or later SELECT statement in a UNION, dependent on outer query UNION RESULT:Result of a UNION. SUBQUERY:First SELECT in subquery DEPENDENT SUBQUERY: First SELECT in subquery, dependent on outer query DERIVED:Derived table SELECT (subquery in FROM clause) UNCACHEABLE SUBQUERY:A subquery for which the result cannot be cached and must be reevaluated for each row of the outer query UNCACHEABLE UNION:The second or later select in a UNION that belongs to an uncacheable subquery (see UNCACHEABLE SUBQUERY) © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 20
  • 21. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 21
  • 22. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 22
  • 23. • Mysql>SET profiling = 1; • Mysql>SHOW PROFILES; • Mysql>SHOW PROFILE CPU FOR QUERY 1; © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 23
  • 24. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 24
  • 25. select tag_id,tag_text from Tags where tag_id+1>1 and tag_id+1<11; © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 25
  • 26. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 26
  • 27. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 27
  • 28. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 28
  • 29. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 29
  • 30. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 30
  • 31. Thank you. © 2011 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 31

Notas del editor

  1. 1)AnticipatoryThe anticipatory I/O elevator was created based on the assumption of a block device withonly one physical seek head (for example a single SATA drive). The anticipatory elevatoruses the deadline mechanism described in more detail below plus an anticipationheuristic. As the name suggests, the anticipatory I/O elevator “anticipates” I/O andattempts to write it in single, bigger streams to the disk instead of multiple very smallrandom disk accesses. The anticipation heuristic may cause latency for write I/O. It isclearly tuned for high throughput on general purpose systems such as the averagepersonal computer. Up to kernel release 2.6.18 the anticipatory elevator is the standardI/O scheduler. However most Enterprise Linux distributions default to the CFQ elevator.2)Complete Fair Queuing (CFQ)The CFQ elevator implements a QoS (Quality of Service) policy for processes bymaintaining per-process I/O queues. The CFQ elevator is well suited for large multiusersystems with a lot of competing processes. It aggressively attempts to avoid starvation ofprocesses and features low latency. Starting with kernel release 2.6.18 the improved CFQelevator is the default I/O scheduler.Depending on the system setup and the workload characteristics, the CFQ scheduler canslowdown a single main application, for example a massive database with its fairnessoriented algorithms. The default configuration handles the fairness based on processgroups which compete against each other. For example a single database and all writesthrough the page cache (all pdflush instances are in one pgroup) are considered as asingle application by CFQ that could compete against many background processes. It canbe useful to experiment with I/O scheduler subconfigurations and/or the deadlinescheduler in such cases.3)DeadlineThe deadline elevator is a cyclic elevator (round robin) with a deadline algorithm thatprovides a near real-time behavior of the I/O subsystem. The deadline elevator offersexcellent request latency while maintaining good disk throughput. The implementation ofthe deadline algorithm ensures that starvation of a process cannot occur.4)NOOPNOOP stands for No Operation, and the name explains most of its functionality. TheNOOP elevator is simple and lean. It is a simple FIFO queue that does not perform anydata ordering. NOOP simply merges adjacent data requests, so it adds very low processoroverhead to disk I/O. The NOOP elevator assumes that a block device either features itsown elevator algorithm such as TCQ for SCSI, or that the block device has no seek latencysuch as a flash card.
  2. A write barrier is a kernel mechanism used to ensure that file system metadata is correctly written and ordered on persistent storage, even when storage devices with volatile write caches lose power.The disk contains all the data. No re-ordering has occurred. With barriers enabled, an fsync() call will also issue a storage cache flushWhen a write hits in a cache, two possible policy choices exist. First, the data can be writtenboth into the cache and passed on to the next lower level in the memory hierarchy. This policy iscalled write-through. A second possible policy on write hits is to only write the data to thefirst-level cache. Only when a dirty line (i.e., a line that has been written to) is replaced in thecache is the data transferred to a lower level in the memory hierarchy. This policy is calledwrite-back.