SlideShare una empresa de Scribd logo
1 de 33
Descargar para leer sin conexión
Quick Wins with
Third Party Patches

   Morgan Tocker, firstname at percona dot com
            Consultant, Percona Inc.
Introduction
• The best new features in MySQL are not always
  coming from MySQL (now Sun Microsystems).
  – One of the killers reasons was the three years it took to
    release MySQL 5.1 - and not accepting any “new
    features” into MySQL 5.0.
  – 5.4 is brilliant news (my opinion)!
Who’s writing the patches
• Various individuals
  and companies.
• They are (mostly) incremental
  improvements, and addressing
  their business needs.
• We’re not really talking about
  a fork*, it’s a delta.
   – Expect 100% backwards compatibility.



 * Except for XtraDB - Not covered today.
How can you get them?
• Percona releases binaries for a limited number of
  platforms.
  – See http://www.percona.com/docs/wiki/release:start
• OurDelta releases binaries (for more platforms) in
  addition to channels that plug into Debian/Red Hat
  package managers.
  – See http://ourdelta.org/
• Compile your own.
  – Not required, see above options.
On to the main event...
• I’m going to show you some cool things you can do
  that are not in MySQL.
  – All of the example patches presented are in the Percona
    and/or OurDelta releases.
  – These are the “quick wins” patches - which means that
    your effort is mostly minimal.
Patch #1 - Slow Query Filtering
• Let me tell a story first:
   – mysql> select * from employees WHERE
     birth_date BETWEEN '1960-01-01' AND
     '1960-03-31' ORDER by RAND();
     117138 rows in set (0.63 sec)
   – mysql> select * from employees WHERE
     birth_date BETWEEN '1960-01-01' AND
     '1960-03-31';
     117138 rows in set (0.25 sec)
First One:
•   mysql> EXPLAIN select * from employees WHERE birth_date BETWEEN
    '1960-01-01' AND '1960-03-31' ORDER by RAND()G
    *************************** 1. row ***************************
               id: 1
      select_type: SIMPLE
            table: employees
             type: range
    possible_keys: birth_date
              key: birth_date
          key_len: 3
              ref: NULL
             rows: 11554
            Extra: Using where; Using temporary; Using filesort
    1 row in set (0.00 sec)
Second One
• mysql> EXPLAIN select * from employees WHERE birth_date BETWEEN
  '1960-01-01' AND '1960-03-31'G
  *************************** 1. row ***************************
             id: 1
    select_type: SIMPLE
          table: employees
           type: range
  possible_keys: birth_date
            key: birth_date
        key_len: 3
            ref: NULL
           rows: 11554
          Extra: Using where
  1 row in set (0.00 sec)
... what do we see?
• So the query that doesn’t have to sort records is
  slightly faster. No surprises here.
• What about the difference in scalability between
  these two queries.
  – Astute audience members will realize this is not the same
    question at all, i.e. scalability != performance.
The empirical test
• #!/bin/sh

  ITERATIONS=10
  CONCURRENCY="1,2,4,8,16,32,64,128"

  mkdir -p results

  ./mysqlslap -q "select * from employees WHERE birth_date
  BETWEEN '1960-01-01' AND '1960-03-31' ORDER by RAND()" --
  create-schema=employees -i $ITERATIONS -c $CONCURRENCY >
  results/ORDER_BY_rand.txt

  ./mysqlslap -q "select * from employees WHERE birth_date
  BETWEEN '1960-01-01' AND '1960-03-31'" --create-
  schema=employees -i $ITERATIONS -c $CONCURRENCY > results/
  ORDER_BY_null.txt
Results

65.00
                                                                60.05

48.75


32.50
                                                        26.96

16.25                                                           18.56
                                               14.39
                                       9.81
                                                        5.16
   0           1.22     2.40
                        0.89
                                4.88
                                1.76
                                       3.48    4.55
        0.63
        0.25   0.47
         1      2        4       8     16       32      64      128
                      RAND()                  No Rand
Why is this?
• The query that requires the sort hits a different
  bottleneck, the sort.
   – Sorts in memory cause a lot of CPU pressure.
      • Might not scale.
   – Temporary tables or sorts on disk cause IO pressure.
      • Certainly won’t scale.
Why is this (cont.)?
• Sometimes it’s just as important to monitor “what
  queries take a long time” as “what may not work
  with concurrency”.
• Examples of things that might be expensive and
  reduce concurrency are.....
Expensive Things...


