SlideShare uma empresa Scribd logo
1 de 54
Baixar para ler offline
MySQL Performance Tuning

                                 A practical guide




                                 Oli Sennhauser
                                  Senior Consultant
                                osennhauser@mysql.com



Copyright 2007 Oli Sennhauser                    The World’s Most Popular Open Source Database   1
Introduction

    • Who we are?
    • What we want?




Copyright 2007 Oli Sennhauser             The World’s Most Popular Open Source Database   2
Table of Contents

    •    Find the problem
    •    MySQL architecture
    •    Database settings
    •    Detect and eliminate slow queries
    •    Table tuning
    •    Application tuning
    •    Alternatives
    •    Prevention
    •    Dirty tricks and other stuff
    •    Now it's up to you...


Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   3
DBA: We have a problem!

    • What does performance mean to you?

    • How does it look like?
          –   DB is (suddenly!?) slow.
          –   No historical data (or not the one we need).
          –   “Screw something on the DB!”
          –   We are short before going life and much too slow!!!


    • We have a problem. And what now?




Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   4
Efficiency of tuning measurements




    • Application/Architecture/Design
          ➳ No way! For what ever reason :-(
    • So on the DBA side: Memory, DB settings, I/O,
      Indexes, etc.

Copyright 2007 Oli Sennhauser             The World’s Most Popular Open Source Database   5
Find the problem / the bottleneck

    • No history data!?! :-(

    • Best if:
          – you can simulate it
          – it happens predictable and/or periodically


    • Your friends are:
          –   vmstat / dstat
          –   iostat
          –   top
          –   any graphical history of values



Copyright 2007 Oli Sennhauser                   The World’s Most Popular Open Source Database   6
Tuning means ...

    • The tuning life cycle:




    • Only one change at a time

Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   7
Measure

    • Find the bottleneck / limiting resource:

          –   I/O
          –   Memory
          –   CPU
          –   Network bandwidth


    • But how?




Copyright 2007 Oli Sennhauser             The World’s Most Popular Open Source Database   8
Measure I/O

    • vmstat
        # vmstat 1
        procs ­­­swap­­ ­­­­­io­­­­ ­­­­cpu­­­­
         r  b   si   so    bi    bo us sy id wa
         0  0    3    3    94   143 21 21 56  2
         0  0    0    0     0     4  9 37 54  0

    • iostat (--> sysstat package)

        # iostat ­x 1
        avg­cpu:  %user   %nice %system %iowait  %steal   %idle
                   5.88    0.00   34.31    2.94    0.00   56.86

        Device:     r/s   w/s  rkB/s  wkB/s  await  svctm  %util
        hda        0.00  0.00   0.00   0.00   0.00   0.00   0.00
        hdc        0.00  2.94   0.00  23.53  14.67  12.00   3.53


Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   9
Measure memory

    • ps
        # ps ­eo user,pid,%cpu,%mem,vsz,rsz,comm ­­sort ­vsz | 
         egrep 'mysql|COMMAND'
        USER       PID %CPU %MEM    VSZ   RSZ COMMAND
        mysql     1361  0.0  1.5 108368 16444 mysqld
        mysql     1210  0.0  0.1   4536  1956 bash
        mysql     1289  0.0  0.1   4060  1444 safe_mysqld
        mysql     1204  0.0  0.1   4048  1404 su



    • free / top:
        #free
                     total   used    free shared buffers cached
        Mem:       1036016 983864   52152      0   35484 547432
        ­/+ buffers/cache: 400948  635068
        swap:      4202112  96148 4105964

Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   10
Measure CPU

    • top

    • vmstat




    • dstat




Copyright 2007 Oli Sennhauser            The World’s Most Popular Open Source Database   11
Measure network bandwidth

    • dstat
        # dstat
        ­­­­total­cpu­usage­­­­ ­dsk/total­ ­net/total­
        usr sys idl wai hiq siq| read  writ| recv  send
         21   5  56   2   0  15|  25k   39k|   0     0
         13   3  84   0   0   0|   0     0 | 994B  437B
          8   4  88   0   0   0|   0     0 | 632B  484B


    • ifconfig

        # watch ­n 1 ­d "/sbin/ifconfig | egrep 'Link|bytes'"
        eth0      Link encap:Ethernet  HWaddr 00:30:1B:2D:67:B4
                  RX bytes:1751779749 (1670.6 Mb)
                  TX bytes:191340381 (182.4 Mb)



Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   12
Think
    • I/O
          – Who does it?
          – Is it read or write?
          – Is it random I/O or sequential I/O?
    • Memory
          – Easy to find!
          – DB sizing
          – Is it somebody else?
    • CPU
          – Easy to find!
          – Who is “burning” CPU?
    • Network bandwidth
          – Who does it?
          – Sniff traffic?
Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   13
Change

    • What could be changed?

    •    Hardware -> I/O system (RAID5), RAM, CPU, NW
    •    O/S -> do not touch (kernel upgrade)
    •    DB -> my.cnf
    •    Application -> Queries!!!




Copyright 2007 Oli Sennhauser            The World’s Most Popular Open Source Database   14
Change Hardware

    • More RAM helps more!!!
    • Faster CPU if it is the bottleneck (not more!)
    • More expensive I/O system:
          –   RAID5 is bad for databases!!!
          –   RAID10 is good.
          –   Many spindles
          –   Battery buffered I/O system cache???
    • 1 Gbit Network?
    • Forget about virtualization (VMware etc.)!!!




Copyright 2007 Oli Sennhauser              The World’s Most Popular Open Source Database   15
Change O/S

    • Use mainstream O/S -> for MySQL this means
      SLES/RHEL!
    • Use 64-bit architecture (> 4 GB RAM)
    • Use recent kernel (>= 2.6.12)
    • Use mainstream file system -> ext3 and xfs
    • Take what you are most familiar with!

    --> But on O/S you cannot change much. They are
      already optimal! :-)




Copyright 2007 Oli Sennhauser           The World’s Most Popular Open Source Database   16
Change MySQL: Architecture




Copyright 2007 Oli Sennhauser          The World’s Most Popular Open Source Database   17
Change MySQL: Performance Features

    • The magic of caching: “Do as little work as
      possible: Be lazy!!!”

    • Performance features:
          –   Thread cache
          –   Query cache
          –   Prepared statements
          –   Stored Procedures (see “the SP trap!”)
          –   delayed INSERT (MyISAM only)




Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   18
Change MySQL: database settings

    • “The big 3!”
          – key_buffer_size
          – innodb_buffer_pool_size
          – innodb_log_file_size


    • Some others: query_cache_size, thread_cache_size

    • My approach:
          – use defaults (or templates)
          – add: “the big 3” + 2 (see above)
          – do NOT change except it was proved and measured
            that is useful!


Copyright 2007 Oli Sennhauser           The World’s Most Popular Open Source Database   19
Change MySQL

    • Where to change?
          – my.cnf (Caution: many possible places!!!)


    • Where to measure?
          – SHOW /*!50000 GLOBAL */ STATUS;


    • Where to cheat?
          – http://dev.mysql.com/doc/refman/5.0/en/index.html
          – 5.2.3. System Variables
          – 5.2.5. Status Variables




Copyright 2007 Oli Sennhauser             The World’s Most Popular Open Source Database   20
The big 3

    • MyISAM

        key_buffer_size               = 25­33% of RAM

        Key_blocks_unused             ­­> actual value
        Key_blocks_used               ­­> high water mark
        Key_read_requests / Key_reads ­­> >= 99% ideally



    • InnoDB

        innodb_buffer_pool_size             = 80% of RAM

        Innodb_buffer_pool_pages_free
        Innodb_buffer_pool_read_requests /
        Innodb_buffer_pool_reads            ­­> >= 99% ideally

Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   21
The big 3

    • InnoDB
        innodb_log_file_size          = 32 ­ 128 Mbyte

        Innodb_os_log_pending_fsyncs  ­­> ???
                                      ­­> hiccups!




Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   22
Query cache & thread cache

    • Query cache
        query_cache_size        = 32 ­ 128 Mbyte (caution: 512!)

        Qcache_total_blocks
        Qcache_free_blocks
        Qcache_free_memory      ­­> Fragmentation
        Qcache_hits
        Qcache_inserts          ­­> Hit ratio, ideally >> 2 : 1
        Qcache_lowmem_prunes    ­­> too small or too fragmented


    • Thread cache

        thread_cache_size        = 8 ­ 128

        Threads_cached
        Threads_created          ­­> should not grow much over time

Copyright 2007 Oli Sennhauser                The World’s Most Popular Open Source Database   23
Some more...

    • That's it! :-)
    • Avoid any kind of I/O: logging!

        sync_binlog       ­­> 0 !!!
        #log              ­­> Not on production!!!
        #log_bin          ­­> Where we do NOT need it!!!
        log_slow_queries  ­­> is OK, we do not have such :­)


    • Try to avoid sync writing:

        innodb_flush_log_at_trx_commit = 2


          ➔   Simulates MyISAM behaviour for InnoDB. But caution!

Copyright 2007 Oli Sennhauser                The World’s Most Popular Open Source Database   24
Some more...

    • Table cache
        table_cache     = 64 ­ 2048

        Open_tables     ­­> <= table_cache
        Opened_tables   ­­> should change moderately

    • Other InnoDB settings:
        innodb_additional_mem_pool_size

          ➔   Do NOT change this! > 20 Mbyte is non sense!

        innodb_flush_method

          ➔   Sometimes O_DIRECT or O_DSYNC can help. But test
              before!

Copyright 2007 Oli Sennhauser               The World’s Most Popular Open Source Database   25
Change Application!

    • Transaction log and binlog cache:
        Binlog_cache_disk_use  ­­> increase binlog_cache_size
        Innodb_log_waits       ­­> increase innodb_log_buffer_size


          ➔   Too big transactions???


    • Temporary results:

        max_heap_table_size      = 16 ­ 256 Mbyte
        tmp_table_size           = 32 ­ 512 Mbyte

        Created_tmp_disk_tables  ­­> changes often

          ➔   Too big temporary results?
Copyright 2007 Oli Sennhauser                The World’s Most Popular Open Source Database   26
Change Application!

    • Sort buffer:
        sort_buffer_size   = 2 ­ 16 Mbyte
        Sort_merge_passes  ­­> sort buffer too small


          ➔   Too big sorts???

    ●    Application or Network problems:
        Aborted_clients
        Aborted_connects

    • Network traffic:
        Bytes_received
        Bytes_sent



Copyright 2007 Oli Sennhauser                The World’s Most Popular Open Source Database   27
Change Application!

    • Locking:
        Table_locks_immediate
        Table_locks_waited      


          ➔   Too high concurrency or too slow queries! -> Optimize
              queries or try InnoDB.

        Innodb_row_lock_current_waits
        Innodb_row_lock_time
        Innodb_row_lock_time_avg
        Innodb_row_lock_time_max
        Innodb_row_lock_waits

          ➔   InnoDB locking! Optimize queries or think about
              changing the application.

Copyright 2007 Oli Sennhauser                The World’s Most Popular Open Source Database   28
Change Application!

    • Missing Indexes:
        Select_full_join
        Select_range_check  ­­> should both be zero!!!


          ➔   Missing Index!

    • Full-Table-Scan:
        Select_scan
        Handler_read_rnd_next
        Sort_scan

          ➔   Find the queries! :-)



Copyright 2007 Oli Sennhauser                The World’s Most Popular Open Source Database   29
Find the slow queries!

    • Quick:

        SHOW [FULL] PROCESSLIST;



    • Proper: Enable the slow query log!

        # my.cnf

        log_slow_queries              = slow_query.log
        long_query_time               = 1
        log_queries_not_using_indexes = 1


          ➔   And now??? Thousands of queries!!!

Copyright 2007 Oli Sennhauser                  The World’s Most Popular Open Source Database   30
Find the slow queries!

    • Profile the slow query log:

        # mysqldumpslow ­s t slow­query.log > slow_query.profile



    • That's how the profile looks like:
        Count: 4498  Time=212.72s (956824s)  Lock=0.04s (198s)  Rows=0.0 (0)
          create table TMP.SS_temp2_36 select l.initlot,s.lot,s.wafer,s.x,s.y,

        Count: 810  Time=121.74s (98610s)  Lock=0.30s (245s)  Rows=0.0 (0)
          insert into TOD.row_descr select l.initlot,w.lot,w.wafer,'S' dataset,'S'

        Count: 477  Time=149.99s (71547s)  Lock=0.01s (4s)  Rows=2.7 (1284)
          SELECT l.lot,count(h.MFG_STEP_NAME) cnt FROM DB1.lot_7000 l left join

        Count: 92  Time=573.43s (52756s)  Lock=0.00s (0s)  Rows=325.6 (29958)
          SELECT ps.X, ps.Y, SUM(N*ps.PARVALUE)/COUNT(ps.PARVALUE) PARMEAN FROM

          ➔   Start working now! EXPLAIN ...
Copyright 2007 Oli Sennhauser                           The World’s Most Popular Open Source Database   31
MySQL EXPLAIN

    • Generate an execution plan:
             EXPLAIN
             SELECT i.number, l.answer
               FROM poll_item i
               JOIN poll_item_l l ON (l.poll_id = i.poll_id
                                  AND l.number = i.number)
             WHERE i.poll_id = '4'
               AND l.language_id = '2'
             ORDER BY i.number ASC;


    +­­­­+­­­­­­­­+­­­­­+­­­­­­­­+­­­­­­­­­­+­­­­­­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+
    | id | select | tab | type   | pos_keys | key     | k_len | ref       | rows | Extra                    |
    +­­­­+­­­­­­­­+­­­­­+­­­­­­­­+­­­­­­­­­­+­­­­­­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+
    |  1 | SIMPLE | i   | ref    | PRIMARY  | PRIMARY | 2     | const     |    5 | Using where; Using index |
    |  1 | SIMPLE | l   | eq_ref | PRIMARY  | PRIMARY | 5     | const,... |    1 | Using where              |
    +­­­­+­­­­­­­­+­­­­­+­­­­­­­­+­­­­­­­­­­+­­­­­­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+



    • Rewrite DML into SELECT.
    • Be cautious with Subqueries! They are executed!

Copyright 2007 Oli Sennhauser                                      The World’s Most Popular Open Source Database   32
MySQL visual explain

    • http://mysqltoolkit.sourceforge.net/
             ./mysql­visual­explain test.exp

             JOIN
             +­ Filter with WHERE
             |  +­ Bookmark lookup
             |     +­ Table
             |     |  table          l
             |     |  possible_keys  PRIMARY
             |     +­ Unique index lookup
             |        key            l­>PRIMARY
             |        possible_keys  PRIMARY
             |        key_len        5
             |        ref            const,topodb.i.number,const
             |        rows           1
             +­ Filter with WHERE
                +­ Index lookup
                   key            i­>PRIMARY
                   possible_keys  PRIMARY
                   key_len        2
                   ref            const
                   rows           5
Copyright 2007 Oli Sennhauser                   The World’s Most Popular Open Source Database   33
Table tuning

    • Indexing
          ➔   See above.
          ➔   What should be indexed and how?


    • Data type tuning
          ●   mysqldump –all­databases ­­no­data


    • Table design




Copyright 2007 Oli Sennhauser             The World’s Most Popular Open Source Database   34
Table tuning – Indexing

    • What should be indexed?
          – All attributes where you JOIN
          – All attributes where you filter (WHERE)
          – All attributes where you ORDER or GROUP BY
          – All attributes where you want to do an Index Scan
            instead of a Table scan.
          – NOT on attributes with an evenly distributed low
            cardinality.
    • How should be indexed?
          –   Indexes can only be used from left to right.
          –   Keep them short.
          –   Compound indexes: INDEX(a, b).
          –   Prefixed indexes: INDEX(a, b(10)).
          –   Do not function-cover indexed attributes
Copyright 2007 Oli Sennhauser                The World’s Most Popular Open Source Database   35
Table tuning – data type tuning

    • Idea behind: Increase the data density!
    • How to get: mysqldump --no-data

        CREATE TABLE betatesters (
          user_id bigint(20) NOT NULL,
          nick varchar(255) NOT NULL,
          registerdate varchar(30) NOT NULL,
          daysregistered int(11) NOT NULL,
          value double default NULL,
          timestamp_data bigint(15) default NULL,
          ip varchar(16) default NULL
          PRIMARY KEY  (`nick`),
          UNIQUE KEY user_id (`user_id`)
          KEY (`user_id`, `nick`)
        ) DEFAULT CHARSET=utf8;

Copyright 2007 Oli Sennhauser           The World’s Most Popular Open Source Database   36
Table tuning – table design

    • Normalization versus de-normalization
          – Joins are expensive --> CPU
          – Denormalized is big --> high redundancy --> RAM -->
            Disk --> Slow
          ➔ Find the trade-off!


          ➔ Bring everything in 3rd NF --> then start denormalizing


            if necessary.
    • vertical and horizontal partitioning:
                        split for static and dynamic data
                                  split for 
                                  example 
                                  by time

Copyright 2007 Oli Sennhauser                  The World’s Most Popular Open Source Database   37
Locality of Reference

    • In theory: We should not care how data are
      stored internally.
    • In practice: It is sometimes good to know!
    • Why?
    • 2 examples from the last 9 months:
          – wind mills
          – vehicle tracking for parcel delivery




Copyright 2007 Oli Sennhauser                  The World’s Most Popular Open Source Database   38
Example 1

    • Several 100 wind mills
    • 50 measured values per
      wind mill
    • Every 5-15 minutes
    • Up to 10 years
    • Dozens of GB of data
    • Record size up to 2k!

    • Search pattern: Give me
      value x from wind mill
      #13 in this time range!

Copyright 2007 Oli Sennhauser           The World’s Most Popular Open Source Database   39
Example 2

       • Several 100 vehicles
       • 24 h/d
       • Every 2 min position
       • Status/position per
         vehicle, later per
         parcel!!!
       • Dozens of GB of data
       • Record size 400 bytes

       • Search pattern: Give
         me all positions of
         vehicle #13 from the
         last 24 hours.
Copyright 2007 Oli Sennhauser           The World’s Most Popular Open Source Database   40
Locality of Reference

    • These 2 examples have one behaviour in
      common:
    • Delivery of data is completely different than
      search pattern.
          – Usually data are delivered sorted by time and also
            (more or less) retrieved by time.
          – In this cases time has a secondary influence!
    • But what happens???




Copyright 2007 Oli Sennhauser                  The World’s Most Popular Open Source Database   41
Locality of Reference

    • Block size is 16k/4k
    • PK is AUTO_INCREMENT




    • Synthetical PK are sometimes dangerous!

Copyright 2007 Oli Sennhauser                  The World’s Most Popular Open Source Database   42
Locality of Reference

    • What to do???

    ➔    PK on (vehicle_id, ts) for example or
    ➔    PK on (windmill_id, data, ts)

    ➔    Can be up to 100 times more efficient (not
         necessarily faster)

    • What about MyISAM?
    • What about Falcon? (Mail from Ann can be
      provided).

Copyright 2007 Oli Sennhauser                  The World’s Most Popular Open Source Database   43
Change Application

    • Where are we now?




    • What else can we do?
          ➔   Avoid – reduce – optimize
    ●    Do not!
          ➔   Put more intelligence into your application!
    ●    Reduce!
          ➔   Do only once. Cache!
    ●    Do it better!
          ➔   Tune the statement, tune the code, tune the logic!

Copyright 2007 Oli Sennhauser                The World’s Most Popular Open Source Database   44
Change Application

    • Clean up first, before you invest into new
      hardware or even a redesign.
          – New hardware brings maybe a factor of 2x
          – Clean up can bring factors up to 10x
          – Sometimes new hardware is cheaper :-(
    • Read issues are a caching problem.
          ➔   Try to cache!
    • Write issues are a batching problem.
          ➔   Try to batch!




Copyright 2007 Oli Sennhauser                The World’s Most Popular Open Source Database   45
commit_demo.pl
                              20




                              15
               run time [s]




                                                                                         normal
                              10                                                         bin_log




                               5




                               0
                                   1   2   4    8   16   32    64       128     256
                                               INSERT/COMMIT




Copyright 2007 Oli Sennhauser                                       The World’s Most Popular Open Source Database   46
Alternatives when exhausted


    • See this afternoon! :-)
    • Change architecture.
          – Scale-Out?
    • Tricks like Materialized Views?
    • Application partitioning




Copyright 2007 Oli Sennhauser          The World’s Most Popular Open Source Database   47
Prevention

    • What can we do to
      prevent Performance
      problems?
          – Do load testing.
          – Do benchmarking.
          – Collect historical data
            and make predictions.
    • An then: Measure and
      monitor...




Copyright 2007 Oli Sennhauser            The World’s Most Popular Open Source Database   48
Measure

    • top, vmstat, iostat,
      dstat, mstat, free, ...
    • mytop, innotop, mtop
    • Nagios, MySQL AR,
      MySQL Administrator,
      Cacti, MRTG, RRD,
      Munin, Moodds, Big
      Sister, MySQLStat,
      Zabbix, Hobbit, Monit,
      ...


     http://www.shinguz.ch/MySQL/mysql_monitoring.html

Copyright 2007 Oli Sennhauser             The World’s Most Popular Open Source Database   49
Virtualization VM /SAN




Copyright 2007 Oli Sennhauser                  The World’s Most Popular Open Source Database   50
RAM disks (I)

    • ORDER BY, GROUP BY, DISTINCT --> temp tables
          – bigger than:
                                tmp_table_size      = 32M
                                max_heap_table_size = 16M
          – BLOB/TEXT
    • Will be written into:
                  tmpdir           =  /tmp/

    • Can be seen in:

                 Created_tmp_disk_tables  0
                 Created_tmp_tables      20

Copyright 2007 Oli Sennhauser              The World’s Most Popular Open Source Database   51
RAM disk (II)

    • Both counters are increased!

    • Solutions?
          –   Change your statement/requirements
          –   Optimize your Query
          –   Reduce size of result set
          –   Avoid BLOB/TEXT


    • And if you cannot?

    --> Use a RAM disk!


Copyright 2007 Oli Sennhauser              The World’s Most Popular Open Source Database   52
RAM disk (III)

    • RAM disk is a disk in RAM :-) --> So you need
      much RAM (8 Gbyte on 32-bit systems?)!
    • Can use your SWAP (we do not want that)!
    • More info:
      /usr/src/linux/Documentation/filesystems


        # cat /proc/filesystems
        # mount tmpfs ­t tmpfs /mnt ­o size=100m
        # mount


    • Bug in 5.0.4x!!! :-(

Copyright 2007 Oli Sennhauser              The World’s Most Popular Open Source Database   53
Now it's up to you...

    •    Output of: SHOW /*!50000 GLOBAL */ STATUS;
    •    Output of: SHOW GLOBAL VARIABLES;
    •    Slow query log.
    •    Slow queries
    •    Execution plans (EXPLAIN SELECT ...)
    •    Output of "vmstat 1" during peak time.




Copyright 2007 Oli Sennhauser                  The World’s Most Popular Open Source Database   54

Mais conteúdo relacionado

Destaque

MySQL High-Availability and Scale-Out architectures
MySQL High-Availability and Scale-Out architecturesMySQL High-Availability and Scale-Out architectures
MySQL High-Availability and Scale-Out architecturesFromDual GmbH
 
Performance Tuning Best Practices
Performance Tuning Best PracticesPerformance Tuning Best Practices
Performance Tuning Best Practiceswebhostingguy
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)Aurimas Mikalauskas
 
浅析My sql事务隔离级别与锁 seanlook
浅析My sql事务隔离级别与锁 seanlook浅析My sql事务隔离级别与锁 seanlook
浅析My sql事务隔离级别与锁 seanlook晓 周
 
MySQL Server Settings Tuning
MySQL Server Settings TuningMySQL Server Settings Tuning
MySQL Server Settings Tuningguest5ca94b
 
MySQL Performance Tuning für Entwickler
MySQL Performance Tuning für EntwicklerMySQL Performance Tuning für Entwickler
MySQL Performance Tuning für EntwicklerFromDual GmbH
 
MySQL Webinar 2/4 Performance tuning, hardware, optimisation
MySQL Webinar 2/4 Performance tuning, hardware, optimisationMySQL Webinar 2/4 Performance tuning, hardware, optimisation
MySQL Webinar 2/4 Performance tuning, hardware, optimisationMark Swarbrick
 
Sharding using MySQL and PHP
Sharding using MySQL and PHPSharding using MySQL and PHP
Sharding using MySQL and PHPMats Kindahl
 
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - SlidesSeveralnines
 
MySQL Performance Tuning Variables
MySQL Performance Tuning VariablesMySQL Performance Tuning Variables
MySQL Performance Tuning VariablesFromDual GmbH
 
Methods of Sharding MySQL
Methods of Sharding MySQLMethods of Sharding MySQL
Methods of Sharding MySQLLaine Campbell
 
Webinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuningWebinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuning晓 周
 
Join-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQLJoin-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQLZendCon
 
MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MYXPLAIN
 
MySQL查询优化浅析
MySQL查询优化浅析MySQL查询优化浅析
MySQL查询优化浅析frogd
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance TuningMark Swarbrick
 
MySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesMySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesIsaac Mosquera
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain ExplainedJeremy Coates
 

Destaque (20)

MySQL High-Availability and Scale-Out architectures
MySQL High-Availability and Scale-Out architecturesMySQL High-Availability and Scale-Out architectures
MySQL High-Availability and Scale-Out architectures
 
Performance Tuning Best Practices
Performance Tuning Best PracticesPerformance Tuning Best Practices
Performance Tuning Best Practices
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
浅析My sql事务隔离级别与锁 seanlook
浅析My sql事务隔离级别与锁 seanlook浅析My sql事务隔离级别与锁 seanlook
浅析My sql事务隔离级别与锁 seanlook
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
 
MySQL Server Settings Tuning
MySQL Server Settings TuningMySQL Server Settings Tuning
MySQL Server Settings Tuning
 
MySQL Performance Tuning für Entwickler
MySQL Performance Tuning für EntwicklerMySQL Performance Tuning für Entwickler
MySQL Performance Tuning für Entwickler
 
MySQL Webinar 2/4 Performance tuning, hardware, optimisation
MySQL Webinar 2/4 Performance tuning, hardware, optimisationMySQL Webinar 2/4 Performance tuning, hardware, optimisation
MySQL Webinar 2/4 Performance tuning, hardware, optimisation
 
Sharding using MySQL and PHP
Sharding using MySQL and PHPSharding using MySQL and PHP
Sharding using MySQL and PHP
 
Perf Tuning Short
Perf Tuning ShortPerf Tuning Short
Perf Tuning Short
 
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
 
MySQL Performance Tuning Variables
MySQL Performance Tuning VariablesMySQL Performance Tuning Variables
MySQL Performance Tuning Variables
 
Methods of Sharding MySQL
Methods of Sharding MySQLMethods of Sharding MySQL
Methods of Sharding MySQL
 
Webinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuningWebinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuning
 
Join-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQLJoin-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQL
 
MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6
 
MySQL查询优化浅析
MySQL查询优化浅析MySQL查询优化浅析
MySQL查询优化浅析
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance Tuning
 
MySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesMySQL Performance Tips & Best Practices
MySQL Performance Tips & Best Practices
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain Explained
 

Semelhante a MySQL Performance Tuning

Improving Hadoop Performance via Linux
Improving Hadoop Performance via LinuxImproving Hadoop Performance via Linux
Improving Hadoop Performance via LinuxAlex Moundalexis
 
MySQL Optimization from a Developer's point of view
MySQL Optimization from a Developer's point of viewMySQL Optimization from a Developer's point of view
MySQL Optimization from a Developer's point of viewSachin Khosla
 
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...PostgreSQL-Consulting
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)MongoDB
 
Real time analytics using Hadoop and Elasticsearch
Real time analytics using Hadoop and ElasticsearchReal time analytics using Hadoop and Elasticsearch
Real time analytics using Hadoop and ElasticsearchAbhishek Andhavarapu
 
Managing Security At 1M Events a Second using Elasticsearch
Managing Security At 1M Events a Second using ElasticsearchManaging Security At 1M Events a Second using Elasticsearch
Managing Security At 1M Events a Second using ElasticsearchJoe Alex
 
Locality of (p)reference
Locality of (p)referenceLocality of (p)reference
Locality of (p)referenceFromDual GmbH
 
Key-Value-Stores -- The Key to Scaling?
Key-Value-Stores -- The Key to Scaling?Key-Value-Stores -- The Key to Scaling?
Key-Value-Stores -- The Key to Scaling?Tim Lossen
 
The 5 Minute MySQL DBA
The 5 Minute MySQL DBAThe 5 Minute MySQL DBA
The 5 Minute MySQL DBAIrawan Soetomo
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment StrategiesMongoDB
 
Linux performance tuning & stabilization tips (mysqlconf2010)
Linux performance tuning & stabilization tips (mysqlconf2010)Linux performance tuning & stabilization tips (mysqlconf2010)
Linux performance tuning & stabilization tips (mysqlconf2010)Yoshinori Matsunobu
 
Scaling Ceph at CERN - Ceph Day Frankfurt
Scaling Ceph at CERN - Ceph Day Frankfurt Scaling Ceph at CERN - Ceph Day Frankfurt
Scaling Ceph at CERN - Ceph Day Frankfurt Ceph Community
 
Storage Systems For Scalable systems
Storage Systems For Scalable systemsStorage Systems For Scalable systems
Storage Systems For Scalable systemselliando dias
 
Top 10 lessons learned from deploying hadoop in a private cloud
Top 10 lessons learned from deploying hadoop in a private cloudTop 10 lessons learned from deploying hadoop in a private cloud
Top 10 lessons learned from deploying hadoop in a private cloudRogue Wave Software
 
Deployment Strategy
Deployment StrategyDeployment Strategy
Deployment StrategyMongoDB
 
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?DATAVERSITY
 
OSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin CharlesOSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin CharlesNETWAYS
 
Network support for resource disaggregation in next-generation datacenters
Network support for resource disaggregation in next-generation datacentersNetwork support for resource disaggregation in next-generation datacenters
Network support for resource disaggregation in next-generation datacentersSangjin Han
 

Semelhante a MySQL Performance Tuning (20)

Improving Hadoop Performance via Linux
Improving Hadoop Performance via LinuxImproving Hadoop Performance via Linux
Improving Hadoop Performance via Linux
 
MySQL Optimization from a Developer's point of view
MySQL Optimization from a Developer's point of viewMySQL Optimization from a Developer's point of view
MySQL Optimization from a Developer's point of view
 
Running MySQL on Linux
Running MySQL on LinuxRunning MySQL on Linux
Running MySQL on Linux
 
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)
 
Real time analytics using Hadoop and Elasticsearch
Real time analytics using Hadoop and ElasticsearchReal time analytics using Hadoop and Elasticsearch
Real time analytics using Hadoop and Elasticsearch
 
Managing Security At 1M Events a Second using Elasticsearch
Managing Security At 1M Events a Second using ElasticsearchManaging Security At 1M Events a Second using Elasticsearch
Managing Security At 1M Events a Second using Elasticsearch
 
Locality of (p)reference
Locality of (p)referenceLocality of (p)reference
Locality of (p)reference
 
Key-Value-Stores -- The Key to Scaling?
Key-Value-Stores -- The Key to Scaling?Key-Value-Stores -- The Key to Scaling?
Key-Value-Stores -- The Key to Scaling?
 
The 5 Minute MySQL DBA
The 5 Minute MySQL DBAThe 5 Minute MySQL DBA
The 5 Minute MySQL DBA
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment Strategies
 
Linux performance tuning & stabilization tips (mysqlconf2010)
Linux performance tuning & stabilization tips (mysqlconf2010)Linux performance tuning & stabilization tips (mysqlconf2010)
Linux performance tuning & stabilization tips (mysqlconf2010)
 
Scaling Ceph at CERN - Ceph Day Frankfurt
Scaling Ceph at CERN - Ceph Day Frankfurt Scaling Ceph at CERN - Ceph Day Frankfurt
Scaling Ceph at CERN - Ceph Day Frankfurt
 
Storage Systems For Scalable systems
Storage Systems For Scalable systemsStorage Systems For Scalable systems
Storage Systems For Scalable systems
 
Top 10 lessons learned from deploying hadoop in a private cloud
Top 10 lessons learned from deploying hadoop in a private cloudTop 10 lessons learned from deploying hadoop in a private cloud
Top 10 lessons learned from deploying hadoop in a private cloud
 
Deployment Strategy
Deployment StrategyDeployment Strategy
Deployment Strategy
 
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
 
OSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin CharlesOSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin Charles
 
Network support for resource disaggregation in next-generation datacenters
Network support for resource disaggregation in next-generation datacentersNetwork support for resource disaggregation in next-generation datacenters
Network support for resource disaggregation in next-generation datacenters
 
Deployment
DeploymentDeployment
Deployment
 

Mais de FromDual GmbH

MariaDB/MySQL pitfalls - And how to come out again...
MariaDB/MySQL pitfalls - And how to come out again...MariaDB/MySQL pitfalls - And how to come out again...
MariaDB/MySQL pitfalls - And how to come out again...FromDual GmbH
 
MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?FromDual GmbH
 
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration Workshop
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration WorkshopPXC 5.5 to MariaDB 10.4 Galera Cluster Migration Workshop
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration WorkshopFromDual GmbH
 
IT Tage 2019 MariaDB 10.4 New Features
IT Tage 2019 MariaDB 10.4 New FeaturesIT Tage 2019 MariaDB 10.4 New Features
IT Tage 2019 MariaDB 10.4 New FeaturesFromDual GmbH
 
MariaDB 10.4 New Features
MariaDB 10.4 New FeaturesMariaDB 10.4 New Features
MariaDB 10.4 New FeaturesFromDual GmbH
 
MariaDB 10.2 New Features
MariaDB 10.2 New FeaturesMariaDB 10.2 New Features
MariaDB 10.2 New FeaturesFromDual GmbH
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaFromDual GmbH
 
MySQL für Oracle DBA's
MySQL für Oracle DBA'sMySQL für Oracle DBA's
MySQL für Oracle DBA'sFromDual GmbH
 
MySQL Backup/Recovery
MySQL Backup/RecoveryMySQL Backup/Recovery
MySQL Backup/RecoveryFromDual GmbH
 
MySQL Beispiele aus der Praxis - Wie setzen Kunden MySQL ein?
MySQL Beispiele aus der Praxis - Wie setzen Kunden MySQL ein?MySQL Beispiele aus der Praxis - Wie setzen Kunden MySQL ein?
MySQL Beispiele aus der Praxis - Wie setzen Kunden MySQL ein?FromDual GmbH
 
MySQL-Server im Teamwork - Replikation und Cluster
MySQL-Server im Teamwork - Replikation und ClusterMySQL-Server im Teamwork - Replikation und Cluster
MySQL-Server im Teamwork - Replikation und ClusterFromDual GmbH
 
Der Datenbank-Backup ist gemacht - was nun?
Der Datenbank-Backup ist gemacht - was nun?Der Datenbank-Backup ist gemacht - was nun?
Der Datenbank-Backup ist gemacht - was nun?FromDual GmbH
 
Weltweite Produktionsdatenverwaltung mit MySQL-Replikation
Weltweite Produktionsdatenverwaltung mit MySQL-ReplikationWeltweite Produktionsdatenverwaltung mit MySQL-Replikation
Weltweite Produktionsdatenverwaltung mit MySQL-ReplikationFromDual GmbH
 
MySQL Performance Tuning für Oracle-DBA's
MySQL Performance Tuning für Oracle-DBA'sMySQL Performance Tuning für Oracle-DBA's
MySQL Performance Tuning für Oracle-DBA'sFromDual GmbH
 
MySQL Security SLAC 2015
MySQL Security SLAC 2015MySQL Security SLAC 2015
MySQL Security SLAC 2015FromDual GmbH
 
MySQL Replikation - Die Eier legende Wollmilchsau?
MySQL Replikation - Die Eier legende Wollmilchsau?MySQL Replikation - Die Eier legende Wollmilchsau?
MySQL Replikation - Die Eier legende Wollmilchsau?FromDual GmbH
 
Reading MySQL fingerprints
Reading MySQL fingerprintsReading MySQL fingerprints
Reading MySQL fingerprintsFromDual GmbH
 
High-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLHigh-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLFromDual GmbH
 
MySQL always-up with Galera Cluster
MySQL always-up with Galera ClusterMySQL always-up with Galera Cluster
MySQL always-up with Galera ClusterFromDual GmbH
 

Mais de FromDual GmbH (20)

MariaDB/MySQL pitfalls - And how to come out again...
MariaDB/MySQL pitfalls - And how to come out again...MariaDB/MySQL pitfalls - And how to come out again...
MariaDB/MySQL pitfalls - And how to come out again...
 
MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?MariaDB / MySQL tripping hazard and how to get out again?
MariaDB / MySQL tripping hazard and how to get out again?
 
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration Workshop
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration WorkshopPXC 5.5 to MariaDB 10.4 Galera Cluster Migration Workshop
PXC 5.5 to MariaDB 10.4 Galera Cluster Migration Workshop
 
IT Tage 2019 MariaDB 10.4 New Features
IT Tage 2019 MariaDB 10.4 New FeaturesIT Tage 2019 MariaDB 10.4 New Features
IT Tage 2019 MariaDB 10.4 New Features
 
MariaDB 10.4 New Features
MariaDB 10.4 New FeaturesMariaDB 10.4 New Features
MariaDB 10.4 New Features
 
MariaDB 10.2 New Features
MariaDB 10.2 New FeaturesMariaDB 10.2 New Features
MariaDB 10.2 New Features
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schema
 
MySQL für Oracle DBA's
MySQL für Oracle DBA'sMySQL für Oracle DBA's
MySQL für Oracle DBA's
 
MySQL Backup/Recovery
MySQL Backup/RecoveryMySQL Backup/Recovery
MySQL Backup/Recovery
 
MySQL Beispiele aus der Praxis - Wie setzen Kunden MySQL ein?
MySQL Beispiele aus der Praxis - Wie setzen Kunden MySQL ein?MySQL Beispiele aus der Praxis - Wie setzen Kunden MySQL ein?
MySQL Beispiele aus der Praxis - Wie setzen Kunden MySQL ein?
 
MySQL-Server im Teamwork - Replikation und Cluster
MySQL-Server im Teamwork - Replikation und ClusterMySQL-Server im Teamwork - Replikation und Cluster
MySQL-Server im Teamwork - Replikation und Cluster
 
Der Datenbank-Backup ist gemacht - was nun?
Der Datenbank-Backup ist gemacht - was nun?Der Datenbank-Backup ist gemacht - was nun?
Der Datenbank-Backup ist gemacht - was nun?
 
Weltweite Produktionsdatenverwaltung mit MySQL-Replikation
Weltweite Produktionsdatenverwaltung mit MySQL-ReplikationWeltweite Produktionsdatenverwaltung mit MySQL-Replikation
Weltweite Produktionsdatenverwaltung mit MySQL-Replikation
 
MySQL Performance Tuning für Oracle-DBA's
MySQL Performance Tuning für Oracle-DBA'sMySQL Performance Tuning für Oracle-DBA's
MySQL Performance Tuning für Oracle-DBA's
 
MySQL Security SLAC 2015
MySQL Security SLAC 2015MySQL Security SLAC 2015
MySQL Security SLAC 2015
 
MySQL Replikation - Die Eier legende Wollmilchsau?
MySQL Replikation - Die Eier legende Wollmilchsau?MySQL Replikation - Die Eier legende Wollmilchsau?
MySQL Replikation - Die Eier legende Wollmilchsau?
 
Reading MySQL fingerprints
Reading MySQL fingerprintsReading MySQL fingerprints
Reading MySQL fingerprints
 
High-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLHigh-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQL
 
MySQL always-up with Galera Cluster
MySQL always-up with Galera ClusterMySQL always-up with Galera Cluster
MySQL always-up with Galera Cluster
 
HA with Galera
HA with GaleraHA with Galera
HA with Galera
 

Último

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Último (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

MySQL Performance Tuning

  • 1. MySQL Performance Tuning A practical guide Oli Sennhauser Senior Consultant osennhauser@mysql.com Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 1
  • 2. Introduction • Who we are? • What we want? Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 2
  • 3. Table of Contents • Find the problem • MySQL architecture • Database settings • Detect and eliminate slow queries • Table tuning • Application tuning • Alternatives • Prevention • Dirty tricks and other stuff • Now it's up to you... Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 3
  • 4. DBA: We have a problem! • What does performance mean to you? • How does it look like? – DB is (suddenly!?) slow. – No historical data (or not the one we need). – “Screw something on the DB!” – We are short before going life and much too slow!!! • We have a problem. And what now? Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 4
  • 5. Efficiency of tuning measurements • Application/Architecture/Design ➳ No way! For what ever reason :-( • So on the DBA side: Memory, DB settings, I/O, Indexes, etc. Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 5
  • 6. Find the problem / the bottleneck • No history data!?! :-( • Best if: – you can simulate it – it happens predictable and/or periodically • Your friends are: – vmstat / dstat – iostat – top – any graphical history of values Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 6
  • 7. Tuning means ... • The tuning life cycle: • Only one change at a time Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 7
  • 8. Measure • Find the bottleneck / limiting resource: – I/O – Memory – CPU – Network bandwidth • But how? Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 8
  • 9. Measure I/O • vmstat # vmstat 1 procs ­­­swap­­ ­­­­­io­­­­ ­­­­cpu­­­­  r  b   si   so    bi    bo us sy id wa  0  0    3    3    94   143 21 21 56  2  0  0    0    0     0     4  9 37 54  0 • iostat (--> sysstat package) # iostat ­x 1 avg­cpu:  %user   %nice %system %iowait  %steal   %idle            5.88    0.00   34.31    2.94    0.00   56.86 Device:     r/s   w/s  rkB/s  wkB/s  await  svctm  %util hda        0.00  0.00   0.00   0.00   0.00   0.00   0.00 hdc        0.00  2.94   0.00  23.53  14.67  12.00   3.53 Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 9
  • 10. Measure memory • ps # ps ­eo user,pid,%cpu,%mem,vsz,rsz,comm ­­sort ­vsz |   egrep 'mysql|COMMAND' USER       PID %CPU %MEM    VSZ   RSZ COMMAND mysql     1361  0.0  1.5 108368 16444 mysqld mysql     1210  0.0  0.1   4536  1956 bash mysql     1289  0.0  0.1   4060  1444 safe_mysqld mysql     1204  0.0  0.1   4048  1404 su • free / top: #free              total   used    free shared buffers cached Mem:       1036016 983864   52152      0   35484 547432 ­/+ buffers/cache: 400948  635068 swap:      4202112  96148 4105964 Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 10
  • 11. Measure CPU • top • vmstat • dstat Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 11
  • 12. Measure network bandwidth • dstat # dstat ­­­­total­cpu­usage­­­­ ­dsk/total­ ­net/total­ usr sys idl wai hiq siq| read  writ| recv  send  21   5  56   2   0  15|  25k   39k|   0     0  13   3  84   0   0   0|   0     0 | 994B  437B   8   4  88   0   0   0|   0     0 | 632B  484B • ifconfig # watch ­n 1 ­d "/sbin/ifconfig | egrep 'Link|bytes'" eth0      Link encap:Ethernet  HWaddr 00:30:1B:2D:67:B4           RX bytes:1751779749 (1670.6 Mb)           TX bytes:191340381 (182.4 Mb) Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 12
  • 13. Think • I/O – Who does it? – Is it read or write? – Is it random I/O or sequential I/O? • Memory – Easy to find! – DB sizing – Is it somebody else? • CPU – Easy to find! – Who is “burning” CPU? • Network bandwidth – Who does it? – Sniff traffic? Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 13
  • 14. Change • What could be changed? • Hardware -> I/O system (RAID5), RAM, CPU, NW • O/S -> do not touch (kernel upgrade) • DB -> my.cnf • Application -> Queries!!! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 14
  • 15. Change Hardware • More RAM helps more!!! • Faster CPU if it is the bottleneck (not more!) • More expensive I/O system: – RAID5 is bad for databases!!! – RAID10 is good. – Many spindles – Battery buffered I/O system cache??? • 1 Gbit Network? • Forget about virtualization (VMware etc.)!!! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 15
  • 16. Change O/S • Use mainstream O/S -> for MySQL this means SLES/RHEL! • Use 64-bit architecture (> 4 GB RAM) • Use recent kernel (>= 2.6.12) • Use mainstream file system -> ext3 and xfs • Take what you are most familiar with! --> But on O/S you cannot change much. They are already optimal! :-) Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 16
  • 17. Change MySQL: Architecture Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 17
  • 18. Change MySQL: Performance Features • The magic of caching: “Do as little work as possible: Be lazy!!!” • Performance features: – Thread cache – Query cache – Prepared statements – Stored Procedures (see “the SP trap!”) – delayed INSERT (MyISAM only) Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 18
  • 19. Change MySQL: database settings • “The big 3!” – key_buffer_size – innodb_buffer_pool_size – innodb_log_file_size • Some others: query_cache_size, thread_cache_size • My approach: – use defaults (or templates) – add: “the big 3” + 2 (see above) – do NOT change except it was proved and measured that is useful! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 19
  • 20. Change MySQL • Where to change? – my.cnf (Caution: many possible places!!!) • Where to measure? – SHOW /*!50000 GLOBAL */ STATUS; • Where to cheat? – http://dev.mysql.com/doc/refman/5.0/en/index.html – 5.2.3. System Variables – 5.2.5. Status Variables Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 20
  • 21. The big 3 • MyISAM key_buffer_size               = 25­33% of RAM Key_blocks_unused             ­­> actual value Key_blocks_used               ­­> high water mark Key_read_requests / Key_reads ­­> >= 99% ideally • InnoDB innodb_buffer_pool_size             = 80% of RAM Innodb_buffer_pool_pages_free Innodb_buffer_pool_read_requests / Innodb_buffer_pool_reads            ­­> >= 99% ideally Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 21
  • 22. The big 3 • InnoDB innodb_log_file_size          = 32 ­ 128 Mbyte Innodb_os_log_pending_fsyncs  ­­> ???                               ­­> hiccups! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 22
  • 23. Query cache & thread cache • Query cache query_cache_size        = 32 ­ 128 Mbyte (caution: 512!) Qcache_total_blocks Qcache_free_blocks Qcache_free_memory      ­­> Fragmentation Qcache_hits Qcache_inserts          ­­> Hit ratio, ideally >> 2 : 1 Qcache_lowmem_prunes    ­­> too small or too fragmented • Thread cache thread_cache_size        = 8 ­ 128 Threads_cached Threads_created          ­­> should not grow much over time Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 23
  • 24. Some more... • That's it! :-) • Avoid any kind of I/O: logging! sync_binlog       ­­> 0 !!! #log              ­­> Not on production!!! #log_bin          ­­> Where we do NOT need it!!! log_slow_queries  ­­> is OK, we do not have such :­) • Try to avoid sync writing: innodb_flush_log_at_trx_commit = 2 ➔ Simulates MyISAM behaviour for InnoDB. But caution! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 24
  • 25. Some more... • Table cache table_cache     = 64 ­ 2048 Open_tables     ­­> <= table_cache Opened_tables   ­­> should change moderately • Other InnoDB settings: innodb_additional_mem_pool_size ➔ Do NOT change this! > 20 Mbyte is non sense! innodb_flush_method ➔ Sometimes O_DIRECT or O_DSYNC can help. But test before! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 25
  • 26. Change Application! • Transaction log and binlog cache: Binlog_cache_disk_use  ­­> increase binlog_cache_size Innodb_log_waits       ­­> increase innodb_log_buffer_size ➔ Too big transactions??? • Temporary results: max_heap_table_size      = 16 ­ 256 Mbyte tmp_table_size           = 32 ­ 512 Mbyte Created_tmp_disk_tables  ­­> changes often ➔ Too big temporary results? Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 26
  • 27. Change Application! • Sort buffer: sort_buffer_size   = 2 ­ 16 Mbyte Sort_merge_passes  ­­> sort buffer too small ➔ Too big sorts??? ● Application or Network problems: Aborted_clients Aborted_connects • Network traffic: Bytes_received Bytes_sent Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 27
  • 28. Change Application! • Locking: Table_locks_immediate Table_locks_waited       ➔ Too high concurrency or too slow queries! -> Optimize queries or try InnoDB. Innodb_row_lock_current_waits Innodb_row_lock_time Innodb_row_lock_time_avg Innodb_row_lock_time_max Innodb_row_lock_waits ➔ InnoDB locking! Optimize queries or think about changing the application. Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 28
  • 29. Change Application! • Missing Indexes: Select_full_join Select_range_check  ­­> should both be zero!!! ➔ Missing Index! • Full-Table-Scan: Select_scan Handler_read_rnd_next Sort_scan ➔ Find the queries! :-) Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 29
  • 30. Find the slow queries! • Quick: SHOW [FULL] PROCESSLIST; • Proper: Enable the slow query log! # my.cnf log_slow_queries              = slow_query.log long_query_time               = 1 log_queries_not_using_indexes = 1 ➔ And now??? Thousands of queries!!! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 30
  • 31. Find the slow queries! • Profile the slow query log: # mysqldumpslow ­s t slow­query.log > slow_query.profile • That's how the profile looks like: Count: 4498  Time=212.72s (956824s)  Lock=0.04s (198s)  Rows=0.0 (0)   create table TMP.SS_temp2_36 select l.initlot,s.lot,s.wafer,s.x,s.y, Count: 810  Time=121.74s (98610s)  Lock=0.30s (245s)  Rows=0.0 (0)   insert into TOD.row_descr select l.initlot,w.lot,w.wafer,'S' dataset,'S' Count: 477  Time=149.99s (71547s)  Lock=0.01s (4s)  Rows=2.7 (1284)   SELECT l.lot,count(h.MFG_STEP_NAME) cnt FROM DB1.lot_7000 l left join Count: 92  Time=573.43s (52756s)  Lock=0.00s (0s)  Rows=325.6 (29958)   SELECT ps.X, ps.Y, SUM(N*ps.PARVALUE)/COUNT(ps.PARVALUE) PARMEAN FROM ➔ Start working now! EXPLAIN ... Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 31
  • 32. MySQL EXPLAIN • Generate an execution plan: EXPLAIN SELECT i.number, l.answer   FROM poll_item i   JOIN poll_item_l l ON (l.poll_id = i.poll_id                      AND l.number = i.number) WHERE i.poll_id = '4'   AND l.language_id = '2' ORDER BY i.number ASC; +­­­­+­­­­­­­­+­­­­­+­­­­­­­­+­­­­­­­­­­+­­­­­­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+ | id | select | tab | type   | pos_keys | key     | k_len | ref       | rows | Extra                    | +­­­­+­­­­­­­­+­­­­­+­­­­­­­­+­­­­­­­­­­+­­­­­­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+ |  1 | SIMPLE | i   | ref    | PRIMARY  | PRIMARY | 2     | const     |    5 | Using where; Using index | |  1 | SIMPLE | l   | eq_ref | PRIMARY  | PRIMARY | 5     | const,... |    1 | Using where              | +­­­­+­­­­­­­­+­­­­­+­­­­­­­­+­­­­­­­­­­+­­­­­­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+ • Rewrite DML into SELECT. • Be cautious with Subqueries! They are executed! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 32
  • 33. MySQL visual explain • http://mysqltoolkit.sourceforge.net/ ./mysql­visual­explain test.exp JOIN +­ Filter with WHERE |  +­ Bookmark lookup |     +­ Table |     |  table          l |     |  possible_keys  PRIMARY |     +­ Unique index lookup |        key            l­>PRIMARY |        possible_keys  PRIMARY |        key_len        5 |        ref            const,topodb.i.number,const |        rows           1 +­ Filter with WHERE    +­ Index lookup       key            i­>PRIMARY       possible_keys  PRIMARY       key_len        2       ref            const       rows           5 Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 33
  • 34. Table tuning • Indexing ➔ See above. ➔ What should be indexed and how? • Data type tuning ● mysqldump –all­databases ­­no­data • Table design Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 34
  • 35. Table tuning – Indexing • What should be indexed? – All attributes where you JOIN – All attributes where you filter (WHERE) – All attributes where you ORDER or GROUP BY – All attributes where you want to do an Index Scan instead of a Table scan. – NOT on attributes with an evenly distributed low cardinality. • How should be indexed? – Indexes can only be used from left to right. – Keep them short. – Compound indexes: INDEX(a, b). – Prefixed indexes: INDEX(a, b(10)). – Do not function-cover indexed attributes Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 35
  • 36. Table tuning – data type tuning • Idea behind: Increase the data density! • How to get: mysqldump --no-data CREATE TABLE betatesters (   user_id bigint(20) NOT NULL,   nick varchar(255) NOT NULL,   registerdate varchar(30) NOT NULL,   daysregistered int(11) NOT NULL,   value double default NULL,   timestamp_data bigint(15) default NULL,   ip varchar(16) default NULL   PRIMARY KEY  (`nick`),   UNIQUE KEY user_id (`user_id`)   KEY (`user_id`, `nick`) ) DEFAULT CHARSET=utf8; Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 36
  • 37. Table tuning – table design • Normalization versus de-normalization – Joins are expensive --> CPU – Denormalized is big --> high redundancy --> RAM --> Disk --> Slow ➔ Find the trade-off! ➔ Bring everything in 3rd NF --> then start denormalizing if necessary. • vertical and horizontal partitioning: split for static and dynamic data split for  example  by time Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 37
  • 38. Locality of Reference • In theory: We should not care how data are stored internally. • In practice: It is sometimes good to know! • Why? • 2 examples from the last 9 months: – wind mills – vehicle tracking for parcel delivery Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 38
  • 39. Example 1 • Several 100 wind mills • 50 measured values per wind mill • Every 5-15 minutes • Up to 10 years • Dozens of GB of data • Record size up to 2k! • Search pattern: Give me value x from wind mill #13 in this time range! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 39
  • 40. Example 2 • Several 100 vehicles • 24 h/d • Every 2 min position • Status/position per vehicle, later per parcel!!! • Dozens of GB of data • Record size 400 bytes • Search pattern: Give me all positions of vehicle #13 from the last 24 hours. Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 40
  • 41. Locality of Reference • These 2 examples have one behaviour in common: • Delivery of data is completely different than search pattern. – Usually data are delivered sorted by time and also (more or less) retrieved by time. – In this cases time has a secondary influence! • But what happens??? Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 41
  • 42. Locality of Reference • Block size is 16k/4k • PK is AUTO_INCREMENT • Synthetical PK are sometimes dangerous! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 42
  • 43. Locality of Reference • What to do??? ➔ PK on (vehicle_id, ts) for example or ➔ PK on (windmill_id, data, ts) ➔ Can be up to 100 times more efficient (not necessarily faster) • What about MyISAM? • What about Falcon? (Mail from Ann can be provided). Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 43
  • 44. Change Application • Where are we now? • What else can we do? ➔ Avoid – reduce – optimize ● Do not! ➔ Put more intelligence into your application! ● Reduce! ➔ Do only once. Cache! ● Do it better! ➔ Tune the statement, tune the code, tune the logic! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 44
  • 45. Change Application • Clean up first, before you invest into new hardware or even a redesign. – New hardware brings maybe a factor of 2x – Clean up can bring factors up to 10x – Sometimes new hardware is cheaper :-( • Read issues are a caching problem. ➔ Try to cache! • Write issues are a batching problem. ➔ Try to batch! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 45
  • 46. commit_demo.pl 20 15 run time [s] normal 10 bin_log 5 0 1 2 4 8 16 32 64 128 256 INSERT/COMMIT Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 46
  • 47. Alternatives when exhausted • See this afternoon! :-) • Change architecture. – Scale-Out? • Tricks like Materialized Views? • Application partitioning Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 47
  • 48. Prevention • What can we do to prevent Performance problems? – Do load testing. – Do benchmarking. – Collect historical data and make predictions. • An then: Measure and monitor... Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 48
  • 49. Measure • top, vmstat, iostat, dstat, mstat, free, ... • mytop, innotop, mtop • Nagios, MySQL AR, MySQL Administrator, Cacti, MRTG, RRD, Munin, Moodds, Big Sister, MySQLStat, Zabbix, Hobbit, Monit, ... http://www.shinguz.ch/MySQL/mysql_monitoring.html Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 49
  • 50. Virtualization VM /SAN Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 50
  • 51. RAM disks (I) • ORDER BY, GROUP BY, DISTINCT --> temp tables – bigger than: tmp_table_size      = 32M max_heap_table_size = 16M – BLOB/TEXT • Will be written into: tmpdir           =  /tmp/ • Can be seen in: Created_tmp_disk_tables  0 Created_tmp_tables      20 Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 51
  • 52. RAM disk (II) • Both counters are increased! • Solutions? – Change your statement/requirements – Optimize your Query – Reduce size of result set – Avoid BLOB/TEXT • And if you cannot? --> Use a RAM disk! Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 52
  • 53. RAM disk (III) • RAM disk is a disk in RAM :-) --> So you need much RAM (8 Gbyte on 32-bit systems?)! • Can use your SWAP (we do not want that)! • More info: /usr/src/linux/Documentation/filesystems # cat /proc/filesystems # mount tmpfs ­t tmpfs /mnt ­o size=100m # mount • Bug in 5.0.4x!!! :-( Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 53
  • 54. Now it's up to you... • Output of: SHOW /*!50000 GLOBAL */ STATUS; • Output of: SHOW GLOBAL VARIABLES; • Slow query log. • Slow queries • Execution plans (EXPLAIN SELECT ...) • Output of "vmstat 1" during peak time. Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database 54