Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database How MySQL.com Improved their Database Performance with Query Analyzer.

Similar presentations


Presentation on theme: "1 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database How MySQL.com Improved their Database Performance with Query Analyzer."— Presentation transcript:

1 1 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database How MySQL.com Improved their Database Performance with Query Analyzer Adam Donnison Web Developer – MySQL.com – Sun Microsystems

2 2 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database About MySQL.com More than 70,000 downloads per day > 3 million registered users > 3 million unique visitors each month > 20 million page views per month

3 3 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database About MySQL.com Not just www.mysql.comwww.mysql.com – dev.mysql.com – DevZone – forums.mysql.com – blogs.mysql.com – solutions.mysql.com – planetmysql.org – shop.mysql.com Common web platform Common code libraries

4 4 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Database Stats or why I don't sleep at night A dozen database servers More than 700 tables in 40 databases Serving more than a dozen database applications Multiple teams hacking code, creating queries Specialized databases for reporting/staging/production Latest versions of MySQL 5.1

5 5 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Keeping Track

6 6 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database MySQL Enterprise Monitor Available as part of MySQL Enterprise offering Monitors all database instances Provides real-time alerts – System issues affecting database – Database replication – Database tuning parameters – Server availability – and heaps more...

7 7 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database MEM Dashboard

8 8 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database MEM Alert Detail

9 9 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database MEM Advisors

10 10 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database MEM Graphs

11 11 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database MySQL Query Analyzer Query Analyzer is part of MySQL Enterprise Monitor Installs in seconds – results in minutes Improved one query by a factor of 300 Reduced executions of another query by a factor of 2000 Review results of changes in minutes

12 12 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Setting Up QUAN

13 13 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Reducing Unnecessary Queries Queries can be sorted by number of executions Outstanding example showed almost 2,000 queries per minute for a particular query

14 14 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database From QUAN to Code Finding the culprit Use Query view to identify full query Determine source of query Scratch head Fix query

15 15 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database

16 16 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database From QUAN to Code List requires knowledge of up to date mirrors Query being performed for each line of list

17 17 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Lessons Learned Use QUAN to identify problems Think through query requirements Is the query doing what you think it is? Will the query scale?

18 18 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Identifying Problem Queries Queries can be sorted by execution time Quickly identify long running queries

19 19 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database The Problem Query

20 20 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Using QUAN Example

21 21 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Using QUAN Example

22 22 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Using QUAN Example Words to look out for: – Using where – Using filesort – Using temporary Check row count

23 23 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database The Problem Query Explained +----+--------------------+-------------+--------+----------------------+---------+---------+-------------------+---------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+--------------------+-------------+--------+----------------------+---------+---------+-------------------+---------+-------------+ | 1 | PRIMARY | lead_source | const | PRIMARY,system | PRIMARY | 4 | const | 1 | | | 1 | PRIMARY | lead | ref | source,sfid,source_2 | source | 5 | const | 2847097 | Using where | | 1 | PRIMARY | position | eq_ref | PRIMARY | PRIMARY | 4 | web.lead.position | 1 | | | 1 | PRIMARY | business | eq_ref | PRIMARY | PRIMARY | 4 | web.lead.business | 1 | | | 1 | PRIMARY | u | eq_ref | email | email | 66 | web.lead.email | 1 | | | 2 | DEPENDENT SUBQUERY | lead_extra | eq_ref | PRIMARY | PRIMARY | 261 | web.lead.id,const | 1 | Using where | +----+--------------------+-------------+--------+----------------------+---------+---------+-------------------+---------+-------------+ Note the number of rows in the Using where area Query only requires looking at past day or so, not entire table Adding a date range reduced the number of rows in contention

24 24 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Lessons Learned Use QUAN to identify long running queries Target queries based on QUAN results – No value spending hours to gain only microseconds improvement on a query that runs once or twice Use Explain option to gain clearer understanding of query behaviour How much data does your query need to search?

25 25 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database Query Analyzer as Adjunct to Code Analysis Code analysis alone cannot identify problem queries – Index performance – Situations change – Obfuscation by abstraction Query analyzer is a hand-in-hand tool – Helps by looking from the database back – Doesn't eliminate need for code analysis

26 26 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database The Tradeoff QUAN uses memory on each agent based on the number of distinct canonical queries being performed – Not the number of queries, but the number of different queries Typically accounts for < 1% CPU on each agent Not recommended to leave running on production servers

27 27 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database MySQL Query Analyzer The knowledge to take control


Download ppt "1 Copyright 2009 Sun Microsystems Inc. The World’s Most Popular Open Source Database How MySQL.com Improved their Database Performance with Query Analyzer."

Similar presentations


Ads by Google