qc_miss             The query was not found in the query cache.
full_scan           The query performed a full table scan.
full_join           The query performed a full join (a join without indexes).
tmp_table           The query created an implicit internal temporary table.
tmp_table_on_disk   The query's temporary table was stored on disk.
filesort            The query used a filesort.
filesort_on_disk    The filesort was performed on disk.
Introducing Log slow filter...
•   [mysqld]
    log_slow_filter=tmp_table_on_disk,filesort_on_disk


     qc_miss             The query was not found in the query cache.
     full_scan           The query performed a full table scan.
     full_join           The query performed a full join (a join without indexes).
     tmp_table           The query created an implicit internal temporary table.
     tmp_table_on_disk   The query's temporary table was stored on disk.
     filesort            The query used a filesort.
     filesort_on_disk    The filesort was performed on disk.
Extra Feature #1
• log_slow_verbosity - You can also *get* more
  information written to the log:
 microtime          Log queries with microsecond precision (mandatory).

 query_plan         Log information about the query's execution plan (optional).

 innodb             Log InnoDB statistics (optional).



  # User@Host: mailboxer[mailboxer] @ [192.168.10.165]
  # Thread_id: 11167745 Schema: board
  # QC_Hit: No Full_scan: No Full_join: No Tmp_table: Yes Disk_tmp_table: No
  # Filesort: Yes Disk_filesort: No Merge_passes: 0
  # Query_time: 0.000659 Lock_time: 0.000070 Rows_sent: 0 Rows_examined: 30
  Rows_affected: 0 Rows_read: 30
  #   InnoDB_IO_r_ops: 1 InnoDB_IO_r_bytes: 16384 InnoDB_IO_r_wait: 0.028487
  #   InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000
  #   InnoDB_pages_distinct: 5
  select count(distinct author_id) from art87.article87 force index (forum_id) where
  forum_id = 240215 and thread_id = '710575'
Extra Feature #2
• It also allows you to set the long_query_time to
  microseconds in MySQL 5.0:
  – long_query_time = 100000

• If we think that it takes an average of up to 7*
  queries to generate a page, 1 second is too long.
  – MySQL finally fixed this in MySQL 5.1




  * Source: Brian Aker somewhere.
More information
• This patch was originally authored by Percona
• More Information:
  http://www.percona.com/docs/wiki/patches:microslow_innodb
Patch #2 - Index Statistics
•   What are the possible indexes?
•   mysql> EXPLAIN SELECT Name FROM Country WHERE continent =
    'Asia' AND population > 5000000 ORDER BY NameG
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: Country
         type: ALL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 239
        Extra: Using where; Using filesort
1 row in set (0.00 sec)
Answers
• The following indexes work (to varying degrees):
  – (continent)
  – (continent, population)
  – (continent, population, name).
Answers (cont.)
• The following answers are incorrect:
  – name. Using an index on name would avoid the sort, but
    it would actually be quicker to table scan.
  – population. Using an index on population is not very
    helpful, since it doesn’t filter enough rows (most countries
    have populations > 5M).
How would you tell...
• .. if you added the wrong index?

  You know, given that indexes will hurt things like
  write performance.
The simple answer...
• You can’t!
  – There is no way in MySQL to find “dead indexes”.
     • Other than drop all indexes and start adding again ;)
  – Did I mention index selection changes over time based
    on data distribution?
• .. and it’s really annoying.
Introducing Index Statistics
•   SELECT DISTINCT s.TABLE_SCHEMA, s.TABLE_NAME, s.INDEX_NAME FROM
    information_schema.statistics `s` LEFT JOIN
    information_schema.index_statistics IS ON (s.TABLE_SCHEMA = IS.TABLE_SCHEMA
    AND s.TABLE_NAME=IS.TABLE_NAME AND s.INDEX_NAME=IS.INDEX_NAME) WHERE
    IS.TABLE_SCHEMA IS NULL;
    +--------------+---------------------------+-----------------+
    | TABLE_SCHEMA | TABLE_NAME                | INDEX_NAME      |
    +--------------+---------------------------+-----------------+
    | art100       | article100                | ext_key         |
    | art100       | article100                | site_id         |
    | art100       | article100                | hash            |
    | art100       | article100                | forum_id_2      |
    | art100       | article100                | published       |
    | art100       | article100                | inserted        |
    | art100       | article100                | site_id_2       |
    | art100       | author100                 | PRIMARY         |
    | art100       | author100                 | site_id         |
    ...
    +--------------+---------------------------+-----------------+
    1150 rows IN SET (1 min 44.23 sec)

    Source: http://www.mysqlperformanceblog.com/2008/09/12/unused-indexes-by-
    single-query/
Index statistics is...
• A very simple statistics tool that increments
  counters as index rows are read.
   – Allows you to figure out which indexes should be dropped
     or tweaked.
   – Very little overhead.
More information
• Actually comes as part of a patch for
  INDEX_STATISTICS, USER_STATISTICS,
  TABLE_STATISTICS.
• Patch originally authored by Google.
• More Information:
  http://www.percona.com/docs/wiki/
  patches:userstatv2
Patch #3 - InnoDB dictionary limit
• MySQL has a data dictionary (.frm) files.
• Guess what, so does InnoDB!
InnoDB Dictionary
• As it turns out that a lot of this information is
  redundant of MySQL :(
• Oh and.. it’s expensive.
• And the default behavior is up to 100% of the buffer
  pool can be used by data dictionary.
This patch does is sets a limit.
• Or “soft upper boundary” of the memory used.
• See: http://www.percona.com/docs/wiki/
  patches:innodb_dict_size_limit
Patch #4 - Global long query time.
• The rules for the slow query time are actually
  defined from when the connection starts.
• This ones a small one, but a life saver for
  applications that use connection pooling ;)
• See: http://www.percona.com/docs/wiki/
  patches:use_global_long_query_time
Patch #5 - Group Commit “Fix”
• There’s a performance regressions in 5.0
  performance as soon as you turn on binary logging.
  – See: http://bugs.mysql.com/bug.php?id=13669

    “One of big customers reported regression from 135 to 35
    transactions due to this issue.” - Peter Zaitsev, 30 Sep
    2005.
Group Commit
• We haven’t fixed it, but we’ve introduced an unsafe
  mode (--innodb-unsafe-group-commit)
• See: http://www.mysqlperformanceblog.com/
  2009/02/02/pretending-to-fix-broken-group-commit/
The End.
• Many of the examples I use show up in some form on our blog:
  http://www.mysqlperformanceblog.com/

• Questions?

Más contenido relacionado

La actualidad más candente

Tech Talk: Best Practices for Data Modeling
Tech Talk: Best Practices for Data ModelingTech Talk: Best Practices for Data Modeling
Tech Talk: Best Practices for Data ModelingScyllaDB
 
Profiling Oracle with GDB
Profiling Oracle with GDBProfiling Oracle with GDB
Profiling Oracle with GDBEnkitec
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query TuningSveta Smirnova
 
Summary tables with flexviews
Summary tables with flexviewsSummary tables with flexviews
Summary tables with flexviewsJustin Swanhart
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sIntroduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sSveta Smirnova
 
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdfDatabase & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdfInSync2011
 
Cassandra London - C* Spark Connector
Cassandra London - C* Spark ConnectorCassandra London - C* Spark Connector
Cassandra London - C* Spark ConnectorChristopher Batey
 
Introduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache CassandraIntroduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache CassandraDataStax Academy
 
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdfDatabase & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdfInSync2011
 
Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试maclean liu
 
0888 learning-mysql
0888 learning-mysql0888 learning-mysql
0888 learning-mysqlsabir18
 
Preparse Query Rewrite Plugins
Preparse Query Rewrite PluginsPreparse Query Rewrite Plugins
Preparse Query Rewrite PluginsSveta Smirnova
 
Full Table Scan: friend or foe
Full Table Scan: friend or foeFull Table Scan: friend or foe
Full Table Scan: friend or foeMauro Pagano
 
Introduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sIntroduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sSveta Smirnova
 
Flexviews materialized views for my sql
Flexviews materialized views for my sqlFlexviews materialized views for my sql
Flexviews materialized views for my sqlJustin Swanhart
 
The Challenges of Distributing Postgres: A Citus Story
The Challenges of Distributing Postgres: A Citus StoryThe Challenges of Distributing Postgres: A Citus Story
The Challenges of Distributing Postgres: A Citus StoryHanna Kelman
 
Dbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersDbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersRiyaj Shamsudeen
 
Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...
Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...
Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...Databricks
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 

La actualidad más candente (20)

Tech Talk: Best Practices for Data Modeling
Tech Talk: Best Practices for Data ModelingTech Talk: Best Practices for Data Modeling
Tech Talk: Best Practices for Data Modeling
 
Profiling Oracle with GDB
Profiling Oracle with GDBProfiling Oracle with GDB
Profiling Oracle with GDB
 
Introduction into MySQL Query Tuning
Introduction into MySQL Query TuningIntroduction into MySQL Query Tuning
Introduction into MySQL Query Tuning
 
Summary tables with flexviews
Summary tables with flexviewsSummary tables with flexviews
Summary tables with flexviews
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sIntroduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]s
 
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdfDatabase & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
 
Cassandra London - C* Spark Connector
Cassandra London - C* Spark ConnectorCassandra London - C* Spark Connector
Cassandra London - C* Spark Connector
 
Introduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache CassandraIntroduction to Data Modeling with Apache Cassandra
Introduction to Data Modeling with Apache Cassandra
 
Cassandra 2.2 & 3.0
Cassandra 2.2 & 3.0Cassandra 2.2 & 3.0
Cassandra 2.2 & 3.0
 
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdfDatabase & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
 
Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试
 
0888 learning-mysql
0888 learning-mysql0888 learning-mysql
0888 learning-mysql
 
Preparse Query Rewrite Plugins
Preparse Query Rewrite PluginsPreparse Query Rewrite Plugins
Preparse Query Rewrite Plugins
 
