an overview to mysql sys schema

24

Click here to load reader

Upload: mydbops

Post on 14-Apr-2017

284 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: An Overview to MySQL SYS Schema

An  Overview  to    MySQL  SYS  Schema

By      

MySQL  Consulting    Team  

Page 2: An Overview to MySQL SYS Schema

About  MyDBOPS  

•       MySQL  Consulting  •       MySQL  Support  •       Remote  DBA  support.  •       Expert  MySQL  solutions  •       MariaDB,  Percona,  Galera,  TokuDB  are              supported  too.  

Page 3: An Overview to MySQL SYS Schema

Agenda  

•       Introduction  •       Installation  •       Summary  Views    

Page 4: An Overview to MySQL SYS Schema

Introduction  

Ø     Improvement  over  PS_helper      Ø   MySQL  5.7.7  and  higher  includes  the  sys  schema  by  default  

Ø     Set  of  objects  that  helps  DBAs  and  developers  interpret  data  collected  by  the            Performance  Schema  and  other  internals.      Ø     sys  schema  objects  can  be  used  for  typical  tuning  and  diagnosis  use  cases.  

Ø     Ease  up  the  DBA’s  task  in  understanding  the  internals.    .    

Page 5: An Overview to MySQL SYS Schema

Introduction  

Ø     Mark  Leith  is  the  Major  Contributor.  

Ø   Similar  to  Oracle  V$  and  X$  views  that  helps  DBA’s.  

§     Views  that  summarize  Performance  Schema  data  into  more  easily  understandable  

form.  

§     Stored  procedures  that  perform  operaNons  such  as  Performance  Schema  

configuraNon  and  generaNng  diagnosNc  reports.  

§     Stored  funcNons  that  query  Performance  Schema  configuraNon  and  provide  

formaQng  services  

§   FormaQng  and  helper  funcNons.    

Page 6: An Overview to MySQL SYS Schema

Installation  

Ø  The  sys  schema  requires  MySQL  5.5  or  higher.  

Ø  Can  be  installed  through  Workbench.  

Ø  Else  need  to  download  sys_56.sql  or  sys_57.sql  (depends  if  you  use  5.6  or  5.7).just  

import  the  sql  file  as  usual  

 

Install    

   $  git  clone  hXps://github.com/MarkLeith/mysql-­‐sys.git  /tmp/sys  

   cd  /tmp/sys  

   Link  to  download:    hXps://github.com/mysql/mysql-­‐sys/archive/master.zip  

Page 7: An Overview to MySQL SYS Schema

Installation  

 To  install  :  

   mysql  -­‐u  root  -­‐p  <  sys_56.sql    Ø  ValidaNng  sys  schema  a]er  loading  

mysql>  select  *  from  sys.version;            +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  sys_version  |  mysql_version      |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  1.5.0              |  5.6.27-­‐76.0-­‐log  |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+            

 

mysql>  select  *  from  sys.schema_object_overview  where  db='sys';  +-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  db    |  object_type      |  count  |  +-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  sys  |  VIEW                    |        87  |  |  sys  |  BASE  TABLE        |          1  |  |  sys  |  INDEX  (BTREE)  |          1  |  |  sys  |  TRIGGER              |          2  |  |  sys  |  FUNCTION            |        20  |  |  sys  |  PROCEDURE          |        26  |  +-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  

 

Page 8: An Overview to MySQL SYS Schema

Installation  

 host_summary                                                                        host_summary_by_file_io                                                  host_summary_by_file_io_type                                        host_summary_by_stages                                                    host_summary_by_statement_latency                              host_summary_by_statement_type                                    innodb_buffer_stats_by_schema                                      innodb_buffer_stats_by_table                                        innodb_lock_waits                                                              io_by_thread_by_latency                                                  io_global_by_file_by_bytes                                            io_global_by_file_by_latency                                        io_global_by_wait_by_bytes                                            io_global_by_wait_by_latency                                        latest_file_io                                                                    metrics                                                                                  processlist                                                                          ps_check_lost_instrumentation                                      schema_auto_increment_columns                                      schema_index_statistics                                                  schema_object_overview                                                    schema_redundant_indexes  

 schema_table_statistics                                                  schema_table_statistics_with_buffer                          schema_tables_with_full_table_scans                          schema_unused_indexes                                                      session                                                                                  statement_analysis                                                            statements_with_errors_or_warnings                            statements_with_full_table_scans                                statements_with_runtimes_in_95th_percentile          statements_with_sorting                                                  statements_with_temp_tables                                          sys_config                                                                            user_summary                                                                        user_summary_by_file_io                                                  user_summary_by_file_io_type                                        user_summary_by_stages                                                    user_summary_by_statement_latency                              user_summary_by_statement_type                                    version                                                                                  wait_classes_global_by_avg_latency                            wait_classes_global_by_latency                                    waits_by_host_by_latency  

Page 9: An Overview to MySQL SYS Schema

Installation  

 waits_by_user_by_latency                                                waits_global_by_latency                                                  x$host_summary                                                                    x$host_summary_by_file_io                                              x$host_summary_by_file_io_type                                    x$host_summary_by_stages                                                x$host_summary_by_statement_latency                          x$host_summary_by_statement_type                                x$innodb_buffer_stats_by_schema                                  x$innodb_buffer_stats_by_table                                    x$innodb_lock_waits                                                          x$io_by_thread_by_latency                                              x$io_global_by_file_by_bytes                                        x$io_global_by_file_by_latency                                    x$io_global_by_wait_by_bytes                                        x$io_global_by_wait_by_latency                                    x$latest_file_io                                                                x$processlist                                                                      x$ps_digest_95th_percentile_by_avg_us                      x$ps_digest_avg_latency_distribution                        x$ps_schema_table_statistics_io                                  x$schema_flattened_keys  

 x$schema_index_statistics                                              x$schema_table_statistics                                              x$schema_table_statistics_with_buffer                      x$schema_tables_with_full_table_scans                      x$session                                                                              x$statement_analysis                                                        x$statements_with_errors_or_warnings                        x$statements_with_full_table_scans                            x$statements_with_runtimes_in_95th_percentile      x$statements_with_sorting                                              x$statements_with_temp_tables                                      x$user_summary                                                                    x$user_summary_by_file_io                                              x$user_summary_by_file_io_type                                    x$user_summary_by_stages                                                x$user_summary_by_statement_latency                          x$user_summary_by_statement_type                                x$wait_classes_global_by_avg_latency                        x$wait_classes_global_by_latency                                x$waits_by_host_by_latency                                            x$waits_by_user_by_latency                                            x$waits_global_by_latency  

Page 10: An Overview to MySQL SYS Schema

Summary  Views  

Ø   Contains  many  views  that  summarize  Performance  Schema  tables  in  various  ways.    Display  all  running  and  acNve  real  Nme  process.  Ø   Most  of  these  views  come  in  pairs,  such  that  one  member  of  the  pair  has  the  same  name  as  the  other  member,  plus  a  x$  prefix.    For  Ex:    mysql>  SELECT  *  FROM  host_summary_by_file_io;  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  host              |  ios      |  io_latency  |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  localhost    |  67570  |  5.38  s          |  |  background  |    3468  |  4.18  s          |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  

mysql>  SELECT  *  FROM  x$host_summary_by_file_io;  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  host              |  ios      |  io_latency        |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  localhost    |  67574  |  5380678125144  |  |  background  |    3474  |  4758696829416  |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  

Page 11: An Overview to MySQL SYS Schema

Summary  Views  

Resource  Consuming  user    

 

 mysql>  select  *  from  user_summary\G  ***************************  1.  row  ***************************                                      user:  root                          statements:  3185            statement_latency:  2.67  h    statement_avg_latency:  3.02  s                        table_scans:  190                              file_ios:  548019                file_io_latency:  15.58  m        current_connections:  3            total_connections:  6                      unique_hosts:  1                  current_memory:  0  bytes  total_memory_allocated:  0  bytes  ***************************  2.  row  ***************************  

Page 12: An Overview to MySQL SYS Schema

Summary  Views  

Internal  File  IO  ConsumpNon      mysql>  select  *  from  user_summary_by_file_io_type  where  user  =  'root';  +-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  user  |  event_name                                                      |  total    |  latency      |  max_latency  |  +-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  root  |  wait/io/file/innodb/innodb_data_file  |  538430  |  13.57  m      |  1.11  s            |  |  root  |  wait/io/file/innodb/innodb_log_file    |      3608  |  2.05  m        |  512.93  ms      |  |  root  |  wait/io/file/sql/FRM                                  |    10579  |  7.95  s        |  315.66  ms      |  |  root  |  wait/io/file/myisam/dfile                        |          69  |  361.88  ms  |  287.33  ms      |  |  root  |  wait/io/file/sql/io_cache                        |        487  |  67.34  ms    |  39.98  ms        |  |  root  |  wait/io/file/sql/file_parser                  |        204  |  16.90  ms    |  14.78  ms        |  |  root  |  wait/io/file/archive/data                        |        256  |  853.56  us  |  13.89  us        |  |  root  |  wait/io/file/sql/dbopt                              |          33  |  564.94  us  |  67.70  us        |  |  root  |  wait/io/file/myisam/kfile                        |          85  |  304.53  us  |  74.57  us        |  |  root  |  wait/io/file/sql/misc                                |            7  |  145.62  us  |  33.73  us        |  +-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  

 

Page 13: An Overview to MySQL SYS Schema

Summary  Views  

Resource  ConsumpNon  based  on  Statements  mysql>  select  *  from  user_summary_by_statement_type  where  user  =  'root';  +-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  user  |  statement                  |  total  |  total_latency  |  max_latency  |  lock_latency  |  rows_sent  |  rows_examined  |  rows_affected  |  full_scans  |  +-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  root  |  insert                        |    1232  |  2.69  h                |  19.52  s          |  0  ps                  |                  0  |                          0  |            10367218  |                    0  |  |  root  |  create_table            |      128  |  1.04  m                |  4.41  s            |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  drop_table                |      150  |  31.18  s              |  2.74  s            |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  select                        |      101  |  9.38  s                |  889.77  ms      |  1.14  s              |          44807  |                  65631  |                          0  |                  45  |  |  root  |  Field  List                |      134  |  6.21  s                |  1.15  s            |  1.49  s              |                  0  |                          0  |                          0  |                    0  |  |  root  |  unlock_tables          |      128  |  1.85  s                |  149.67  ms      |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  show_tables              |          7  |  779.85  ms          |  414.56  ms      |  701.33  ms        |              345  |                      345  |                          0  |                    7  |  |  root  |  error                          |          1  |  748.68  ms          |  748.68  ms      |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  show_databases        |          8  |  703.16  ms          |  644.97  ms      |  585.93  ms        |                75  |                        75  |                          0  |                    8  |  |  root  |  show_variables        |          2  |  389.08  ms          |  388.09  ms      |  45.45  ms          |                  1  |                    1008  |                          0  |                    2  |  |  root  |  show_processlist    |        80  |  334.39  ms          |  236.12  ms      |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  set_option                |      586  |  224.78  ms          |  190.99  ms      |  205.00  us        |                  0  |                          0  |                          0  |                    0  |  |  root  |  show_create_table  |        34  |  116.54  ms          |  108.95  ms      |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  lock_tables              |      129  |  73.91  ms            |  10.81  ms        |  70.90  ms          |                  0  |                          0  |                          0  |                    0  |  |  root  |  alter_table              |      255  |  36.52  ms            |  6.93  ms          |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  change_db                  |        33  |  25.66  ms            |  24.29  ms        |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  show_fields              |        66  |  22.35  ms            |  2.10  ms          |  0  ps                  |              276  |                      276  |                          0  |                  66  |  |  root  |  show_triggers          |        33  |  17.33  ms            |  1.59  ms          |  0  ps                  |                  0  |                          0  |                          0  |                  33  |  |  root  |  show_table_status  |        33  |  8.69  ms              |  384.26  us      |  0  ps                  |                33  |                        33  |                          0  |                  33  |  |  root  |  create_db                  |          7  |  1.47  ms              |  332.44  us      |  0  ps                  |                  0  |                          0  |                          7  |                    0  |  |  root  |  flush                          |          1  |  902.74  us          |  902.74  us      |  822.00  us        |                  0  |                          0  |                          0  |                    0  |  |  root  |  jump_if_not              |      295  |  833.81  us          |  20.04  us        |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  create_procedure    |          2  |  393.48  us          |  226.63  us      |  220.00  us        |                  0  |                          0  |                          0  |                    0  |  |  root  |  drop_procedure        |          2  |  392.08  us          |  301.71  us      |  289.00  us        |                  0  |                          0  |                          0  |                    0  |  |  root  |  Init  DB                      |        10  |  338.30  us          |  73.47  us        |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  freturn                      |        46  |  281.04  us          |  39.39  us        |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  Statistics                |          3  |  67.26  us            |  31.78  us        |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  |  root  |  Quit                            |          3  |  54.40  us            |  19.70  us        |  0  ps                  |                  0  |                          0  |                          0  |                    0  |  +-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+    

Page 14: An Overview to MySQL SYS Schema

Summary  Views  

Resource  ConsumpNon  based  on  host  connecNvity    

mysql>  select  *  from  sys.host_summary\G  ***************************  1.  row  ***************************                                      host:  localhost                          statements:  15588            statement_latency:  2.76  h    statement_avg_latency:  637.81  ms                        table_scans:  198                              file_ios:  566859                file_io_latency:  16.10  m        current_connections:  3            total_connections:  6                      unique_users:  1                  current_memory:  0  bytes  total_memory_allocated:  0  bytes  1  row  in  set  (0.15  sec)  

 

 

Page 15: An Overview to MySQL SYS Schema

Summary  Views  

InnoDB  Buffer  Pool  Stats  based  on  Table.    

 

         mysql>  select  *  from  sys.innodb_buffer_stats_by_table;  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  object_schema      |  object_name                                |  allocated    |  data              |  pages      |  pages_hashed  |  pages_old  |  rows_cached  |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  testsoffice_sql  |  TEST_TABLE_0                              |  22.20  GiB    |  19.42  GiB    |  1455134  |            1455134  |      1455134  |        16828504  |  |  testsoffice_sql  |  TEST_TABLE_l                              |  947.80  MiB  |  887.60  MiB  |      60659  |                60659  |          60659  |          4393691  |  |  testsoffice_sql  |  TEST_TABLE_2                              |  120.70  MiB  |  74.42  MiB    |        7725  |                  7725  |            7725  |          1482091  |  |  testsoffice_sql  |  TEST_TABLE_3                              |  60.55  MiB    |  44.19  MiB    |        3875  |                  3875  |            3875  |            545475  |  |  testsoffice_sql  |  TEST_TABLE_4                              |  55.58  MiB    |  49.66  MiB    |        3557  |                  3557  |            3557  |            671925  |  |  testrsync              |  TEST_TABLE_5                              |  53.50  MiB    |  37.03  MiB    |        3424  |                  3424  |            3424  |            205086  |  |  testsoffice_sql  |  TEST_TABLE_6                              |  29.23  MiB    |  18.43  MiB    |        1871  |                  1871  |            1871  |              43250  |  |  testsoffice_sql  |  TEST_TABLE_7                              |  21.31  MiB    |  19.37  MiB    |        1364  |                  1364  |            1364  |              42888  |  |  testrsync              |  TEST_TABLE_8                              |  18.80  MiB    |  13.79  MiB    |        1203  |                  1203  |            1203  |              63859  |  |  testsoffice_sql  |  TEST_TABLE_9                              |  14.95  MiB    |  9.87  MiB      |          957  |                    957  |              957  |              49498  |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  

