Looking at Performance - What’s new in MySQL Workbench 6.2 Mario Beck MySQL Sales Consulting Manager EMEA 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.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 2 Agenda
Very Brief Product History & Overview What’s New – Performance Tools Performance Dashboard Performance Schema Reports and Sys Schema Visual Explain 2 Request Results Status Details View Other related extras and tips
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 3 MySQL Workbench Overview Design, Develop, Administer, Migrate And now adding – Performance • MySQL Database IDE • Millions of Users • Millions of Downloads • Windows, OS X, Linux
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 4 History Workbench 6.1 New Performance Tools
Workbench Workbench 5.2 6.0 Workbench New GUI Design 5.0/5.1 fabFORCE.net Admin Enhanced EER Designer Develop Workflow DBDesigner4 Migrate Windows Native X-Platform
Query Browser
Administrator
Migration Toolkit
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 5 Performance Dashboard
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 6 Previously Basic Health Graphs
. On the server . CPU Load
. Linux – Load Average
. Windows – CPU usage %
. Mac – Load Average . Total Connections . Network Traffic
. MySQL Only – Byte Sent + Bytes Rcved . Total QPS for entire server
. Total Ops . Percentage of Pages Free/Total
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 7 Performance Dashboard
• Connect – (DB Click or Open and Connect) • Go to Management Tab – If needed (Bottom Left) • Go to Dashboard – New Performance Section
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 8 The Dashboard – 3 core areas Network, General Server, InnoDB Network to Disk – Left to Right, Top to Bottom
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 9 General Dashboard
• Max Time Window is ~2.5 minutes • Data is transient – Nothing is stored long term in WB – For storing history of performance use MEM • Plenty of mouse over's for details and descriptions
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 10 Incoming / Outgoing Traffic
Mouse over for Details
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 11 SQL Statements – By Select, DML, DDL
Mouse over for Details
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 12 Table Cache and Buffer Pool
• Hits and Misses in Mouse Over
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 13 Track Writes and Reads, Redo Log, Db Write Buffer
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 14 Performance Schema Reports and Sys Schema
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 15 What are Performance Reports for
• Finding problems looking at the whole server – Queries – IO and Files – Buffers – Threads – Connections – Etc
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 16 Performance Schema Reports
• Connect – (DB Click or Open and Connect) • Go to Management Tab – If needed (Bottom Left) • Go to Performance Reports – New Performance Section
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 17 Open Settings Before Running Performance Reports
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 18 First Run
• Installs the SYS schema – Or updates to newer version in needed
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 19 SYS now Added
• No Tables • Only – Views – SPs – Functions • Operates on – Performance Schema – Information Schema
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 20 Notice x$
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 21 Unit String within result versus (x$) Single Unit
• Providing 2 options • One is easy – To read in a query • Other (x$) is easier – To compare – To Export to spreadsheet – To Graph – To consume in code
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 22 SYS - SPs and Functions
SPs FUNCTIONS Used to simplify Used for Formatting and management Simple Checks
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 23 Many WB Performance Reports
• WB wrappers many SYS views
• If we’ve missed a needed report or view – Let us know – Happy to add more
– Even if not performance related • Could go in an Inspector
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 24 General Lay Out - Header
Title and Brief Description
Sortable Columns
Column Labels indicate Units
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 25 General Lay Out – Footer - Export
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 26 Load Spreadsheet
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 27 Graph and Analyze Further
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 28 General Lay Out – Footer - Copy Selected
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 29 General Lay Out – Footer - Copy Selected
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 30 Using the Performance Reports
• 4 Categories – IO – High Cost SQL Statements – Database Statistics – Wait Event Times – InnoDB Statistics
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 31 IO Reports
• For – Files, Event Categories, User/Thread • Quickly – View, Sort – By #, Time, Reads, Writes, Percentages • Look for Hot Spots – Use to determine system requirements, tuning, etc.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 32 High Cost SQL Statements
• Look at query statements and statistics • Look for Full Table Scans • Frequency of execution • Errors, Warnings • Long Runtimes – Total, Max, Ave • Large numbers of Rows – Total, Max, Ave • Usage of Temp Tables
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 33 Database Schema Statistics
• Quickly Review Various Stats – Counts – Rows – Timing – Paging – Buffering – IOs • Easily find Full Scans • Spot Unused Indexes • Also See Schema/Table Inspectors – Table, Column, Index,… Statis
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 34 Wait Event Times (For Experts)
• Wait Event Analysis is Complex • However for power expert users – These reports show collected data – Show the queries used to collect – Provides Statistics – Breaks out events by Users and Classes
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 35 InnoDB Statistics
• Quick views – Aggregated • By Schema • By Table – Easy to sort by • Allocation, Data, • Pages, Pages hashed, Old Pages • Rows cached
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 36 Schema Inspector/Table Inspector • Review and Maintain
• Assess Tables – Engine Types – Statistics • Column – Types – Size • Indexes and Triggers …
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 37 Look at details TABLEs Inspect sizes, engine types COLUMNs …
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 38 Go To Maintenance Options
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 39 Maintenance – Multi-select – Apply – Confirm
Access to table maintenance ANALYZE – updates statistics – important for innodb tables OPTIMIZE TABLE – formats data more efficiently on disk CHECK – if not valid – may be having some problems – important for myisam
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 40 Perform Maintenance or Checks
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 41 Visual Explain 2
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 42 What are Explain Plans for
• When you're working on a specific query – To optimize performance – Understand how it executes – Hints for how to restructure query – Add indexes – Change design of schema – Etc
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 43 Running an Explain • SELECT * FROM sakila.film_list;
• Runs EXPLAIN FORMAT=JSON (for 5.6 and up)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 44 Visualization of the Query Plan Complex Query
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 45 What you’ll see
• Based on MySQL Version – The higher the version the more details in latest JSON explain data
– The more details in JSON Explain Data – the more Workbench shows
• Some simpler terms versus JSON explain Output – For example • ALL -> Full Table Scan • REF -> Non-Unique Key Lookup
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 46 Boxes and Colors
• Color Hint at Importance – Bad to Good - Red, Yellow, Green • Boxes are – A lookup Action – Hover over for details • Type • Objects • References • Possible Issues • Optimization Hints/Ideas
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 47 How to read • Lines, Numbers, and Labels
. Joined values are here • Bottom # – How many rows . Category_Id • Number of rows 992 from loop is . Film_id
• 16x31x1x2x1 . Actor_id
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 48 Costs
• Prefix Cost (read + Eval) • Read Cost • Eval Cost • Data Read Per Join • Rows Returned Cost Shown on Left Hand Side – based on Cost Type Selected
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 49 Query Results Details View
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 50 Look at general response time
Duration = Execution time – on the server Fetch = Time to transfer the result (Network + Client “App” Latency)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 51 New Side Tabs
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 52 Easy to use form Editor
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 53 Results field type view
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 54 Query statistics
Server # more accurate typically
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 55 If you get a message like this –
Either PS is off – see next page OR You didn’t run mysql_upgrade
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 56 New Screen – Performance Schema Setup YES – its on, NO – its off Advanced – for power users
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 57 New Connection Screen Features
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 58 Improved Connections Screen
Connections Look for Right Click – From Where – Unexpected apps – View Thread Stack – Who / What – Analysis – Go to Explain Plan (5.7) – Which DB – Jobs – How long Time Duration Look for high time values for Queries for example
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 59 Grab SQL from a Connection
• To try it - in WB editor run select * from actor where (select sleep(30));
• Show SQL from a Connection in Editor • Format SQL so its more readable • Execute to see timing • Run Explain on the SQL
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 60 Final Tips
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 61 Know and inspect the model
• Insight into improving design, improving indexing, how to write SQL
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 62 Monitor “What’s Slow” – Slow Query Log
• Enable, Set time in seconds, Set to 0 to test
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 63 Look At Server Logs
• Go to Slow Query Log
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 64 Quick Links
• Download: – http://dev.mysql.com/downloads/tools/workbench/
• Bugs: – http://bugs.mysql.com
• Forums: – http://forums.mysql.com/index.php?151
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 65 Supporting Resources
• Oracle and MySQL • MySQL • MySQL Workbench • Team Blog – https://blogs.oracle.com/mysqlworkbench/ • MySQL Community Edition • MySQL Enterprise Edition • MySQL Blog, Twitter, Facebook • Optimizer Blog – http://oysteing.blogspot.co.uk/
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 66