Full Table Scan: friend or foe
Full Table Scan: friend or foeFull Table Scan: friend or foe
Full Table Scan: friend or foe
 
Introduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sIntroduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]s
 
Flexviews materialized views for my sql
Flexviews materialized views for my sqlFlexviews materialized views for my sql
Flexviews materialized views for my sql
 
The Challenges of Distributing Postgres: A Citus Story
The Challenges of Distributing Postgres: A Citus StoryThe Challenges of Distributing Postgres: A Citus Story
The Challenges of Distributing Postgres: A Citus Story
 
Dbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersDbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineers
 
Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...
Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...
Analyzing the Performance Effects of Meltdown + Spectre on Apache Spark Workl...
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 

Destacado

Wordpress Security Optimization (Basic)
Wordpress Security Optimization (Basic)Wordpress Security Optimization (Basic)
Wordpress Security Optimization (Basic)Irvan R-ID
 
Formazione formatori
Formazione formatori Formazione formatori
Formazione formatori stefano preto
 
Domanda protocollata
Domanda protocollataDomanda protocollata
Domanda protocollatanoicattaroweb
 
PHP SuperGlobals - Supersized Trouble
PHP SuperGlobals - Supersized TroublePHP SuperGlobals - Supersized Trouble
PHP SuperGlobals - Supersized TroubleImperva
 
parameter tampering
parameter tamperingparameter tampering
parameter tamperingIlsun Choi
 
Digital Media & Learning Conference Talk: Kids Teaching Kids Web Design at a ...
Digital Media & Learning Conference Talk: Kids Teaching Kids Web Design at a ...Digital Media & Learning Conference Talk: Kids Teaching Kids Web Design at a ...
Digital Media & Learning Conference Talk: Kids Teaching Kids Web Design at a ...Jacqueline Vickery
 
Prezi #hotelvertrieb#ecommerce#SEO_2021
Prezi #hotelvertrieb#ecommerce#SEO_2021Prezi #hotelvertrieb#ecommerce#SEO_2021
Prezi #hotelvertrieb#ecommerce#SEO_2021Ansgar Jahns
 
La posta elettronica certificata (PEC)
La posta elettronica certificata (PEC)La posta elettronica certificata (PEC)
La posta elettronica certificata (PEC)Salvatore Cordiano
 
L1 seeingthings
L1 seeingthingsL1 seeingthings
L1 seeingthingsBoat Dock
 
Le piattaforme per il social business
Le piattaforme per il social businessLe piattaforme per il social business
Le piattaforme per il social businesspiero itta
 
Sunny on Foody
Sunny on FoodySunny on Foody
Sunny on Foodymrp4
 
Cyberfolio 2007 - Lean.Joy
Cyberfolio 2007 - Lean.JoyCyberfolio 2007 - Lean.Joy
Cyberfolio 2007 - Lean.JoyLeandro Rangel
 
Intestazione
IntestazioneIntestazione
Intestazionerifugiati
 
Digital Media & Youth Safety - Ricky Lewis & Jacqueline Vickery
Digital Media & Youth Safety - Ricky Lewis & Jacqueline VickeryDigital Media & Youth Safety - Ricky Lewis & Jacqueline Vickery
Digital Media & Youth Safety - Ricky Lewis & Jacqueline VickeryJacqueline Vickery
 
Thanks A Lot
Thanks A LotThanks A Lot
Thanks A LotKaren C
 
Sharding Architectures
Sharding ArchitecturesSharding Architectures
Sharding Architecturesguest0e6d5e
 

Destacado (20)

Wordpress Security Optimization (Basic)
Wordpress Security Optimization (Basic)Wordpress Security Optimization (Basic)
Wordpress Security Optimization (Basic)
 
Formazione formatori
Formazione formatori Formazione formatori
Formazione formatori
 
Domanda protocollata
Domanda protocollataDomanda protocollata
Domanda protocollata
 
PHP
PHPPHP
PHP
 
PHP SuperGlobals - Supersized Trouble
PHP SuperGlobals - Supersized TroublePHP SuperGlobals - Supersized Trouble
PHP SuperGlobals - Supersized Trouble
 
M Power
M PowerM Power
M Power
 
parameter tampering
parameter tamperingparameter tampering
parameter tampering
 
Digital Media & Learning Conference Talk: Kids Teaching Kids Web Design at a ...
Digital Media & Learning Conference Talk: Kids Teaching Kids Web Design at a ...Digital Media & Learning Conference Talk: Kids Teaching Kids Web Design at a ...
Digital Media & Learning Conference Talk: Kids Teaching Kids Web Design at a ...
 
Prezi #hotelvertrieb#ecommerce#SEO_2021
Prezi #hotelvertrieb#ecommerce#SEO_2021Prezi #hotelvertrieb#ecommerce#SEO_2021
Prezi #hotelvertrieb#ecommerce#SEO_2021
 