Page 16: An Overview to MySQL SYS Schema

Summary  Views  

Finding  the  Hot  tables    mysql>  select  *  from  sys.schema_table_statistics  limit  2\G  ***************************  1.  row  ***************************            table_schema:  test_database                table_name:  test_table1          total_latency:  2.68  h            rows_fetched:  0          fetch_latency:  0  ps          rows_inserted:  10426278        insert_latency:  2.68  h            rows_updated:  0        update_latency:  0  ps            rows_deleted:  0        delete_latency:  0  ps    io_read_requests:  19                      io_read:  5.31  KiB      io_read_latency:  43.69  us  io_write_requests:  37                    io_write:  6.10  KiB    io_write_latency:  54.50  us    io_misc_requests:  24      io_misc_latency:  40.31  ms    

 

***************************  2.  row  ***************            table_schema:  db2                table_name:  table_2          total_latency:  3.76  s            rows_fetched:  0          fetch_latency:  0  ps          rows_inserted:  7488        insert_latency:  3.76  s            rows_updated:  0        update_latency:  0  ps            rows_deleted:  0        delete_latency:  0  ps    io_read_requests:  19                      io_read:  1.80  KiB      io_read_latency:  39.66  us  io_write_requests:  101                    io_write:  1.25  MiB    io_write_latency:  1.72  ms    io_misc_requests:  64      io_misc_latency:  3.45  s    

Page 17: An Overview to MySQL SYS Schema

Summary  Views  

Memory  DistribuNon  inside  MySQL   select * from memory_global_by_current_bytes limit 10;

+------------------------------------------------------------------------------+---------------+---------------+-------------------+------------+------------+----------------+

| event_name | current_count | current_alloc | current_avg_alloc | high_count | high_alloc | high_avg_alloc |

+------------------------------------------------------------------------------+---------------+---------------+-------------------+------------+------------+----------------+

| memory/performance_schema/events_statements_history_long | 1 | 13.66 MiB | 13.66 MiB | 1 | 13.66 MiB | 13.66 MiB |

| memory/performance_schema/events_statements_history_long.tokens | 1 | 9.77 MiB | 9.77 MiB | 1 | 9.77 MiB | 9.77 MiB |

| memory/performance_schema/events_statements_history_long.sqltext | 1 | 9.77 MiB | 9.77 MiB | 1 | 9.77 MiB | 9.77 MiB |

| memory/performance_schema/events_statements_summary_by_digest.tokens | 1 | 9.77 MiB | 9.77 MiB | 1 | 9.77 MiB | 9.77 MiB |

| memory/performance_schema/table_handles | 1 | 9.00 MiB | 9.00 MiB | 1 | 9.00 MiB | 9.00 MiB |

| memory/performance_schema/events_statements_summary_by_thread_by_event_name | 1 | 8.67 MiB | 8.67 MiB | 1 | 8.67 MiB | 8.67 MiB |

| memory/performance_schema/memory_summary_by_thread_by_event_name | 1 | 5.62 MiB | 5.62 MiB | 1 | 5.62 MiB | 5.62 MiB |

| memory/performance_schema/events_statements_summary_by_digest | 1 | 4.88 MiB | 4.88 MiB | 1 | 4.88 MiB | 4.88 MiB |

| memory/performance_schema/events_statements_summary_by_account_by_event_name | 1 | 4.33 MiB | 4.33 MiB | 1 | 4.33 MiB | 4.33 MiB |

