MySQL 5.1 and beyond
Upcoming SlideShare
Loading in...5
×
 

MySQL 5.1 and beyond

on

  • 6,543 views

MySQL 5.1 adds new features and more performance. And MySQL 5.4 is even faster. Some theory and practical tests

MySQL 5.1 adds new features and more performance. And MySQL 5.4 is even faster. Some theory and practical tests

Statistics

Views

Total Views
6,543
Views on SlideShare
6,488
Embed Views
55

Actions

Likes
1
Downloads
105
Comments
0

3 Embeds 55

http://www.wordcamp.it 32
http://wordcamp.it 12
http://www.slideshare.net 11

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

MySQL 5.1 and beyond Presentation Transcript

  • 1. MySQL 5.1 (and more) What's new Giuseppe Maxia MySQL Community Team Lead
  • 2. about me -Giuseppe Maxia  a.k.a. The Data Charmer  MySQL Community Team Lead  Long time hacking with MySQL features  Formerly, database consultant, designer, coder.  A passion for QA  An even greater passion for open source  ... and community  Passionate blogger  http://datacharmer.blogspot.com
  • 3. MySQL 5.1 GA
  • 4. MySQL 5.1 GA
  • 5. MySQL 5.1 GA
  • 6. MySQL 5.1 features Partitions performance row-based replication stability event scheduler ease of use logs on demand ease of use plugin interface extensibility GENERAL PERFORMANCE performance
  • 7. What exactly is this quot;partitionsquot; thing?  Logical splitting of tables  Transparent to user
  • 8. Remember the MERGE tables? MERGE TABLE  separate tables  risk of duplicates  insert in each table  no constraints
  • 9. It isn't a merge table! PARTITIONED TABLE  One table  No risk of duplicates  insert in one table  constraints enforced
  • 10. Partition pruning 1a - unpartitioned table - SINGLE RECORD select * from table_name where colx = 120
  • 11. Partition pruning 1b - unpartitioned table - SINGLE RECORD select * from table_name where colx = 350
  • 12. Partition pruning 1c - unpartitioned table - RANGE select * from table_name where colx between 120 and 230
  • 13. Partition pruning 2a - table partitioned by colx - SINGLE REC 1-99 100-199 select * from 200-299 table_name where colx = 300-399 120 400-499 500-599
  • 14. Partition pruning 2b - table partitioned by colx - SINGLE REC 1-99 100-199 select * from 200-299 table_name where colx = 300-399 350 400-499 500-599
  • 15. Partition pruning 2c - table partitioned by colx - RANGE 1-99 select * 100-199 from table_name 200-299 where colx 300-399 between 120 and 230 400-499 500-599
  • 16. Partition pruning EXPLAIN select * before from table_name where colx = 120 EXPLAIN PARTITIONS in 5.1 select * from table_name where colx = 120
  • 17. Partition pruning - unpartitioned table explain partitions select count(*) from table_name where colx=120G ***** 1. row **** id: 1 select_type: SIMPLE table: table_name partitions: p01,p02,p03,p04,p05,p06,p07,p08,p09 ,p10,p11,p12,p13,p14,p15,p16,p17,p1 8,p19 type: index ...
  • 18. Partition pruning - unpartitioned table explain partitions select count(*) from table_name where colx between 120 and 230G ***** 1. row **** id: 1 select_type: SIMPLE table: table_name partitions: p01,p02,p03,p04,p05,p06,p07,p08,p09 ,p10,p11,p12,p13,p14,p15,p16,p17,p1 8,p19 type: index ...
  • 19. Partition pruning - table partitioned by colx explain partitions select count(*) from table_name where colx between 120 and 230G ***** 1. row **** id: 1 select_type: SIMPLE table: table_name partitions: p02,p03 type: index ...
  • 20. HOW TO MAKE PARTITIONS
  • 21. HOW TO MAKE PARTITIONS RTFM ...
  • 22. HOW TO MAKE PARTITIONS RTFM ...  No, seriously, the manual has everything
  • 23. HOW TO MAKE PARTITIONS RTFM ...  No, seriously, the manual has everything  But if you absolutely insist ...
  • 24. HOW TO MAKE PARTITIONS CREATE TABLE t1 ( id int ) ENGINE=InnoDB # or MyISAM, ARCHIVE PARTITION BY RANGE (id) ( PARTITION P1 VALUES LESS THAN (10), PARTITION P2 VALUES LESS THAN (20) ) 20
  • 25. HOW TO MAKE PARTITIONS CREATE TABLE t1 ( id int ) ENGINE=InnoDB PARTITION BY LIST (id) ( PARTITION P1 VALUES IN (1,2,4), PARTITION P2 VALUES IN (3,5,9) ) 21
  • 26. HOW TO MAKE PARTITIONS CREATE TABLE t1 ( id int not null primary key ) ENGINE=InnoDB PARTITION BY HASH (id) PARTITIONS 10; 22
  • 27. HOW TO MAKE PARTITIONS CREATE TABLE t1 ( id int not null primary key ) ENGINE=InnoDB PARTITION BY KEY () PARTITIONS 10; 23
  • 28. Limitations • Can partition only by INTEGER columns • OR you can partition by an expression, which must return an integer • Maximum 1024 partitions • If you have a Unique Key or PK, the partition column must be part of that key • No Foreign Key support • No Fulltext or GIS support 24
  • 29. Benchmarking partitions  Compare results  Unpartitioned vs partitioned  ISOLATION  Repeatability  Check your resources!
  • 30. Partitions with InnoDB (laptop)  Key points:  Takes much more storage than other engines engine storage (MB) innodb 221 myisam 181 archive 74 innodb partitioned (whole) 289 innodb partitioned (file per table) 676 myisam partitioned 182 archive partitioned 72
  • 31. Benchmarking results (laptop) engine query year query year 2000 2002 InnoDB 1.25 1.25 MyISAM 1.72 1.73 Archive 2.47 2.45 InnoDB partitioned 0.24 0.10 whole InnoDB Partitioned 0.45 0.10 (file per table) MyISAM partitioned 0.18 0.12 Archive partitioned 0.22 0.12
  • 32. Partitions with InnoDB (huge server)  Key points:  Takes much more storage than other engines engine storage (GB) innodb (with PK) 330 myisam (with PK) 141 archive 13 innodb partitioned (no PK) 237 myisam partitioned (no PK) 107 archive partitioned 13
  • 33. Benchmarking results (huge server) engine 6 month range InnoDB 4 min 30s MyISAM 25.03s Archive 22 min 25s InnoDB partitioned by month 13.19 MyISAM partitioned by year 6.31 MyISAM partitioned by month 4.45 Archive partitioned by year 16.67 Archive partitioned by month 8.97
  • 34. What is the event scheduler  Temporal triggers  NOT related to a specific table  Execute SQL code  at a given time  or at given intervals  Created by Andrey Hristov  First released with MySQL 5.1
  • 35. How does it work? event scheduler thread MySQL Server event time? start regular thread regular thread regular thread regular thread regular thread event thread
  • 36. Why using the event scheduler?  Cross platform scheduler  No external applications needed  No overhead
  • 37. How to use the event scheduler 1. Enable the event scheduler A. in the option file • event-scheduler=1 B. online • SET GLOBAL event_scheduler=ON; 2. Create an event 3. Check the effects
  • 38. Event creation syntax CREATE EVENT event_name ON SCHEDULE AT {DATE AND TIME} DO {SQL COMMAND}; CREATE EVENT event_name ON SCHEDULE EVERY {X} {SECOND|MINUTE|HOUR|DAY|MONTH|YEAR|WEEK} DO {SQL COMMAND};
  • 39. Event creation syntax CREATE EVENT event_name ON SCHEDULE {schedule clause} [ON COMPLETION [NOT] PRESERVE] [STARTS {DATE TIME}] [ENDS {DATE TIME} ] [ENABLE|DISABLE] DO {SQL COMMAND};
  • 40. Creating an event at a given time CREATE EVENT event_name ON SCHEDULE AT '2009-04-21 15:55:00' DO INSERT INTO some_table VALUES ('gotcha', now()); CREATE EVENT event_name ON SCHEDULE AT now() + interval 20 minute DO CALL smart_procedure()
  • 41. Creating a recurring event CREATE EVENT event_name ON SCHEDULE EVERY 20 MINUTE DO INSERT INTO some_table VALUES ('gotcha', now()); CREATE EVENT event_name ON SCHEDULE every 7 DAY DO CALL smart_procedure()
  • 42. Creating a recurring event CREATE EVENT event_name ON SCHEDULE EVERY 10 MINUTE STARTS NOW() + INTERVAL 2 HOUR ENDS NOW() + INTERVAL 4 HOUR DO CALL some_procedure(); # creates an event that runs every # 10 minutes, but does not start now. # It will start in 2 hours # and end two hours later
  • 43. MySQL 5.1 and 5.4 in practice Giuseppe Maxia MySQL Community Team Lead
  • 44. 5.4 ? This release is very special for two reasons
  • 45. Tight team work MySQL architects, top MySQL coders, Sun 1 performance engineers, all worked together to create this release
  • 46. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 47. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 48. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 49. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 50. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 51. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 52. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 53. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 54. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 55. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 56. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 57. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 58. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 59. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 60. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 61. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 62. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 63. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 64. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 65. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 66. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 67. How to improve performance method efficacy difficulty Schema optimization ***** ##### Server tuning ** #### 2 Query tuning *** #### Hardware upgrade *** # Replication ** ##### Partitioning ***** ##### Server Upgrade (5.4) ***** #
  • 68. 5.4 = 5.1 + performance patches
  • 69. Practical experience
  • 70. sysbench prepare time sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=msandbox --mysql-password=msandbox --mysql-host=127.0.0.1 --mysql-port=$PORT --num-threads=8 prepare
  • 71. sysbench r/o sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=msandbox --mysql-password=msandbox --mysql-host=127.0.0.1 --mysql-port=$PORT --max-time=60 --oltp-read-only=on --max-requests=0 --num-threads=8 run
  • 72. sysbench r/w sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=msandbox --mysql-password=msandbox --mysql-host=127.0.0.1 --mysql-port=$PORT --max-time=60 --oltp-read-only=off --max-requests=0 --num-threads=8 run
  • 73. sysbench results MySQL 5.0 read-only
  • 74. sysbench results MySQL 5.1 read-only
  • 75. sysbench results MySQL 5.0 R/W
  • 76. sysbench results MySQL 5.1 R/W
  • 77. sysbench results MySQL 5.4 R/O
  • 78. sysbench results MySQL 5.4 R/W
  • 79. sysbench results graph MySQL 5.0 read-only
  • 80. sysbench results graph MySQL 5.1 R/O
  • 81. sysbench results graph - read only 5.0 5.1
  • 82. sysbench results graph MySQL 5.0 R/W
  • 83. sysbench results graph MySQL 5.1 R/W
  • 84. sysbench results graph - R/W 5.0 5.1
  • 85. sysbench results graph MySQL 5.4 R/O
  • 86. sysbench results graph - read only 5.0 5.1/5.4
  • 87. sysbench results graph - read only
  • 88. sysbench results graph MySQL 5.4 R/W
  • 89. sysbench results graph - R/W 5.0 5.1/5.4
  • 90. sysbench results graph - R/W
  • 91. THANKS QUESTIONS? Slides in my blog http://datacharmer.blogspot.com