La posta elettronica certificata (PEC)
La posta elettronica certificata (PEC)La posta elettronica certificata (PEC)
La posta elettronica certificata (PEC)
 
L1 seeingthings
L1 seeingthingsL1 seeingthings
L1 seeingthings
 
Le piattaforme per il social business
Le piattaforme per il social businessLe piattaforme per il social business
Le piattaforme per il social business
 
Sunny on Foody
Sunny on FoodySunny on Foody
Sunny on Foody
 
Cyberfolio 2007 - Lean.Joy
Cyberfolio 2007 - Lean.JoyCyberfolio 2007 - Lean.Joy
Cyberfolio 2007 - Lean.Joy
 
Intestazione
IntestazioneIntestazione
Intestazione
 
Digital Media & Youth Safety - Ricky Lewis & Jacqueline Vickery
Digital Media & Youth Safety - Ricky Lewis & Jacqueline VickeryDigital Media & Youth Safety - Ricky Lewis & Jacqueline Vickery
Digital Media & Youth Safety - Ricky Lewis & Jacqueline Vickery
 
O meio ambiente acustico.97
O meio ambiente acustico.97O meio ambiente acustico.97
O meio ambiente acustico.97
 
Thanks A Lot
Thanks A LotThanks A Lot
Thanks A Lot
 
A+ student strategies final
A+ student strategies   finalA+ student strategies   final
A+ student strategies final
 
Sharding Architectures
Sharding ArchitecturesSharding Architectures
Sharding Architectures
 

Similar a Quick Wins

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
10x improvement-mysql-100419105218-phpapp02
10x improvement-mysql-100419105218-phpapp0210x improvement-mysql-100419105218-phpapp02
10x improvement-mysql-100419105218-phpapp02promethius
 
10x Performance Improvements
10x Performance Improvements10x Performance Improvements
10x Performance ImprovementsRonald Bradford
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACPerformance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACKristofferson A
 
Oracle Database In-Memory Option in Action
Oracle Database In-Memory Option in ActionOracle Database In-Memory Option in Action
Oracle Database In-Memory Option in ActionTanel Poder
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneEnkitec
 
Real World Performance - Data Warehouses
Real World Performance - Data WarehousesReal World Performance - Data Warehouses
Real World Performance - Data WarehousesConnor McDonald
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeWim Godden
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksMYXPLAIN
 
Percona Live UK 2014 Part III
Percona Live UK 2014  Part IIIPercona Live UK 2014  Part III
Percona Live UK 2014 Part IIIAlkin Tezuysal
 
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...Altinity Ltd
 
Why Use EXPLAIN FORMAT=JSON?
 Why Use EXPLAIN FORMAT=JSON?  Why Use EXPLAIN FORMAT=JSON?
Why Use EXPLAIN FORMAT=JSON? Sveta Smirnova
 
MariaDB with SphinxSE
MariaDB with SphinxSEMariaDB with SphinxSE
MariaDB with SphinxSEColin Charles
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionSveta Smirnova
 
High Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouseHigh Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouseAltinity Ltd
 
Оптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчикОптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчикAgnislav Onufrijchuk
 

Similar a Quick Wins (20)

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
10x improvement-mysql-100419105218-phpapp02
10x improvement-mysql-100419105218-phpapp0210x improvement-mysql-100419105218-phpapp02
10x improvement-mysql-100419105218-phpapp02
 
10x Performance Improvements
10x Performance Improvements10x Performance Improvements
10x Performance Improvements
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACPerformance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
 
Oracle Database In-Memory Option in Action
Oracle Database In-Memory Option in ActionOracle Database In-Memory Option in Action
Oracle Database In-Memory Option in Action
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry Osborne
 
Real World Performance - Data Warehouses
Real World Performance - Data WarehousesReal World Performance - Data Warehouses
Real World Performance - Data Warehouses
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the code
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New Tricks
 
Percona Live UK 2014 Part III
Percona Live UK 2014  Part IIIPercona Live UK 2014  Part III
Percona Live UK 2014 Part III
 
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
 
Apache Cassandra at Macys
Apache Cassandra at MacysApache Cassandra at Macys
Apache Cassandra at Macys
 
Why Use EXPLAIN FORMAT=JSON?
 Why Use EXPLAIN FORMAT=JSON?  Why Use EXPLAIN FORMAT=JSON?
Why Use EXPLAIN FORMAT=JSON?
 
Hotsos 2012
Hotsos 2012Hotsos 2012
Hotsos 2012
 
MariaDB with SphinxSE
MariaDB with SphinxSEMariaDB with SphinxSE
MariaDB with SphinxSE
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in action
 
High Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouseHigh Performance, High Reliability Data Loading on ClickHouse
High Performance, High Reliability Data Loading on ClickHouse
 
Оптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчикОптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчик
 

Más de HighLoad2009

Eremkin Cboss Smsc Hl2009
Eremkin Cboss Smsc Hl2009Eremkin Cboss Smsc Hl2009
Eremkin Cboss Smsc Hl2009HighLoad2009
 
Hl++2009 Ayakovlev Pochta
Hl++2009 Ayakovlev PochtaHl++2009 Ayakovlev Pochta
Hl++2009 Ayakovlev PochtaHighLoad2009
 
архитектура новой почты рамблера
архитектура новой почты рамблераархитектура новой почты рамблера
архитектура новой почты рамблераHighLoad2009
 
Dz Java Hi Load 0.4
Dz Java Hi Load 0.4Dz Java Hi Load 0.4
Dz Java Hi Load 0.4HighLoad2009
 
Highload Perf Tuning
Highload Perf TuningHighload Perf Tuning
Highload Perf TuningHighLoad2009
 
особенности использования Times Ten In Memory Database в высоконагруженной среде
особенности использования Times Ten In Memory Database в высоконагруженной средеособенности использования Times Ten In Memory Database в высоконагруженной среде
особенности использования Times Ten In Memory Database в высоконагруженной средеHighLoad2009
 
High Load 2009 Dimaa Rus Ready
High Load 2009 Dimaa Rus ReadyHigh Load 2009 Dimaa Rus Ready
High Load 2009 Dimaa Rus ReadyHighLoad2009
 
High Load 2009 Dimaa Rus Ready 16 9
High Load 2009 Dimaa Rus Ready 16 9High Load 2009 Dimaa Rus Ready 16 9
High Load 2009 Dimaa Rus Ready 16 9HighLoad2009
 

Más de HighLoad2009 (20)

Krizhanovsky Vm
Krizhanovsky VmKrizhanovsky Vm
Krizhanovsky Vm
 
Eremkin Cboss Smsc Hl2009
Eremkin Cboss Smsc Hl2009Eremkin Cboss Smsc Hl2009
Eremkin Cboss Smsc Hl2009
 
Ddos
DdosDdos
Ddos
 
Kosmodemiansky
KosmodemianskyKosmodemiansky
Kosmodemiansky
 
Scalaxy
ScalaxyScalaxy
Scalaxy
 
Hl++2009 Ayakovlev Pochta
Hl++2009 Ayakovlev PochtaHl++2009 Ayakovlev Pochta
Hl++2009 Ayakovlev Pochta
 
Why02
Why02Why02
Why02
 
архитектура новой почты рамблера
архитектура новой почты рамблераархитектура новой почты рамблера
архитектура новой почты рамблера
 
Take2
Take2Take2
Take2
 
Hl2009 1c Bitrix
Hl2009 1c BitrixHl2009 1c Bitrix
Hl2009 1c Bitrix
 
Php Daemon
Php DaemonPhp Daemon
Php Daemon
 
Dz Java Hi Load 0.4
Dz Java Hi Load 0.4Dz Java Hi Load 0.4
Dz Java Hi Load 0.4
 
Highload Perf Tuning
Highload Perf TuningHighload Perf Tuning
Highload Perf Tuning
 
Hl2009 Pr V2
Hl2009 Pr V2Hl2009 Pr V2
Hl2009 Pr V2
 
Highload2009
Highload2009Highload2009
Highload2009
 
особенности использования Times Ten In Memory Database в высоконагруженной среде
особенности использования Times Ten In Memory Database в высоконагруженной средеособенности использования Times Ten In Memory Database в высоконагруженной среде
особенности использования Times Ten In Memory Database в высоконагруженной среде
 
бегун
бегунбегун
бегун
 
Hl Nekoval
Hl NekovalHl Nekoval
Hl Nekoval
 
High Load 2009 Dimaa Rus Ready
High Load 2009 Dimaa Rus ReadyHigh Load 2009 Dimaa Rus Ready
High Load 2009 Dimaa Rus Ready
 
High Load 2009 Dimaa Rus Ready 16 9
High Load 2009 Dimaa Rus Ready 16 9High Load 2009 Dimaa Rus Ready 16 9
High Load 2009 Dimaa Rus Ready 16 9
 

Último

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Último (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Quick Wins

  • 1. Quick Wins with Third Party Patches Morgan Tocker, firstname at percona dot com Consultant, Percona Inc.
  • 2. Introduction • The best new features in MySQL are not always coming from MySQL (now Sun Microsystems). – One of the killers reasons was the three years it took to release MySQL 5.1 - and not accepting any “new features” into MySQL 5.0. – 5.4 is brilliant news (my opinion)!
  • 3. Who’s writing the patches • Various individuals and companies. • They are (mostly) incremental improvements, and addressing their business needs. • We’re not really talking about a fork*, it’s a delta. – Expect 100% backwards compatibility. * Except for XtraDB - Not covered today.
  • 4. How can you get them? • Percona releases binaries for a limited number of platforms. – See http://www.percona.com/docs/wiki/release:start • OurDelta releases binaries (for more platforms) in addition to channels that plug into Debian/Red Hat package managers. – See http://ourdelta.org/ • Compile your own. – Not required, see above options.
  • 5. On to the main event... • I’m going to show you some cool things you can do that are not in MySQL. – All of the example patches presented are in the Percona and/or OurDelta releases. – These are the “quick wins” patches - which means that your effort is mostly minimal.
  • 6. Patch #1 - Slow Query Filtering • Let me tell a story first: – mysql> select * from employees WHERE birth_date BETWEEN '1960-01-01' AND '1960-03-31' ORDER by RAND(); 117138 rows in set (0.63 sec) – mysql> select * from employees WHERE birth_date BETWEEN '1960-01-01' AND '1960-03-31'; 117138 rows in set (0.25 sec)
  • 7. First One: • mysql> EXPLAIN select * from employees WHERE birth_date BETWEEN '1960-01-01' AND '1960-03-31' ORDER by RAND()G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: employees type: range possible_keys: birth_date key: birth_date key_len: 3 ref: NULL rows: 11554 Extra: Using where; Using temporary; Using filesort 1 row in set (0.00 sec)
  • 8. Second One • mysql> EXPLAIN select * from employees WHERE birth_date BETWEEN '1960-01-01' AND '1960-03-31'G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: employees type: range possible_keys: birth_date key: birth_date key_len: 3 ref: NULL rows: 11554 Extra: Using where 1 row in set (0.00 sec)
  • 9. ... what do we see? • So the query that doesn’t have to sort records is slightly faster. No surprises here. • What about the difference in scalability between these two queries. – Astute audience members will realize this is not the same question at all, i.e. scalability != performance.
  • 10. The empirical test • #!/bin/sh ITERATIONS=10 CONCURRENCY="1,2,4,8,16,32,64,128" mkdir -p results ./mysqlslap -q "select * from employees WHERE birth_date BETWEEN '1960-01-01' AND '1960-03-31' ORDER by RAND()" -- create-schema=employees -i $ITERATIONS -c $CONCURRENCY > results/ORDER_BY_rand.txt ./mysqlslap -q "select * from employees WHERE birth_date BETWEEN '1960-01-01' AND '1960-03-31'" --create- schema=employees -i $ITERATIONS -c $CONCURRENCY > results/ ORDER_BY_null.txt
  • 11. Results 65.00 60.05 48.75 32.50 26.96 16.25 18.56 14.39 9.81 5.16 0 1.22 2.40 0.89 4.88 1.76 3.48 4.55 0.63 0.25 0.47 1 2 4 8 16 32 64 128 RAND() No Rand
  • 12. Why is this? • The query that requires the sort hits a different bottleneck, the sort. – Sorts in memory cause a lot of CPU pressure. • Might not scale. – Temporary tables or sorts on disk cause IO pressure. • Certainly won’t scale.
  • 13. Why is this (cont.)? • Sometimes it’s just as important to monitor “what queries take a long time” as “what may not work with concurrency”. • Examples of things that might be expensive and reduce concurrency are.....
  • 14. Expensive Things... qc_miss The query was not found in the query cache. full_scan The query performed a full table scan. full_join The query performed a full join (a join without indexes). tmp_table The query created an implicit internal temporary table. tmp_table_on_disk The query's temporary table was stored on disk. filesort The query used a filesort. filesort_on_disk The filesort was performed on disk.
  • 15. Introducing Log slow filter... • [mysqld] log_slow_filter=tmp_table_on_disk,filesort_on_disk qc_miss The query was not found in the query cache. full_scan The query performed a full table scan. full_join The query performed a full join (a join without indexes). tmp_table The query created an implicit internal temporary table. tmp_table_on_disk The query's temporary table was stored on disk. filesort The query used a filesort. filesort_on_disk The filesort was performed on disk.
  • 16. Extra Feature #1 • log_slow_verbosity - You can also *get* more information written to the log: microtime Log queries with microsecond precision (mandatory). query_plan Log information about the query's execution plan (optional). innodb Log InnoDB statistics (optional). # User@Host: mailboxer[mailboxer] @ [192.168.10.165] # Thread_id: 11167745 Schema: board # QC_Hit: No Full_scan: No Full_join: No Tmp_table: Yes Disk_tmp_table: No # Filesort: Yes Disk_filesort: No Merge_passes: 0 # Query_time: 0.000659 Lock_time: 0.000070 Rows_sent: 0 Rows_examined: 30 Rows_affected: 0 Rows_read: 30 # InnoDB_IO_r_ops: 1 InnoDB_IO_r_bytes: 16384 InnoDB_IO_r_wait: 0.028487 # InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000 # InnoDB_pages_distinct: 5 select count(distinct author_id) from art87.article87 force index (forum_id) where forum_id = 240215 and thread_id = '710575'
  • 17. Extra Feature #2 • It also allows you to set the long_query_time to microseconds in MySQL 5.0: – long_query_time = 100000 • If we think that it takes an average of up to 7* queries to generate a page, 1 second is too long. – MySQL finally fixed this in MySQL 5.1 * Source: Brian Aker somewhere.
  • 18. More information • This patch was originally authored by Percona • More Information: http://www.percona.com/docs/wiki/patches:microslow_innodb
  • 19. Patch #2 - Index Statistics • What are the possible indexes? • mysql> EXPLAIN SELECT Name FROM Country WHERE continent = 'Asia' AND population > 5000000 ORDER BY NameG *************************** 1. row *************************** id: 1 select_type: SIMPLE table: Country type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 239 Extra: Using where; Using filesort 1 row in set (0.00 sec)
  • 20. Answers • The following indexes work (to varying degrees): – (continent) – (continent, population) – (continent, population, name).
  • 21. Answers (cont.) • The following answers are incorrect: – name. Using an index on name would avoid the sort, but it would actually be quicker to table scan. – population. Using an index on population is not very helpful, since it doesn’t filter enough rows (most countries have populations > 5M).
  • 22. How would you tell... • .. if you added the wrong index? You know, given that indexes will hurt things like write performance.
  • 23. The simple answer... • You can’t! – There is no way in MySQL to find “dead indexes”. • Other than drop all indexes and start adding again ;) – Did I mention index selection changes over time based on data distribution? • .. and it’s really annoying.
  • 24. Introducing Index Statistics • SELECT DISTINCT s.TABLE_SCHEMA, s.TABLE_NAME, s.INDEX_NAME FROM information_schema.statistics `s` LEFT JOIN information_schema.index_statistics IS ON (s.TABLE_SCHEMA = IS.TABLE_SCHEMA AND s.TABLE_NAME=IS.TABLE_NAME AND s.INDEX_NAME=IS.INDEX_NAME) WHERE IS.TABLE_SCHEMA IS NULL; +--------------+---------------------------+-----------------+ | TABLE_SCHEMA | TABLE_NAME                | INDEX_NAME      | +--------------+---------------------------+-----------------+ | art100       | article100                | ext_key         | | art100       | article100                | site_id         | | art100       | article100                | hash            | | art100       | article100                | forum_id_2      | | art100       | article100                | published       | | art100       | article100                | inserted        | | art100       | article100                | site_id_2       | | art100       | author100                 | PRIMARY         | | art100       | author100                 | site_id         | ... +--------------+---------------------------+-----------------+ 1150 rows IN SET (1 min 44.23 sec) Source: http://www.mysqlperformanceblog.com/2008/09/12/unused-indexes-by- single-query/
  • 25. Index statistics is... • A very simple statistics tool that increments counters as index rows are read. – Allows you to figure out which indexes should be dropped or tweaked. – Very little overhead.
  • 26. More information • Actually comes as part of a patch for INDEX_STATISTICS, USER_STATISTICS, TABLE_STATISTICS. • Patch originally authored by Google. • More Information: http://www.percona.com/docs/wiki/ patches:userstatv2
  • 27. Patch #3 - InnoDB dictionary limit • MySQL has a data dictionary (.frm) files. • Guess what, so does InnoDB!
  • 28. InnoDB Dictionary • As it turns out that a lot of this information is redundant of MySQL :( • Oh and.. it’s expensive. • And the default behavior is up to 100% of the buffer pool can be used by data dictionary.
  • 29. This patch does is sets a limit. • Or “soft upper boundary” of the memory used. • See: http://www.percona.com/docs/wiki/ patches:innodb_dict_size_limit
  • 30. Patch #4 - Global long query time. • The rules for the slow query time are actually defined from when the connection starts. • This ones a small one, but a life saver for applications that use connection pooling ;) • See: http://www.percona.com/docs/wiki/ patches:use_global_long_query_time
  • 31. Patch #5 - Group Commit “Fix” • There’s a performance regressions in 5.0 performance as soon as you turn on binary logging. – See: http://bugs.mysql.com/bug.php?id=13669 “One of big customers reported regression from 135 to 35 transactions due to this issue.” - Peter Zaitsev, 30 Sep 2005.
  • 32. Group Commit • We haven’t fixed it, but we’ve introduced an unsafe mode (--innodb-unsafe-group-commit) • See: http://www.mysqlperformanceblog.com/ 2009/02/02/pretending-to-fix-broken-group-commit/
  • 33. The End. • Many of the examples I use show up in some form on our blog: http://www.mysqlperformanceblog.com/ • Questions?