| memory/performance_schema/events_statements_summary_by_host_by_event_name | 1 | 4.33 MiB | 4.33 MiB | 1 | 4.33 MiB | 4.33 MiB |

+------------------------------------------------------------------------------+---------------+---------------+-------------------+------------+------------+----------------+

Page 18: An Overview to MySQL SYS Schema

Summary  Views  

Finding  the  Global  Wait  Latency                            mysql>    select  *  from  waits_global_by_latency  limit  10;  

+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  events                                                                                          |  total        |  total_latency  |  avg_latency  |  max_latency  |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  wait/io/file/innodb/innodb_data_file                              |    3025950  |  2.84  h                |  3.38  ms          |  1.11  s            |  |  wait/io/table/sql/handler                                                    |  11025308  |  2.83  h                |  923.86  us      |  1.56  s            |  |  wait/io/file/innodb/innodb_log_file                                |        56941  |  32.53  m              |  34.28  ms        |  565.85  ms      |  |  wait/io/file/sql/FRM                                                              |        12044  |  7.96  s                |  660.69  us      |  315.66  ms      |  |  wait/io/file/myisam/dfile                                                    |              93  |  361.95  ms          |  3.89  ms          |  287.33  ms      |  |  wait/io/file/sql/io_cache                                                    |            487  |  67.34  ms            |  138.28  us      |  39.98  ms        |  |  wait/io/file/sql/file_parser                                              |            104  |  15.29  ms            |  147.05  us      |  14.78  ms        |  |  wait/io/file/archive/data                                                    |            256  |  853.56  us          |  3.33  us          |  13.89  us        |  |  wait/io/file/sql/dbopt                                                          |              33  |  564.94  us          |  17.12  us        |  67.70  us        |  |  wait/io/file/sql/ERRMSG                                                        |                5  |  518.37  us          |  103.67  us      |  468.87  us      |  |  wait/io/file/myisam/kfile                                                    |            118  |  403.17  us          |  3.42  us          |  74.57  us        |  |  wait/lock/table/sql/handler                                                |            127  |  301.39  us          |  2.37  us          |  5.13  us          |  |  wait/io/file/sql/misc                                                            |                7  |  145.62  us          |  20.80  us        |  33.73  us        |  |  wait/io/file/sql/casetest                                                    |              10  |  142.10  us          |  14.21  us        |  80.76  us        |  |  wait/io/file/sql/pid                                                              |                3  |  136.44  us          |  45.48  us        |  108.86  us      |  |  wait/io/file/mysys/cnf                                                          |                5  |  51.82  us            |  10.36  us        |  20.47  us        |  |  wait/io/file/mysys/charset                                                  |                3  |  25.89  us            |  8.63  us          |  13.81  us        |  |  wait/io/file/keyring_file/keyring_file_data                |                4  |  18.76  us            |  4.69  us          |  13.98  us        |  |  wait/io/file/sql/global_ddl_log                                        |                2  |  6.06  us              |  3.03  us          |  3.49  us          |  |  wait/io/file/keyring_file/keyring_backup_file_data  |                1  |  4.35  us              |  4.35  us          |  4.35  us          |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  

 

 

Page 19: An Overview to MySQL SYS Schema

Summary  Views  

Finding  unused  index    in  my  database.              

mysql>  select  *  from  sys.schema_unused_indexes  limit  10;  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  object_schema      |  object_name                              |  index_name                |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  database_sample  |  1459778950_ME4_list              |  test_index                |  |  database_sample  |  1459779671_633_list              |  test_index                |  |  database_sample  |  1459778981_ME4_list              |  test_index_1            |  |  database_sample  |  1459778986_ME4_list              |  test_index_1            |  |  database_sample  |  1459778990_ME4_list              |  test_index_2            |  |  database_sample  |  1459778990_ME4_list              |  idx_date                    |  |  database_sample  |  1459778995_ME4_list              |  test_index_2            |  |  database_sample  |  1459778995_ME4_list              |  idx_head                    |  |  dbbase_sample_2  |  1459778999_ME4_list              |  username                    |  |  dbbase_sample_2  |  1459778999_ME4_list              |  test_index_2            |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  

 

 

Page 20: An Overview to MySQL SYS Schema

Summary  Views  

Tables  with  FTS  (  Full  Table  Scan)  queries              

mysql>  select  *  from  schema_tables_with_full_table_scans;  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  object_schema      |  object_name              |  rows_full_scanned  |  latency      |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  |  dbbase_sample_2  |  TESTSTATS                  |                      1639668  |  20.16  m      |  |  dbbase_sample_2  |  TABLEP_TESTS            |                        174365  |  814.35  ms  |  |  dbbase_sample_2  |  TESTTB                        |                          83577  |  195.37  ms  |  |  dbbase_sample_2  |  TABLE_STATS              |                          14124  |  31.96  s      |  |  dbbase_sample_2  |  TABLE_FILE1              |                            3215  |  31.18  ms    |  |  dbbase_sample_2  |  TABLE_FILE2              |                            2552  |  27.44  ms    |  |  dbbase_sample_2  |  TABLE_FILE4              |                            2306  |  368.97  ms  |  |  database_sample  |  TABLE_FILE6              |                            1602  |  151.13  ms  |  |  dbbase_sample_2  |  TABLE_FILE8              |                                16  |  16.13  ms    |  |  sys                          |  TABLE_FILE9              |                                  6  |  137.39  us  |  +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+  

 

 

Page 21: An Overview to MySQL SYS Schema

Summary  Views  

Find  queries  creaNng  temp  tables.              

mysql>  select  *  from  statements_with_temp_tables  limit  2\G  ***************************  1.  row  ***************************                                        query:  SELECT  DISTINCT  ROW  `COLUMN3`  FRO  ...  NOT  IN  (...)  ORDER  BY  `COLUMN4`                                              db:  TEST_DB                              exec_count:  321                        total_latency:  1.59  s                memory_tmp_tables:  321                    disk_tmp_tables:  0  avg_tmp_tables_per_query:  1      tmp_tables_to_disk_pct:  0                              first_seen:  2016-­‐04-­‐03  11:00:02                                last_seen:  2016-­‐04-­‐05  16:20:01                                      digest:  ad3f312c08d1e324cde5ff9e7f5b7513  ***************************  2.  row  ***************************                                        query:  SELECT  DISTINCTROW  (  `COLUMN1`  )  FROM  `TABLE`                                              db:  TEST_DB                              exec_count:  176                        total_latency:  50.65  ms                memory_tmp_tables:  176                    disk_tmp_tables:  0  avg_tmp_tables_per_query:  1      tmp_tables_to_disk_pct:  0                              first_seen:  2016-­‐04-­‐03  11:52:04                                last_seen:  2016-­‐04-­‐05  13:52:04                                      digest:  d0a288bf2140849667259fcfbf2b9619  

 

 

Page 22: An Overview to MySQL SYS Schema

Summary  Views              

•  Sys  schema  can  help  a  lot  in  monitoring  and  Fine  Tuning.  

•  Monitoring  and  alert  systems  can  benefitted  a  lot  by  it.  

•  Seems  like  MEM  3.2  has  implemented  most  of  sys  schema  tables.  

•  Large  scale  MySQL  Farms  can  poll  the  sys  schema  views  to  

centralized  servers  for  historical  data  analysis.  

Page 23: An Overview to MySQL SYS Schema

How MyDBOPS Can Help You ?

•     MySQL  Consulting  •     MySQL  Support  •     Remote  DBA  •     MySQL  Health  Audit    •     24  *  7  Support    

 

Contact  :    [email protected]  

Page 24: An Overview to MySQL SYS Schema

Thank  You