MySQL Performance Schema New enhancements in MySQL 5.7 Mayank Prasad Principal Member Technical Staff Oracle, MySQL October 1, 2014 Copyright © 2014,

Slides:



Advertisements
Similar presentations
Enhancing Productivity with MySQL 5.6 New Features
Advertisements

Adam Jorgensen Pragmatic Works Performance Optimization in SQL Server Analysis Services 2008.
1.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Your customer as a segment of one That changes every second! Hein Van Der Merwe Chief.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1.
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Jim Ferrentino Elizabeth West
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle SQL Developer Tips & Tricks Jeff Smith
A Java Architecture for the Internet of Things Noel Poore, Architect Pete St. Pierre, Product Manager Java Platform Group, Internet of Things September.
Oracle Cloud Marketplace Neelesh Gurnani Director, Product Development Arif Khan Director, Product Management September 29, 2014 Copyright © 2014, Oracle.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Track the changes in your Apex application between releases: Yes you can Plsql.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle SQL Developer What’s New in Version 4.1 Jeff Smith
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Advanced Metadata Modeling Modeling for the Oracle Business Intelligence Cloud.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Introduction and Update: Oracle Hyperion Financial Close Management CON8536 Richard.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle SQL Developer For the DBA Jeff Smith
The Safe Harbor The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated.
HOL9396: Oracle Event Processing 12c
Best Practices for Supporting Oracle Hyperion EPM and Business Intelligence Solutions Mitra Veluri Senior Principal Technical Support Engineer David Valociek.
Best Practices for Upgrading Oracle PeopleSoft Environments
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Title Slide without Picture Subtitle Presenter’s Name Presenter’s Title Organization,
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit The Newest JDE Module – Rental Management Joel Sandberg Sales Consultant.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1 Preview of Oracle Database 12 c In-Memory Option Thomas Kyte
Getting Started with Oracle Compute Cloud
Oracle Confidential – Internal/Restricted/Highly RestrictedCopyright © 2014, Oracle and/or its affiliates. All rights reserved. | Oracle Identity Management.
Application Express 4.1 New Features Hilary Farrell, Principal Member of Technical Staff, Oracle.
Software Engineer, #MongoDBDays.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
1Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 Reporting from Contract.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Oracle E-Business Suite Order Management: Presenting the HTML and Mobile User Experience Durgaprasad Bodapati Director, Product Management Bhavana Sharma.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Database Technical Session By: Prof. Adarsh Patel.
RMB Billing UX Design Concepts / Proposals Peter Picone.
Hadoop 2 cluster with Oracle Solaris Zones, ZFS and unified archives Orgad Kimchi - Principal Software Engineer September 29, 2014 Oracle Confidential.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
1Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 Contract Management.
1 Moshe Shadmon ScaleDB Scaling MySQL in the Cloud.
Copyright 2006 MySQL AB The World’s Most Popular Open Source Database MySQL Cluster: An introduction Geert Vanderkelen MySQL AB.
CON Software-Defined Networking in a Hybrid, Open Data Center Krishna Srinivasan Senior Principal Product Strategy Manager Oracle Virtual Networking.
SQL Tuning made much easier with SQLTXPLAIN (SQLT) Mauro Pagano Senior Principal Technical Support Engineer Oracle Confidential – Internal/Restricted/Highly.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit Preview the Plans for JD Edwards World A9.4 Release David Greiner,
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. JD Edwards Summit Really Cool Demo Stuff – 2015 Edition!!!!! For demo content, please.
A Brief Documentation.  Provides basic information about connection, server, and client.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Using Edition-based redefinition with PL/SQL How to deploy database code changes.
1. When things go wrong: how to find SQL error Sveta Smirnova Principle Technical Support Engineer, Oracle.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Workforce Scheduling Release 5.0 for Windows Implementation Overview OWS Development Team.
RESTful Microservices In Java With Jersey Jakub Podlešák Software Engineer Oracle, Application Server Group September 29, 2014 Copyright © 2014, Oracle.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Planning & Budgeting Cloud Service (PBCS) Overview Business Analytics Product Group.
WebCenter in Education & Research A Transformation in Digital Business Session: CON7709 Golden Gate C3 Room, Marriott Marquis Moderator: Kevin Roebuck,
ASEMON JEAN-PAUL MARTIN May 2015.
Senior Solutions Architect, MongoDB Inc. Massimo Brignoli #MongoDB Introduction to Sharding.
1 Copyright © 2005, Oracle. All rights reserved. Following a Tuning Methodology.
Performance/Scalability with JDBC, UCP & Oracle Database 12c
Travel and Transportation General Session and Industry Excellence Awards Vijay Anand, Oracle Sundar Swaminathan, Oracle September 30, 2014 Copyright ©
CMPE 226 Database Systems April 19 Class Meeting Department of Computer Engineering San Jose State University Spring 2016 Instructor: Ron Mak
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 1.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 5 Lifehacks for the Apex Development environment Five frameworks you should use.
3 Copyright © 2006, Oracle. All rights reserved. Designing and Developing for Performance.
Session Name Pelin ATICI SQL Premier Field Engineer.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | PeopleSoft Order Management Pricing Managers: Have We Got Tools for You Oracle Confidential.
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | What You Need to Know About User Defined Objects (UDOs) With Tools Release 9.2.
O'Reilly MySQL Conference & Expo 2010
Build a Web App with Oracle REST Data Services &
Charles Phillips screen
Key Considerations in User Lifecycle Management
DATABASE MANAGEMENT SYSTEM
OpenWorld How to Prepare Data from Business Intelligence Cloud Service
Presentation transcript:

MySQL Performance Schema New enhancements in MySQL 5.7 Mayank Prasad Principal Member Technical Staff Oracle, MySQL October 1, 2014 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Need and Origin The Journey : Then and now … New in MySQL-5.7 (DMRs) Configuration An example Q&A

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Need and Origin The Journey : Then and now … New in MySQL-5.7 (DMRs) Configuration An example Q&A

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Why Performance Schema? System Low throughput? ? 6 DBA Hot table? Network High traffic on link? Storage Too much disk spin? App Developer Slow application? MySQL Developer Code contention? End User Stuck session?

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | History and Origin “The Performance Schema is a mechanism to give user an insight of what is happening behind the scenes when MySQL server is running.” Development was started by Marc Alff in He is Chief Architect and Lead of Performance Schema Team (Christopher Powers and me) at Oracle-MySQL. Introduced in MySQL 5.5. New storage engine : Performance Schema New Database : performance_schema Statistics stored in tables (hard-coded DDLs). Non-persistent data. SQL user interface. 7

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 Performance Schema : Design MySQL Server MySQL Server Instrumentation points (P_S hooks) P_S Internal Buffers P_S Storage Engine Storage Engine Interface Statistics Report Fetch Data SQL Query Collect Data Store Data P_S Tables 8

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Need and Origin The journey : Then and now … New in MySQL-5.7 (DMRs) Configuration An example Q&A

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The Journey : Then and now.. MySQL 5.5 Only waits events – Mutex waits – Conditions waits – R/W locks waits – File I/O waits Setup_(timers/consumers /instruments) tables Few summary tables 17 Tables and 218 Instruments MySQL 5.6 Statements and stages Table, Index and network I/O. Table locks Host Cache User, account, host Setup_(actor/objects) Multiple summary tables Events’ hierarchy 52 Tables and 550 Instruments MySQL 5.7 (DMRs) Instrumentation: – Transactions – Metadata locks – Prepared statements – Stored programs – Memory usage User variables Replication summary tables 76 Tables and 885 Instruments … 10

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Need and Origin The Journey : Then and now … New in MySQL-5.7 (DMRs) Configuration An example Q&A

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Transaction Instrumentation Exposes all aspects of Transactions within server Implicit vs Explicit Quantitative (counts, timing) and Qualitative (isolation level) statistics Aggregated across several dimensions (user, account, session etc.) Statements to non-transactional tables are ignored (MyISAM) 12

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Transaction Instrumentation (cont.) Transactions stats at runtime * Units in PICOSECONDs EVENTS_TRANSACTIONS_SUMMARY_BY_THREAD_ BY_EVENT_NAME THREAD_ID23 EVENT_NAMETransaction COUNT_STAR3 SUM_TIMER_WAIT * …… COUNT_READ_WRITE3 SUM_TIMER_READ_WRITE * …… EVENTS_TRANSACTIONS_CURRENT THREAD_ID23 EVENT_ID11 EVENT_NAMETransaction STATECOMMITTED TIMER_WAIT * ACCESS_MODEREAD WRITE ISOLATION LEVELREPEATABLE READ AUTOCOMMITNO 13

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Event Hierarchy Session Transaction Statement* Stage ( closing tables, preparing, optimizing) Wait (sync, lock, i/o) Wait (sync, lock, i/o) * Transactional tables only. 14

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Event Hierarchy (cont.) An example START TRANSACTION; INSERT INTO test.t1 VALUES(‘3’); COMMIT; START TRANSACTION; INSERT INTO test.t1 VALUES(‘3’); COMMIT; 15

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Event Hierarchy (cont.) An example START TRANSACTION; INSERT INTO test.t1 VALUES(‘3’); COMMIT; START TRANSACTION; INSERT INTO test.t1 VALUES(‘3’); COMMIT; 16

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Metadata Locks Instrumentation METADATA_LOCKS OBJECT_TYPE:TABLE OBJECT_SCHEMA:test OBJECT_NAME:tab1 LOCK_TYPE:SHARED_READ LOCK_DURATION:TRANSACTION LOCK_STATUS:GRANTED OWNER_THREAD_ID:23 OWNER_EVENT_ID:41 17 wait/lock/metadata/sql/mdl What are MDLs? Exposes metadata lock dependencies between session. Which session holds MDL Which session waiting MDL Lock request status – PENDING, GRANTED, KILLED, TIMEDOUT

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Stored Programs Instrumentation New objects types in setup_objects. – PROCEDURE – FUNCTION – TRIGGER – EVENT Can be configured individually. Nesting is maintained. Triggers, Events, Functions, Procedures OBJECT_ TYPES OBJECT_ SCHEMA OBJECT_ NAME ENABLEDTIMED TABLEtesttab1YESNO PROCEDUREtestproc1NO TRIGGERdb1trg1YES FUNCTION%NO EVENT%NO SETUP_OBJECTS 18

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Stored Programs Instrumentation (contd..) Example : create trigger test.trg before insert on test.tab1 for each row insert into test.tab2 values ('2'); create procedure test.proc () BEGIN select count(*) from test.tab1; insert into test.tab1 values('123'); END call test.proc(); create trigger test.trg before insert on test.tab1 for each row insert into test.tab2 values ('2'); create procedure test.proc () BEGIN select count(*) from test.tab1; insert into test.tab1 values('123'); END call test.proc(); EVENTS_STATEMENTS_SUMMARY_BY_PROGRAM OBJECT_TYPE OBJECT_ SCHEMA OBJECT_ NAME COUNT_ STAR SUM_TIMER_ WAIT COUNT_ STATEMENT SUM_STATEMENTS_ WAIT SUM_ ERRORS SUM_ROWS_ AFFECTED PROCEDUREtestproc TRIGGERtesttrg

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Stored Programs Instrumentation (contd..) Example : (Nesting) 20 EVENTS_STATEMENTS_HISTORY EVENT_ID461 SQL_TEXTinsert into d1.tab1 values('123') OBJECT_TYPEPROCEDURE OBJECT_NAMEproc NESTING_EVENT_ID442 EVENTS_STATEMENTS_HISTORY EVENT_ID469 SQL_TEXTinsert into d1.tab2 values ('2') OBJECT_TYPETRIGGER OBJECT_NAMEtrg NESTING_EVENT_ID461

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Prepared Statements Instrumentation What are Prepared Statements? Exposes Prepared Statements in use by server. Covers – PREPARE – mysql_stmt_prepare() SQLCOM_PREPARE, COM_STMT_PREPARE 21

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Prepared Statements Instrumentation (contd.) Example prepare stmt1 from “select * from employee where emp_id=?”; execute stmt1 prepare stmt1 from “select * from employee where emp_id=?”; execute stmt1 EVENTS_STATEMENTS_HISTORY_LONG THREAD_ID: 20 EVENT_ID: 4 EVENT_NAME: statement/sql/prepare_sql SQL_TEXT: prepare stmt1 from "select * from employee where emp_id=?’;" … PREPARED_STATEMENTS_INSTANCES STATEMENT_ID: 1 STATEMENT_NAME: stmt1 SQL_TEXT: select * from employee where emp_id=? OWNER_THREAD_ID: 20 OWNER_EVENT_ID: 4 OWNER_OBJECT_TYPE: NULL OWNER_OBJECT_NAME: NULL COUNT_EXECUTE: 1 22

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | User Variables Exposes user-defined variables Max name limit 64 USER_VARIABLES_BY_THREAD USER_VARIABLES_BY_THREAD THREAD_IDVARIABLE_NAMEVARIABLE_VALUE 23var_ var_

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Memory Usage Instrumentation Aspects covered : – Memory size – Operation Count (1M bytes once vs. 1 byte 1M times) – Low/high watermarks (spikes) Aggregation – Type of memory (various cache, internal buffers) – Thread/account/user/host Memory behavior of code/choice of design Who is taking what, how much and how many times. 24

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Memory Usages Instrumentation (contd..) MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME EVENT_NAMEmemory/sql/TABLE COUNT_ALLOC1381 COUNT_FREE924 SUM_NUMBER_OF_BYTES_ALLOC SUM_NUMBER_OF_BYTES_FREE CURRENT_COUNT_USED457 HIGH_COUNT_USED461 CURRENT_NUMBER_OF_BYTES_USED HIGH_NUMBER_OF_BYTES_USED Say : T1 : 1MB-2MB T2 : 10MB-12MB Together : 11MB - 14MB 25

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Replication Summary Tables Tables for replication statistics 26 SHOW SLAVE STATUS (Limitations) – Lots of information packed together – No logical division of information – No cherry picking (difficult for automation) – Difficult to scale (more new fields) Why Performance Schema Tables? – SQL Interface. Fetch what is required – Split logically into different tables – Easier to extend

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Replication Summary Tables Tables for replication statistics 27 Replication status Connection InformationExecute Information Connection Configuration Connection Status Execute Configuration Execute Status Coordinator/SQL Thread Worker Thread replication_connection _configuration replication_connection _status replication_execute_status _by_coordinator replication_execute_status _by_worker replication_execute _status replication_execute _configuration

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Replication Summary Tables Tables for replication statistics TableInformation replication_connection_configuration(Host, Port, User etc.) replication_connection_status(Server UUID, Receiver thread ID, Service State etc.) replication_execute_configuration(Desired Delay) replication_execute_status(Remaining Delay) replication_execute_status_by_coordinator(Thread Id, Service State, Last Error info.) replication_execute_status_by_worker(WID, WTID, Service State, Last error Info.) 28

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Need and Origin The Journey : Then and now … New in MySQL-5.7 (DMRs) Configuration An example Q&A

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Configuration Build Startup – Configuration file – Command line [mysqld] performance_schema_consumers_event_waits_history = ON. performance_schema_events_waits_history_size = performance_schema_instruments=‘statement/sql/% = COUNTED’ [mysqld] performance_schema_consumers_event_waits_history = ON. performance_schema_events_waits_history_size = performance_schema_instruments=‘statement/sql/% = COUNTED’ --performance_schema_consumers_event_waits_history = ON. --performance_schema_events_waits_history_size = performance_schema_consumers_event_waits_history = ON. --performance_schema_events_waits_history_size = 1000 cmake. -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DDISABLE_PSI_MUTEX=1 30

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Configuration (contd..) Runtime Auto tune (value=-1) – Use heuristics to compute Max number of objects (mutex, rwlocks, files, sockets, threads etc.) Memory for statistical data (history, history_long, digest etc.) NOT ALL VARIABLES ARE AUTO TUNED. – Aligned with server tuning Use hints from server variables update setup_consumers set ENABLED=‘NO’ where NAME=‘global_instrumentation’;. update setup_instruments set ENABLED=‘YES’ where NAME=‘statement/sql/%’; update setup_consumers set ENABLED=‘NO’ where NAME=‘global_instrumentation’;. update setup_instruments set ENABLED=‘YES’ where NAME=‘statement/sql/%’; 31 max_connections table_open_cache table_definition_cache open_files_limit

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Need and Origin The Journey : Then and now … New in MySQL-5.7 (DMRs) Configuration An example Q&A

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | An Example Lets say thread, with thread id T0, is trying to alter a table tab1 and is hung. Now, what T0 is waiting for – LOCK_STATUS=PENDING and OBJECT_NAME=‘tab1’ Lets see who has taken MDL on table tab1. – Thread T1 (column OWNER_THREAD_ID) is holding MDL. Is T1 waiting for some MDL? SELECT * FROM metadata_locks WHERE THREAD_ID = T0; SELECT * FROM metadata_locks WHERE OBJECT_NAME=‘tab1’, LOCK_STATUS=GRANTED; SELECT * FROM metadata_locks WHERE OWNER_THREAD_ID = T1, LOCK_STATUS=PENDING; Diagnose a stuck session 33

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | An Example (contd…) If T1 is not waiting for a MDL, then ? What T1 is waiting for – Say T1 is waiting for mutex_A (column OBJECT_INSTANCE_BEGIN) Lets see who has taken this mutex_A – Ok, so thread T2 is holding mutex_A (column LOCKED_BY_THREAD_ID) Find out what thread t2 is waiting for SELECT * FROM events_waits_current WHERE THREAD_ID = T1; SELECT * FROM mutex_instances WHERE OBJECT_INSTANCE_BEGIN = mutex_A; SELECT * FROM events_waits_current WHERE THREAD_ID = T2; Diagnose a stuck session 34

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Need and Origin The Journey : Then and now … New in MySQL-5.7 (DMRs) Configuration An example Q&A

Thank You! Q&A ? Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

MySQL sys Schema and Performance Sessions Session by Mark Lieth on MySQL sys Schema. – 12:45 PM - 1:30 PM - Moscone South – 250 Session by Dimitri on Performance and Scalability. – 2:00 PM - 2:45 PM - Moscone South