Mysql Performance Schema in Action
Presenter by
S Kannan
Database Engineer
Mydbops 12th Webinar
www.mydbops.com info@mydbops.com
❏ Database Engineer
❏ Interest on Mysql and its related tech
❏ Active Learner
About Me
Mydbops at a Glance
● Founded in 2015, HQ in Bangalore India, 70+ Employees.
● Mydbops is on Database Consulting with core specialization on MySQL, MongoDB and PostgreSQL
Administration and Support.
● Mydbops was created with a motto of developing a DevOPS model for Database Administration.
● We help organisations to scale in MySQL/Mongodb/postgresql and implement the advanced technologies in
MySQL/Mongodb/PostgreSQL.
Mydbops at a Glance
Happy Customers
4
Agenda
● Introduction
● Performance Schema
● How performance schema Works ?
● Performance schema Terminology
● What is Instruments and how instruments get Data
● Instruments on various Mysql version
● Sys schema
● Demo
Introduction
What is Performance schema ?
❏Performance Schema is a feature for monitoring MySQL Server execution at a low level .
❏It was introduced in MySQL 5.5 .
❏It provides a way to inspect internal execution of the server at runtime .
❏Performance Schema events are specific to a given instance of the MySQL Server
❏It gives an insight what is happening behind the screen .
❏It was implemented as a Storage engine.
Performance Schema terminology
❖Actor
❖Consumer
❖Digest
❖Dynamic Configuration
❖Event
❖Instrument
❖Object
❖Setup Table
❖Summary table
❖Threads
How Performance Schema Works ?
Instruments:
❖Instruments are the code points where the measurements are done.
❖There are two types of instruments:
1) Timed instruments (Events)
2) Untimed instruments (count errors and memory usage)
❖Name of the monitored activity
❖Stored in performance_schema.setup_instruments table
❖More than 1200 instruments are in mysql 8
Config Server:
● Config servers store metadata and configuration settings for the cluster. As of MongoDB 3.4, config servers must
be deployed as a replica set (CSRS).
● If your cluster has a single config server, then the config server is a single point of failure.
● If the config server is inaccessible, the cluster is not accessible.
● If you cannot recover the data on a config server, the cluster will be inoperable.
● Always use three config servers for production deployments
How Instruments get data ?
S Consumers:
❖ It Process the data collected by the instruments and make it available on performance schema
❖ The consumers are defined in the setup_consumers table
❖ consumer name has a column to specify whether the consumer is enabled
S Events:
❖ An event is the result of a consumer recording the data collected by an instrument.
❖ It is used to observe the flow in mysql.
❖ Events are linked such that in general an event both has a parent and one or more child event.
S Event Types:
❖ Transactions
❖ Statements
❖ Stages
❖ Waits
S Threads:
❏ A thread is a fundamental concept in the Performance Schema.
❏ It handles a connections or Performing background operations.
❏ Mysql have several threads in parallel .
❏ Each thread has an Id (thread id).
❏ Stored in performance_schema.threads table
Performance Schema Table Types:
❖ Setup
❖ Event
❖ Instance
❖ Summary
❖ Histogram
❖ Connections and Threads
❖ Replication
❖ Lock
❖ Variable
❖ Clone
❖ Miscellaneous
S Statistics tables in performance schema
❖ Setup tables
❖ Events tables
❖ Summary tables
❖ Instance tables
❖ Lock tables
❖ Replication Summary
Instruments on various mysql version:
nstruments on various mysql version:
Mysql 5.6 Mysql 8
52 Tables 102 Ta
561 Instruments 10202 Instrume
589 ( percona server) 1229 (percona ser
31 Variables 44 variab
Mysql
87 Ta
1029 Instrume
1067 ( percona ser
42 Variables
High level Instruments on mysql 8
❏Memory
❏Idle
❏Stage
❏Transaction
❏Wait
❏Statement
❏error
S Sys schema:
❖ Sys schema reads and present the data.
❖ This is "user friendly" Performance Schema .
❖ The sys schema includes tables and triggers, views, and stored procedures and functions .
❖ The sys schema contains many views that summarize Performance Schema tables in various ways.
❖ Sys schema objects can be used for typical tuning and diagnosis use cases .
Unclosed Connections not closed properly :
Unused Index:
User created temporary tables on disk:
MySQL Performance Schema in Action

MySQL Performance Schema in Action

  • 1.
    Mysql Performance Schemain Action Presenter by S Kannan Database Engineer Mydbops 12th Webinar www.mydbops.com [email protected]
  • 2.
    ❏ Database Engineer ❏Interest on Mysql and its related tech ❏ Active Learner About Me
  • 3.
    Mydbops at aGlance ● Founded in 2015, HQ in Bangalore India, 70+ Employees. ● Mydbops is on Database Consulting with core specialization on MySQL, MongoDB and PostgreSQL Administration and Support. ● Mydbops was created with a motto of developing a DevOPS model for Database Administration. ● We help organisations to scale in MySQL/Mongodb/postgresql and implement the advanced technologies in MySQL/Mongodb/PostgreSQL.
  • 4.
    Mydbops at aGlance Happy Customers 4
  • 5.
    Agenda ● Introduction ● PerformanceSchema ● How performance schema Works ? ● Performance schema Terminology ● What is Instruments and how instruments get Data ● Instruments on various Mysql version ● Sys schema ● Demo
  • 6.
  • 7.
    What is Performanceschema ? ❏Performance Schema is a feature for monitoring MySQL Server execution at a low level . ❏It was introduced in MySQL 5.5 . ❏It provides a way to inspect internal execution of the server at runtime . ❏Performance Schema events are specific to a given instance of the MySQL Server ❏It gives an insight what is happening behind the screen . ❏It was implemented as a Storage engine.
  • 8.
    Performance Schema terminology ❖Actor ❖Consumer ❖Digest ❖DynamicConfiguration ❖Event ❖Instrument ❖Object ❖Setup Table ❖Summary table ❖Threads
  • 9.
  • 10.
    Instruments: ❖Instruments are thecode points where the measurements are done. ❖There are two types of instruments: 1) Timed instruments (Events) 2) Untimed instruments (count errors and memory usage) ❖Name of the monitored activity ❖Stored in performance_schema.setup_instruments table ❖More than 1200 instruments are in mysql 8
  • 11.
    Config Server: ● Configservers store metadata and configuration settings for the cluster. As of MongoDB 3.4, config servers must be deployed as a replica set (CSRS). ● If your cluster has a single config server, then the config server is a single point of failure. ● If the config server is inaccessible, the cluster is not accessible. ● If you cannot recover the data on a config server, the cluster will be inoperable. ● Always use three config servers for production deployments How Instruments get data ?
  • 12.
    S Consumers: ❖ ItProcess the data collected by the instruments and make it available on performance schema ❖ The consumers are defined in the setup_consumers table ❖ consumer name has a column to specify whether the consumer is enabled
  • 13.
    S Events: ❖ Anevent is the result of a consumer recording the data collected by an instrument. ❖ It is used to observe the flow in mysql. ❖ Events are linked such that in general an event both has a parent and one or more child event.
  • 14.
    S Event Types: ❖Transactions ❖ Statements ❖ Stages ❖ Waits
  • 15.
    S Threads: ❏ Athread is a fundamental concept in the Performance Schema. ❏ It handles a connections or Performing background operations. ❏ Mysql have several threads in parallel . ❏ Each thread has an Id (thread id). ❏ Stored in performance_schema.threads table
  • 16.
    Performance Schema TableTypes: ❖ Setup ❖ Event ❖ Instance ❖ Summary ❖ Histogram ❖ Connections and Threads ❖ Replication ❖ Lock ❖ Variable ❖ Clone ❖ Miscellaneous
  • 17.
    S Statistics tablesin performance schema ❖ Setup tables ❖ Events tables ❖ Summary tables ❖ Instance tables ❖ Lock tables ❖ Replication Summary
  • 18.
    Instruments on variousmysql version:
  • 19.
    nstruments on variousmysql version: Mysql 5.6 Mysql 8 52 Tables 102 Ta 561 Instruments 10202 Instrume 589 ( percona server) 1229 (percona ser 31 Variables 44 variab Mysql 87 Ta 1029 Instrume 1067 ( percona ser 42 Variables
  • 20.
    High level Instrumentson mysql 8 ❏Memory ❏Idle ❏Stage ❏Transaction ❏Wait ❏Statement ❏error
  • 21.
    S Sys schema: ❖Sys schema reads and present the data. ❖ This is "user friendly" Performance Schema . ❖ The sys schema includes tables and triggers, views, and stored procedures and functions . ❖ The sys schema contains many views that summarize Performance Schema tables in various ways. ❖ Sys schema objects can be used for typical tuning and diagnosis use cases .
  • 22.
    Unclosed Connections notclosed properly :
  • 23.
  • 24.
    User created temporarytables on disk: