SlideShare a Scribd company logo
1 of 33
Download to read offline
Locality of (p)reference

                 Some thoughts about MySQL consulting issues




                                 Oli Sennhauser
                                  Senior Consultant
                                osennhauser@mysql.com



Copyright 2007 MySQL AB                       The World’s Most Popular Open Source Database   1
ToC

    •   Locality of (p)reference
    •   commit_demo.pl (performance test/numbers)
    •   InnoDB information (discussion)
    •   RAM disk
    •   MySQL variables (discussion)
    •   MyISAM log
    •   MySQL Visual Explain




Copyright 2007 MySQL AB           The World’s Most Popular Open Source Database   2
Locality of (p)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 MySQL AB                     The World’s Most Popular Open Source Database   3
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 MySQL AB           The World’s Most Popular Open Source Database   4
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 MySQL AB           The World’s Most Popular Open Source Database   5
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 MySQL AB                   The World’s Most Popular Open Source Database   6
Locality of Reference

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




    • Synthecial PK are sometimes dangerous!

Copyright 2007 MySQL AB                  The World’s Most Popular Open Source Database   7
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 MySQL AB                  The World’s Most Popular Open Source Database   8
commit_demo.pl

    • Little ugly script to test your I/O system:
          http://www.shinguz.ch/MySQL/consulting_tools.html
    • What it does:
       INSERT -> COMMIT -> INSERT -> COMMIT -> ...
    • The idea behind it
    • How to call:

            ./commit_demo.pl ­u root ­c
            ./commit_demo.pl ­u root ­i <n>
            ./commit_demo.pl ­u root ­c

    • Does NOT work with 6.0 :-(
    • Lit: http://www.shinguz.ch/MySQL/transaction_performance.pdf
Copyright 2007 MySQL AB                      The World’s Most Popular Open Source Database   9
commit_demo.pl

                          40

                          35

                          30
           run time [s]




                          25
                                                                                     normal

                          20                                                         bin_log
                                                                                     sync_binlog
                                                                                     MyISAM
                          15
                                                                                     Backup
                                                                                     Theory
                          10

                          5

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



Copyright 2007 MySQL AB                                         The World’s Most Popular Open Source Database   10
commit_demo.pl




Copyright 2007 MySQL AB             The World’s Most Popular Open Source Database   11
commit_demo.pl


      Time          trx          trx    theorie                  Comment
        [s]     [ms/trx] [trx/s] [ms/trx]
        12.3               1.2    833        8.3 Laptop, with good disk cache
        27.2               2.7    370        2.5 SAN with up to 2000 I/O per second
        41.0               4.1    244        4.0 Baseline for the following test
        42.2               4.2    238        4.0 With DRBD, 2.5% slower
       157.0              15.7     64        4.0 with XFS, badly configured?
        86.4               8.6    116        8.0 With binary logging
       565.0              56.5     18        8.0 sync_binlog=1!!!




Copyright 2007 MySQL AB                                The World’s Most Popular Open Source Database   12
InnoDB information (discussion)

    •   SHOW GLOBAL STATUS LIKE 'InnoDB%';
    •   SHOW ENGINE INNODB STATUSG
    •   OK. But what does it mean to me?
    •   Let's start with a rough architecture picture:




Copyright 2007 MySQL AB               The World’s Most Popular Open Source Database   13
InnoDB architecture            mysqld
                                                               secondary index buffer
                                                                                                              data pages
                                                                                                              index pages
                                                                                                              adaptive hash idx
                                                                                                              undo records
                                                       buffer pool
    • SHOW STATUS;                                                                                            lock info table




                                trx log buffer
      Innodb_buffer_pool_%
      Innodb_data_%
      Innodb_dblwr_%
      Innodb_log_%
      Innodb_os_log_%
      Innodb_pages_%
      Innodb_row_lock_%




                                                                                            async
                                                                    OS file cache




                                     sync
      Innodb_rows_%


     • SHOW INNODB STATUS;                             system table space: ibdata1




                                        ib_logfile1
                                                        undo

      SEMAPHORES                                              double write area                     dd
      TRANSACTIONS
                                        ib_logfile2
      FILE I/O
      INSERT BUFFER AND                                            tables/indexes
        ADAPTIVE HASH INDEX
                                        ib_logfilen




      LOG
      BUFFER POOL AND MEMORY                          table table space table table space table table space


      ROW OPERATIONS
Copyright 2007 MySQL AB                                The World’s Most Popular Open Source Database                              14
Innodb_buffer_pool%

         Innodb_buffer_pool_pages_dirty   ­­­­­­­­­­­­­­­­­­­­­­
       + Innodb_buffer_pool_pages_clean   BUFFER POOL AND MEMORY
       ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­      ­­­­­­­­­­­­­­­­­­­­­­
       Innodb_buffer_pool_pages_data      Total memory allocated 18415432;
     + Innodb_buffer_pool_pages_free      in additional pool allocated 859008
     + Innodb_buffer_pool_pages_misc      Dictionary memory allocated 20888
       ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­     Buffer pool size   512
     = Innodb_buffer_pool_pages_total     Free buffers       493
       ==============================     Database pages     19
                                          Modified db pages  0
     Innodb_buffer_pool_pages_flushed     Pending reads 0
     Innodb_buffer_pool_pages_latched     Pending writes: LRU 0,
                                          flush list 0,
     Innodb_buffer_pool_read_ahead_rnd    single page 0
     Innodb_buffer_pool_read_ahead_seq    Pages read 19,
                                          created 0,
     Innodb_buffer_pool_read_requests     written 0
     Innodb_buffer_pool_reads             0.32 reads/s,
     Innodb_buffer_pool_write_requests    0.00 creates/s,
                                          0.00 writes/s
     Innodb_buffer_pool_wait_free         Buffer pool hit rate 754 / 1000



Copyright 2007 MySQL AB                        The World’s Most Popular Open Source Database   15
Innodb_data%




      Innodb_data_fsyncs        
      Innodb_data_pending_fsyncs
      Innodb_data_pending_reads
      Innodb_data_pending_writes
                                                      ???
      Innodb_data_read
      Innodb_data_reads
      Innodb_data_writes
      Innodb_data_written




Copyright 2007 MySQL AB               The World’s Most Popular Open Source Database   16
Innodb_dblwr%




      Innodb_dblwr_pages_written
                                                      ???
      Innodb_dblwr_writes       




Copyright 2007 MySQL AB               The World’s Most Popular Open Source Database   17
Innodb_[os_]log%


                                     LOG
                                     ­­­
                                     Log sequence number 0 46409
                                     Log flushed up to   0 46409
                                     Last checkpoint at  0 46409
      Innodb_log_waits            
                                     0 pending log writes,
      Innodb_log_write_requests
                                     0 pending chkp writes
      Innodb_log_writes
                                     8 log i/o's done,
                                     0.14 log i/o's/second
      Innodb_os_log_fsyncs
      Innodb_os_log_pending_fsyncs
                                     Pending normal aio reads: 0,
      Innodb_os_log_pending_writes
                                     aio writes: 0,
      Innodb_os_log_written
                                     ibuf aio reads: 0,
                                     log i/o's: 0,
                                     sync i/o's: 0
                                     Pending flushes (fsync) log: 0;
                                     buffer pool: 0




Copyright 2007 MySQL AB                  The World’s Most Popular Open Source Database   18
Innodb_pages%




      Innodb_page_size             
      Innodb_pages_created
                                                      ???
      Innodb_pages_read
      Innodb_pages_written




Copyright 2007 MySQL AB               The World’s Most Popular Open Source Database   19
Innodb_row_lock%




      Innodb_row_lock_current_waits
      Innodb_row_lock_time_max

        Innodb_row_lock_time_avg                      ???
      * Innodb_row_lock_waits
        ­­­­­­­­­­­­­­­­­­­­­­­­
      = Innodb_row_lock_time




Copyright 2007 MySQL AB               The World’s Most Popular Open Source Database   20
Innodb_rows%



                                    ROW OPERATIONS
                                    ­­­­­­­­­­­­­­
                                    0 queries inside InnoDB,
                                    0 queries in queue
                                    1 read views open inside InnoDB
                                    Main thread process no. 7924,
      Innodb_rows_deleted           id 3004103568,
      Innodb_rows_inserted          state: waiting for server activity
      Innodb_rows_read              Number of rows inserted 0,
      Innodb_rows_updated           updated 0,
                                    deleted 0,
                                    read 0
                                    0.00 inserts/s,
                                    0.00 updates/s,
                                    0.00 deletes/s,
                                    0.00 reads/s




Copyright 2007 MySQL AB                  The World’s Most Popular Open Source Database   21
SEMAPHORES




                                      SEMAPHORES
                                      ­­­­­­­­­­
                                      OS WAIT ARRAY INFO:
                                      reservation count 2,
                                      signal count 2
                                      Mutex spin waits 0,
                          ???
                                      rounds 0,
                                      OS waits 0
                                      RW­shared spins 4,
                                      OS waits 2;
                                      RW­excl spins 1,
                                      OS waits 0




Copyright 2007 MySQL AB                   The World’s Most Popular Open Source Database   22
TRANSACTIONS


                                       TRANSACTIONS
                                       ­­­­­­­­­­­­
                                       Trx id counter 0 1280
                                       Purge done for trx's n:o < 0 0
                                       undo n:o < 0 0
                                       History list length 0
                                       Total number of lock structs
                                       in row lock hash table 0
                          ???
                                       LIST OF TRANSACTIONS
                                       FOR EACH SESSION:
                                       ­­­TRANSACTION 0 0, not started,
                                       process no 7924,
                                       OS thread id 3032894352
                                       MySQL thread id 2,
                                       query id 4 localhost root
                                       show engine innodb status




Copyright 2007 MySQL AB                    The World’s Most Popular Open Source Database   23
FILE I/O
                                     FILE I/O
                                     ­­­­­­­­
                                     I/O thread 0 state:
                                     waiting for i/o request
                                     (insert buffer thread)
                                     I/O thread 1 state:
                                     waiting for i/o request
                                     (log thread)
                                     I/O thread 2 state:
                                     waiting for i/o request
                                     (read thread)
                                     I/O thread 3 state:
                          ???        waiting for i/o request
                                     (write thread)

                                     Pending normal aio reads: 0,
                                     aio writes: 0,
                                     ibuf aio reads: 0, log i/o's: 0,
                                     sync i/o's: 0
                                     Pending flushes (fsync) log: 0;
                                     buffer pool: 0
                                     25 OS file reads, 3 OS file writes,
                                     3 OS fsyncs
                                     0.42 reads/s, 100433 avg bytes/read,
                                     0.05 writes/s, 0.05 fsyncs/s

Copyright 2007 MySQL AB                    The World’s Most Popular Open Source Database   24
INSERT BUFFER AND ADAPTIVE HASH INDEX



                                INSERT BUFFER AND
                                ADAPTIVE HASH INDEX
                                ­­­­­­­­­­­­­­­­­­­
                                Ibuf: size 1,
                                free list len 0,
                                seg size 2,
                                0 inserts,
                          ???   0 merged recs,
                                0 merges

                                Hash table size 34679,
                                used cells 0,
                                node heap has 0 buffer(s)
                                0.00 hash searches/s,
                                0.31 non­hash searches/s




Copyright 2007 MySQL AB             The World’s Most Popular Open Source Database   25
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 MySQL AB               The World’s Most Popular Open Source Database   26
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 MySQL AB                   The World’s Most Popular Open Source Database   27
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 MySQL AB              The World’s Most Popular Open Source Database   28
MySQL variables (discussion)

    • Customers have very often misconfigured my.cnf

    • My postulate: use the DEFAULT and adapt 3
      things:
          – key_buffer_size
          – innodb_buffer_pool_size
          – innodb_log_file_size


    • That's it! Other changes only after detailed tests!

    • What is you opinion?


Copyright 2007 MySQL AB               The World’s Most Popular Open Source Database   29
MyISAM log

    • There is a log for MyISAM!
          I did not know that! :-(
    • enable in my.cnf

            log­isam = myisam.log

    • cat myisam.log: :-(
            +�./mysql/host.MYI+�
            +�+�+�./mysql/user.MYI+�
            +�+�+�./mysql/db.MYI+�
            +�+�+�+�+�+�+�+�+�+�+�+�!./mysql/time_zone_leap_second.MYI+�
            +�+�+�▒./mysql/time_zone_name.MYI+�
            +�+�+�./mysql/time_zone.MYI+�
              +�%./mysql/time_zone_transition_type.MYI
            +� ./mysql/time_zone_transition.MYI+�
            +�+�+�+�+�+�+�./mysql/tables_priv.MYI+�
            +�+�+�▒./mysql/columns_priv.MYI+�


Copyright 2007 MySQL AB                                 The World’s Most Popular Open Source Database   30
MyISAM log

    • myisamlog myisam.log
            Commands   Used count    Errors   Recover errors
            open               15         0                0
            write               8         0                0
            update              1         0                0
            close               8         0                0
            extra              93         0                0
            Total             125         0                0



    • myisamlog -? --> help
    • myisamlog -vvv
    • myisamlog -i
            User time 0.00, System time 0.00
            Maximum resident set size 0, Integral resident set size 0
            Non­physical pagefaults 519, Physical pagefaults 0, Swaps 0
            Blocks in 0 out 0, Messages in 0 out 0, Signals 0
            Voluntary context switches 1, Involuntary context switches 8



Copyright 2007 MySQL AB                                  The World’s Most Popular Open Source Database   31
MySQL visual explain

    • http://mysqltoolkit.sourceforge.net/

            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              |
   +­­­­+­­­­­­­­+­­­­­+­­­­­­­­+­­­­­­­­­­+­­­­­­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+




Copyright 2007 MySQL AB                                           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 MySQL AB                        The World’s Most Popular Open Source Database   33

More Related Content

What's hot

Cache memory.12
Cache memory.12Cache memory.12
Cache memory.12
myrajendra
 
Memory technology and optimization in Advance Computer Architechture
Memory technology and optimization in Advance Computer ArchitechtureMemory technology and optimization in Advance Computer Architechture
Memory technology and optimization in Advance Computer Architechture
Shweta Ghate
 
Cache memory
Cache memoryCache memory
Cache memory
Anuj Modi
 
Virtual Memory vs Cache Memory
Virtual Memory vs Cache MemoryVirtual Memory vs Cache Memory
Virtual Memory vs Cache Memory
Ashik Iqbal
 
Computer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer ArchitectureComputer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer Architecture
Haris456
 
Project Presentation Final
Project Presentation FinalProject Presentation Final
Project Presentation Final
Dhritiman Halder
 

What's hot (20)

Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory.12
Cache memory.12Cache memory.12
Cache memory.12
 
Cache memory ...
Cache memory ...Cache memory ...
Cache memory ...
 
Memory technology and optimization in Advance Computer Architechture
Memory technology and optimization in Advance Computer ArchitechtureMemory technology and optimization in Advance Computer Architechture
Memory technology and optimization in Advance Computer Architechture
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache
CacheCache
Cache
 
Virtual Memory vs Cache Memory
Virtual Memory vs Cache MemoryVirtual Memory vs Cache Memory
Virtual Memory vs Cache Memory
 
Cache memory
Cache memory Cache memory
Cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cachememory
CachememoryCachememory
Cachememory
 
Cache memory and cache
Cache memory and cacheCache memory and cache
Cache memory and cache
 
Computer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer ArchitectureComputer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer Architecture
 
04 Cache Memory
04  Cache  Memory04  Cache  Memory
04 Cache Memory
 
Project Presentation Final
Project Presentation FinalProject Presentation Final
Project Presentation Final
 
Memory managment
Memory managmentMemory managment
Memory managment
 
Cache memory in Eng:Ahmed Ali Ahmed
Cache memory in Eng:Ahmed Ali AhmedCache memory in Eng:Ahmed Ali Ahmed
Cache memory in Eng:Ahmed Ali Ahmed
 
Hierarchical Memory System
Hierarchical Memory SystemHierarchical Memory System
Hierarchical Memory System
 
Linux Memory
Linux MemoryLinux Memory
Linux Memory
 
Cache Memory
Cache MemoryCache Memory
Cache Memory
 

Viewers also liked (7)

Vam: A Locality-Improving Dynamic Memory Allocator
Vam: A Locality-Improving Dynamic Memory AllocatorVam: A Locality-Improving Dynamic Memory Allocator
Vam: A Locality-Improving Dynamic Memory Allocator
 
Pipelining and ILP (Instruction Level Parallelism)
Pipelining and ILP (Instruction Level Parallelism) Pipelining and ILP (Instruction Level Parallelism)
Pipelining and ILP (Instruction Level Parallelism)
 
pipelining
pipeliningpipelining
pipelining
 
Instruction pipelining
Instruction pipeliningInstruction pipelining
Instruction pipelining
 
pipelining
pipeliningpipelining
pipelining
 
LinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-PresentedLinkedIn SlideShare: Knowledge, Well-Presented
LinkedIn SlideShare: Knowledge, Well-Presented
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 

Similar to Locality of (p)reference

The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQL
Morgan Tocker
 
InnoDB architecture and performance optimization (Пётр Зайцев)
InnoDB architecture and performance optimization (Пётр Зайцев)InnoDB architecture and performance optimization (Пётр Зайцев)
InnoDB architecture and performance optimization (Пётр Зайцев)
Ontico
 
Mysql Fulltext Search 1
Mysql Fulltext Search 1Mysql Fulltext Search 1
Mysql Fulltext Search 1
johnymas
 
001 hbase introduction
001 hbase introduction001 hbase introduction
001 hbase introduction
Scott Miao
 
ZFS for Databases
ZFS for DatabasesZFS for Databases
ZFS for Databases
ahl0003
 
Scalable and High available Distributed File System Metadata Service Using gR...
Scalable and High available Distributed File System Metadata Service Using gR...Scalable and High available Distributed File System Metadata Service Using gR...
Scalable and High available Distributed File System Metadata Service Using gR...
Alluxio, Inc.
 

Similar to Locality of (p)reference (20)

The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQL
 
Some key value stores using log-structure
Some key value stores using log-structureSome key value stores using log-structure
Some key value stores using log-structure
 
NoSQL with MySQL
NoSQL with MySQLNoSQL with MySQL
NoSQL with MySQL
 
InnoDB architecture and performance optimization (Пётр Зайцев)
InnoDB architecture and performance optimization (Пётр Зайцев)InnoDB architecture and performance optimization (Пётр Зайцев)
InnoDB architecture and performance optimization (Пётр Зайцев)
 
Running MySQL on Linux
Running MySQL on LinuxRunning MySQL on Linux
Running MySQL on Linux
 
Introduction to TokuDB v7.5 and Read Free Replication
Introduction to TokuDB v7.5 and Read Free ReplicationIntroduction to TokuDB v7.5 and Read Free Replication
Introduction to TokuDB v7.5 and Read Free Replication
 
Ceph
CephCeph
Ceph
 
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
 
MyRocks introduction and production deployment
MyRocks introduction and production deploymentMyRocks introduction and production deployment
MyRocks introduction and production deployment
 
Scale your Alfresco Solutions
Scale your Alfresco Solutions Scale your Alfresco Solutions
Scale your Alfresco Solutions
 
CLFS 2010
CLFS 2010CLFS 2010
CLFS 2010
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at night
 
PhegData X - High Performance EBS
PhegData X - High Performance EBSPhegData X - High Performance EBS
PhegData X - High Performance EBS
 
Exploiting Your File System to Build Robust & Efficient Workflows
Exploiting Your File System to Build Robust & Efficient WorkflowsExploiting Your File System to Build Robust & Efficient Workflows
Exploiting Your File System to Build Robust & Efficient Workflows
 
Why MariaDB?
Why MariaDB?Why MariaDB?
Why MariaDB?
 
Mysql Fulltext Search 1
Mysql Fulltext Search 1Mysql Fulltext Search 1
Mysql Fulltext Search 1
 
001 hbase introduction
001 hbase introduction001 hbase introduction
001 hbase introduction
 
ZFS for Databases
ZFS for DatabasesZFS for Databases
ZFS for Databases
 
Scalable and High available Distributed File System Metadata Service Using gR...
Scalable and High available Distributed File System Metadata Service Using gR...Scalable and High available Distributed File System Metadata Service Using gR...
Scalable and High available Distributed File System Metadata Service Using gR...
 
Severalnines Training: MySQL® Cluster - Part IX
Severalnines Training: MySQL® Cluster - Part IXSeveralnines Training: MySQL® Cluster - Part IX
Severalnines Training: MySQL® Cluster - Part IX
 

More from FromDual GmbH

More from 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 Performance Tuning für Entwickler
MySQL Performance Tuning für EntwicklerMySQL Performance Tuning für Entwickler
MySQL Performance Tuning für Entwickler
 
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
 

Recently uploaded

Recently uploaded (20)

Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
THE BEST IPTV in GERMANY for 2024: IPTVreel
THE BEST IPTV in  GERMANY for 2024: IPTVreelTHE BEST IPTV in  GERMANY for 2024: IPTVreel
THE BEST IPTV in GERMANY for 2024: IPTVreel
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, Ocado
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 

Locality of (p)reference

  • 1. Locality of (p)reference Some thoughts about MySQL consulting issues Oli Sennhauser Senior Consultant osennhauser@mysql.com Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 1
  • 2. ToC • Locality of (p)reference • commit_demo.pl (performance test/numbers) • InnoDB information (discussion) • RAM disk • MySQL variables (discussion) • MyISAM log • MySQL Visual Explain Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 2
  • 3. Locality of (p)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 MySQL AB The World’s Most Popular Open Source Database 3
  • 4. 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 MySQL AB The World’s Most Popular Open Source Database 4
  • 5. 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 MySQL AB The World’s Most Popular Open Source Database 5
  • 6. 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 MySQL AB The World’s Most Popular Open Source Database 6
  • 7. Locality of Reference • Block size is 16k/4k • PK is AUTO_INCREMENT • Synthecial PK are sometimes dangerous! Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 7
  • 8. 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 MySQL AB The World’s Most Popular Open Source Database 8
  • 9. commit_demo.pl • Little ugly script to test your I/O system: http://www.shinguz.ch/MySQL/consulting_tools.html • What it does: INSERT -> COMMIT -> INSERT -> COMMIT -> ... • The idea behind it • How to call: ./commit_demo.pl ­u root ­c ./commit_demo.pl ­u root ­i <n> ./commit_demo.pl ­u root ­c • Does NOT work with 6.0 :-( • Lit: http://www.shinguz.ch/MySQL/transaction_performance.pdf Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 9
  • 10. commit_demo.pl 40 35 30 run time [s] 25 normal 20 bin_log sync_binlog MyISAM 15 Backup Theory 10 5 0 1 2 4 8 16 32 64 128 256 INSERT/COMMIT Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 10
  • 11. commit_demo.pl Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 11
  • 12. commit_demo.pl Time trx trx theorie Comment [s] [ms/trx] [trx/s] [ms/trx] 12.3 1.2 833 8.3 Laptop, with good disk cache 27.2 2.7 370 2.5 SAN with up to 2000 I/O per second 41.0 4.1 244 4.0 Baseline for the following test 42.2 4.2 238 4.0 With DRBD, 2.5% slower 157.0 15.7 64 4.0 with XFS, badly configured? 86.4 8.6 116 8.0 With binary logging 565.0 56.5 18 8.0 sync_binlog=1!!! Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 12
  • 13. InnoDB information (discussion) • SHOW GLOBAL STATUS LIKE 'InnoDB%'; • SHOW ENGINE INNODB STATUSG • OK. But what does it mean to me? • Let's start with a rough architecture picture: Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 13
  • 14. InnoDB architecture mysqld secondary index buffer data pages index pages adaptive hash idx undo records buffer pool • SHOW STATUS; lock info table trx log buffer Innodb_buffer_pool_% Innodb_data_% Innodb_dblwr_% Innodb_log_% Innodb_os_log_% Innodb_pages_% Innodb_row_lock_% async OS file cache sync Innodb_rows_% • SHOW INNODB STATUS; system table space: ibdata1 ib_logfile1 undo SEMAPHORES double write area dd TRANSACTIONS ib_logfile2 FILE I/O INSERT BUFFER AND tables/indexes   ADAPTIVE HASH INDEX ib_logfilen LOG BUFFER POOL AND MEMORY table table space table table space table table space ROW OPERATIONS Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 14
  • 15. Innodb_buffer_pool%     Innodb_buffer_pool_pages_dirty ­­­­­­­­­­­­­­­­­­­­­­   + Innodb_buffer_pool_pages_clean BUFFER POOL AND MEMORY   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ ­­­­­­­­­­­­­­­­­­­­­­   Innodb_buffer_pool_pages_data Total memory allocated 18415432; + Innodb_buffer_pool_pages_free in additional pool allocated 859008 + Innodb_buffer_pool_pages_misc Dictionary memory allocated 20888   ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ Buffer pool size   512 = Innodb_buffer_pool_pages_total Free buffers       493   ============================== Database pages     19 Modified db pages  0 Innodb_buffer_pool_pages_flushed Pending reads 0 Innodb_buffer_pool_pages_latched Pending writes: LRU 0, flush list 0, Innodb_buffer_pool_read_ahead_rnd single page 0 Innodb_buffer_pool_read_ahead_seq Pages read 19, created 0, Innodb_buffer_pool_read_requests written 0 Innodb_buffer_pool_reads 0.32 reads/s, Innodb_buffer_pool_write_requests 0.00 creates/s, 0.00 writes/s Innodb_buffer_pool_wait_free Buffer pool hit rate 754 / 1000 Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 15
  • 16. Innodb_data% Innodb_data_fsyncs         Innodb_data_pending_fsyncs Innodb_data_pending_reads Innodb_data_pending_writes ??? Innodb_data_read Innodb_data_reads Innodb_data_writes Innodb_data_written Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 16
  • 17. Innodb_dblwr% Innodb_dblwr_pages_written ??? Innodb_dblwr_writes        Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 17
  • 18. Innodb_[os_]log% LOG ­­­ Log sequence number 0 46409 Log flushed up to   0 46409 Last checkpoint at  0 46409 Innodb_log_waits             0 pending log writes, Innodb_log_write_requests 0 pending chkp writes Innodb_log_writes 8 log i/o's done, 0.14 log i/o's/second Innodb_os_log_fsyncs Innodb_os_log_pending_fsyncs Pending normal aio reads: 0, Innodb_os_log_pending_writes aio writes: 0, Innodb_os_log_written ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0 Pending flushes (fsync) log: 0; buffer pool: 0 Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 18
  • 19. Innodb_pages% Innodb_page_size              Innodb_pages_created ??? Innodb_pages_read Innodb_pages_written Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 19
  • 20. Innodb_row_lock% Innodb_row_lock_current_waits Innodb_row_lock_time_max   Innodb_row_lock_time_avg ??? * Innodb_row_lock_waits   ­­­­­­­­­­­­­­­­­­­­­­­­ = Innodb_row_lock_time Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 20
  • 21. Innodb_rows% ROW OPERATIONS ­­­­­­­­­­­­­­ 0 queries inside InnoDB, 0 queries in queue 1 read views open inside InnoDB Main thread process no. 7924, Innodb_rows_deleted id 3004103568, Innodb_rows_inserted state: waiting for server activity Innodb_rows_read Number of rows inserted 0, Innodb_rows_updated updated 0, deleted 0, read 0 0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 21
  • 22. SEMAPHORES SEMAPHORES ­­­­­­­­­­ OS WAIT ARRAY INFO: reservation count 2, signal count 2 Mutex spin waits 0, ??? rounds 0, OS waits 0 RW­shared spins 4, OS waits 2; RW­excl spins 1, OS waits 0 Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 22
  • 23. TRANSACTIONS TRANSACTIONS ­­­­­­­­­­­­ Trx id counter 0 1280 Purge done for trx's n:o < 0 0 undo n:o < 0 0 History list length 0 Total number of lock structs in row lock hash table 0 ??? LIST OF TRANSACTIONS FOR EACH SESSION: ­­­TRANSACTION 0 0, not started, process no 7924, OS thread id 3032894352 MySQL thread id 2, query id 4 localhost root show engine innodb status Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 23
  • 24. FILE I/O FILE I/O ­­­­­­­­ I/O thread 0 state: waiting for i/o request (insert buffer thread) I/O thread 1 state: waiting for i/o request (log thread) I/O thread 2 state: waiting for i/o request (read thread) I/O thread 3 state: ??? waiting for i/o request (write thread) Pending normal aio reads: 0, aio writes: 0, ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0 Pending flushes (fsync) log: 0; buffer pool: 0 25 OS file reads, 3 OS file writes, 3 OS fsyncs 0.42 reads/s, 100433 avg bytes/read, 0.05 writes/s, 0.05 fsyncs/s Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 24
  • 25. INSERT BUFFER AND ADAPTIVE HASH INDEX INSERT BUFFER AND ADAPTIVE HASH INDEX ­­­­­­­­­­­­­­­­­­­ Ibuf: size 1, free list len 0, seg size 2, 0 inserts, ??? 0 merged recs, 0 merges Hash table size 34679, used cells 0, node heap has 0 buffer(s) 0.00 hash searches/s, 0.31 non­hash searches/s Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 25
  • 26. 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 MySQL AB The World’s Most Popular Open Source Database 26
  • 27. 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 MySQL AB The World’s Most Popular Open Source Database 27
  • 28. 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 MySQL AB The World’s Most Popular Open Source Database 28
  • 29. MySQL variables (discussion) • Customers have very often misconfigured my.cnf • My postulate: use the DEFAULT and adapt 3 things: – key_buffer_size – innodb_buffer_pool_size – innodb_log_file_size • That's it! Other changes only after detailed tests! • What is you opinion? Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 29
  • 30. MyISAM log • There is a log for MyISAM! I did not know that! :-( • enable in my.cnf log­isam = myisam.log • cat myisam.log: :-( +�./mysql/host.MYI+� +�+�+�./mysql/user.MYI+� +�+�+�./mysql/db.MYI+� +�+�+�+�+�+�+�+�+�+�+�+�!./mysql/time_zone_leap_second.MYI+� +�+�+�▒./mysql/time_zone_name.MYI+� +�+�+�./mysql/time_zone.MYI+�   +�%./mysql/time_zone_transition_type.MYI +� ./mysql/time_zone_transition.MYI+� +�+�+�+�+�+�+�./mysql/tables_priv.MYI+� +�+�+�▒./mysql/columns_priv.MYI+� Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 30
  • 31. MyISAM log • myisamlog myisam.log Commands   Used count    Errors   Recover errors open               15         0                0 write               8         0                0 update              1         0                0 close               8         0                0 extra              93         0                0 Total             125         0                0 • myisamlog -? --> help • myisamlog -vvv • myisamlog -i User time 0.00, System time 0.00 Maximum resident set size 0, Integral resident set size 0 Non­physical pagefaults 519, Physical pagefaults 0, Swaps 0 Blocks in 0 out 0, Messages in 0 out 0, Signals 0 Voluntary context switches 1, Involuntary context switches 8 Copyright 2007 MySQL AB The World’s Most Popular Open Source Database 31
  • 32. MySQL visual explain • http://mysqltoolkit.sourceforge.net/ 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              | +­­­­+­­­­­­­­+­­­­­+­­­­­­­­+­­­­­­­­­­+­­­­­­­­­+­­­­­­­+­­­­­­­­­­­+­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+ Copyright 2007 MySQL AB 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 MySQL AB The World’s Most Popular Open Source Database 33