SlideShare a Scribd company logo
1 of 89
Download to read offline
Boost performance
with
MySQL 5.1 partitions

March 19, 2009
Giuseppe Maxia
MySQL Community Team Lead
Sun Microsystems
Who's this guy?




about me
                  2
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




               5
Defining the problem




   YOUR
   NEEDS               6
The problem(s)
    Too much data
•
    Not enough RAM
•
    Historical data
•
    Growing data
•
    Rotating data
•




                      7
Too much data




         data




                8
Not enough RAM



                       RAM


                       INDEXES
             INDEXES
      data




                                 9
Not enough RAM




                       INDEXES
                       RAM
             INDEXES
      data




                                 10
MySQL 5.1 partitions




     WHAT
                       11
What is it?
• Logical splitting of tables
• Transparent to user




                                12
Logical splitting
• No need to create separate tables
• No need to move chunks of data across files




                                                13
MySQL 5.1 partitions




          SQL
 TRANSPARENT
                       14
COMPARED TO MERGE TABLES
                     separate tables
                 •
   MERGE TABLE
                     risk of duplicates
                 •
                     insert in each table
                 •
                     no constraints
                 •




                                      15
COMPARED TO MERGE TABLES
                        One table
                    •
PARTITIONED TABLE
                        No risk of duplicates
                    •
                        insert in one table
                    •
                        constraints enforced
                    •




                                        16
Wait a minute ...
• WHAT THE HELL DOES quot;LOGICAL SPLITquot;
  REALLY MEANS?
• LET ME EXPLAIN ...




                                       17
Physical partitioning (1)
• Take a map




                            18
Physical partitioning (2)
• cut it into pieces




                            19
Physical partitioning (3)
• What you have, is several different pieces




                                               20
Physical partitioning (4)
• If you want the map back, you need some
  application (adhesive tape) and you may get it
  wrong




                                               21
Logical partitioning (1)
• Take a map




                           22
Logical partitioning (2)
• fold it to show the piece you need




                                       23
Logical partitioning (3)
• what you have is still a map, even if you see only
  one part.




                                                24
Logical partitioning (4)
• if you unfold the map, you still have the whole thing




                                                 25
What partitions can do
    logical split
•
    but you can also split the data physically
•
    granular partition (subpartitioning)
•
    different methods (range, list, hash, key)
•




                                                 26
MySQL 5.1 partitions




        WHY
                       27
4 main reasons to use partitions
    To make single inserts and selects faster
•
    To make range selects faster
•
    To help split the data across different paths
•
    To store historical data efficiently
•
    If you need to delete large chunks of data
•
    INSTANTLY



                                                    28
MySQL 5.1 partitions




       HOW
                       29
HOW TO MAKE PARTITIONS




                         30
HOW TO MAKE PARTITIONS

•RTFM ...



                         30
HOW TO MAKE PARTITIONS

•RTFM ...
• No, seriously, the manual has everything




                                             30
HOW TO MAKE PARTITIONS

•RTFM ...
• No, seriously, the manual has everything
• But if you absolutely insist ...




                                             30
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)
)                              31
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)
)
                               32
HOW TO MAKE PARTITIONS
CREATE TABLE t1 (
  id int not null primary key
) ENGINE=InnoDB
PARTITION BY HASH (id)
PARTITIONS 10;




                                33
HOW TO MAKE PARTITIONS
CREATE TABLE t1 (
  id int not null primary key
) ENGINE=InnoDB
PARTITION BY KEY ()
PARTITIONS 10;




                                34
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
                                                  35
PARTITIONING BY DATE
CREATE TABLE t1 (
  d date
) ENGINE=InnoDB
PARTITION BY RANGE (year(d))
(
  PARTITION P1 VALUES
     LESS THAN (1999),
  PARTITION P2 VALUES
    LESS THAN (2000)           36

)
PARTITIONING BY DATE
CREATE TABLE t1 (
  d date
) ENGINE=InnoDB
PARTITION BY RANGE (to_days(d))
(
  PARTITION P1 VALUES
   LESS THAN (to_days('1999-01-01')),
  PARTITION P2 VALUES
  LESS THAN (to_days('2000-01-01'))
                               37

)
MySQL 5.1 partitions




     WHEN
                       38
When to use partitions?
• if you have large tables
• if you know that you will always query for the
  partitioning column
• if you have historical tables that you want to purge
  quickly
• if your indexes are larger than the available RAM




                                                 39
MySQL 5.1 partitions




   HANDS
    ON                 40
components used for testing




                              41
components used for testing
• MySQL Sandbox
 > created MySQL instances in seconds
 > http://launchpad.net/mysql-sandbox




                                        41
components used for testing
• MySQL Sandbox
  > created MySQL instances in seconds
  > http://launchpad.net/mysql-sandbox

• MySQL Employees Test Database
  > has ~ 4 mil records in 6 tables
  > http://launchpad.net/test-db




                                         41
components used for testing
• MySQL Sandbox
  > created MySQL instances in seconds
  > http://launchpad.net/mysql-sandbox

• MySQL Employees Test Database
  > has ~ 4 mil records in 6 tables
  > http://launchpad.net/test-db

• Command line ability
  > fingers
  > ingenuity
                                         41
employees test database




                          42
How many partitions
from information_schema.partitions
+-------+-----------------+----------+
| pname | expr            | descr    |
+-------+-----------------+----------+
| p01   | year(from_date) | 1985     |
| p02   | year(from_date) | 1986     |

...
| p13   | year(from_date) | 1997     |
| p14   | year(from_date) | 1998     |
| p15   | year(from_date) | 1999     |
| p16   | year(from_date) | 2000     |
  ...
| p19   | year(from_date) | MAXVALUE |
+-------+-----------------+----------+   43
How many records
select count(*) from salaries;
 +----------+
 | count(*) |
 +----------+
 | 2844047 |
 +----------+
1 row in set (0.01 sec)



                             44
How many records in 1998
not partitioned
select count(*) from salaries
where from_date between
'1998-01-01' and '1998-12-31';
+----------+
| count(*) |
+----------+
|   247489 |
+----------+
1 row in set (1.52 sec)

# NOT PARTITIONED            45
How many records in 1998
PARTITIONED
select count(*) from salaries
where from_date between
'1998-01-01' and '1998-12-31';
+----------+
| count(*) |
+----------+
|   247489 |
+----------+
1 row in set (0.41 sec)

# partition p15
                             46
How many records in 1999
not partitioned
select count(*) from salaries
where from_date between
'1999-01-01' and '1999-12-31';
+----------+
| count(*) |
+----------+
|   260957 |
+----------+
1 row in set (1.54 sec)

# NOT PARTITIONED
                             47
How many records in 1999
PARTITIONED
select count(*) from salaries
where from_date between
'1999-01-01' and '1999-12-31';
+----------+
| count(*) |
+----------+
|   260957 |
+----------+
1 row in set (0.17 sec)

# partition p16
                             48
Deleting 1998 records
not partitioned
delete from salaries where
from_date between '1998-01-01'
and '1998-12-31';
Query OK, 247489 rows affected
(19.13 sec)



# NOT PARTITIONED

                             49
Deleting 1998 records
partitioned
alter table salaries drop
partition p15;
Query OK, 0 rows affected (1.35
sec)




                             50
MySQL 5.1 partitions




 LEVERAGING
 REPLICATION
                       51
Replication schemes
                     INNODB                   INNODB
                     NOT                      NOT
   MASTER            PARTITIONED              PARTITIONED

                                                             SLAVE
 concurrent insert
                                                       concurrent read

           INNODB                   MyISAM
           PARTITIONED              PARTITIONED
           BY RANGE                 BY RANGE
SLAVE                                             SLAVE
                                                            52
concurrent batch processing        large batch processing
Replication schemes
                              concurrent insert
                INNODB
                PARTITIONED
 MASTER


                                        INNODB
                                        NON
                                        PARTITIONED
            MyISAM
            PARTITIONED
 SLAVE                                               SLAVE
                                                     53
  batch processing                       concurrent reads
MySQL 5.1 partitions




PITFALLS
                       54
Expressions
• Partition by function
• Search by column




                          55
WRONG
PARTITION BY RANGE(year(from_date))

select count(*) from salaries where
year(from_date) = 1998;
+----------+
| count(*) |
+----------+
|   247489 |
+----------+
1 row in set (2.25 sec)
                             56
RIGHT
PARTITION BY RANGE(year(from_date))

select count(*) from salaries where
from_date between '1998-01-01' and
'1998-12-31';
+----------+
| count(*) |
+----------+
|   247489 |
+----------+
1 row in set (0.46 sec)
                             57
EXPLAIN
explain partitions select count(*)
from salaries where year(from_date)
= 1998G
***** 1. row ****
            id: 1
  select_type: SIMPLE
         table: salaries
   partitions:
p01,p02,p03,p04,p05,p06,p07,p08,p09
,p10,p11,p12,p13,p14,p15,p16,p17,p1
8,p19
          type: index        58

...
EXPLAIN
explain partitions select count(*)
from salaries where from_date
between '1998-01-01' and
'1998-12-31'G
***** 1. row ****
           id: 1
  select_type: SIMPLE
        table: salaries
   partitions: p14,p15
...

                             59
MySQL 5.1 partitions




   BENCHMARKS

                       60
Partitions benchmarks (laptop)


 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
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
Partitioning storage (huge server)


 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
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
MySQL 5.1 partitions




   TOOLS
                       65
The partition helper
• The INFORMATION_SCHEMA.PARTITIONS table
• The partition helper
  > http://datacharmer.blogspot.com/2008/12/partition-
    helper-improving-usability.html
  > A Perl script that creates partitioning statements


• ... anything you are creating right now :)



                                                         66
MySQL 5.1 partitions




        TIPS
                       67
TIPS
• For large table ( indexes > available RAM)
  > DO NOT USE INDEXES
  > PARTITIONS ARE MORE EFFICIENT




                                               68
TIPS
• Before adopting partitions in production, benchmark!
• you can create partitions of different sizes
  > in historical tables, you can partition
     – current data by day
     – recent data by month
     – distant past data by year
  > ALL IN THE SAME TABLE!
• If you want to enforce a constraint on a integer
  column, you may set a partition by list, with only the
  values you want to admit.
                                                 69
TIPS
• For large historical tables, consider using ARCHIVE
  + partitions
  > You see benefits for very large amounts of data ( > 500
    MB)
  > Very effective when you run statistics
  > Almost the same performance of MyISAM
  > but 1/10 of storage




                                                     70
Thank you!



Giuseppe Maxia
http://datacharmer@blogspot.com
datacharmer@sun.com
MySQL 5.1 partitions




        BONUS
        SLIDES
                       72
MySQL 5.1 partitions




ANNOYANCES
                       73
Annoyances with partitions
• CREATE TABLE STATEMENT hard to read




                                        74
Annoyances with partitions
• CREATE TABLE STATEMENT hard to read




                                        74
Annoyances with partitions
• hard to read (FIXED!! in 5.1.31)




                                     75
Annoyances with partitions
• hard to read (FIXED!! in 5.1.31)




                                     75
Annoyances with partitions
• CREATE TABLE only keeps the result of the
  expression for each partition.
• (you can use the information_schema to ease the
  pain in this case)




                                             76
Annoyances with partitions
CREATE TABLE t1 (
  d date
) ENGINE=InnoDB
PARTITION BY RANGE (to_days(d))
(
  PARTITION P1 VALUES
   LESS THAN (to_days('1999-01-01')),
  PARTITION P2 VALUES
  LESS THAN (to_days('2000-01-01'))
                               77

)
Annoyances with partitions
CREATE TABLE `t1` (
  `d` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT
CHARSET=latin1
/*!50100 PARTITION BY RANGE
(to_days(d))
(PARTITION P1 VALUES LESS THAN
(730120) ENGINE = InnoDB,
 PARTITION P2 VALUES LESS THAN
(730485) ENGINE = InnoDB) */
                                 78
Fixing annoyances with partitions
select partition_name part,
partition_expression expr,
partition_description val
from information_schema.partitions
where table_name='t1';
+------+------------+--------+
| part | expr       | val    |
+------+------------+--------+
| P1   | to_days(d) | 730120 |
| P2   | to_days(d) | 730485 |
                              79
+------+------------+--------+
fixing annoyances with partitions
select partition_name part ,
partition_expression expr,
from_days(partition_description) val
from information_schema.partitions
where table_name='t1';
+------+------------+------------+
| part | expr       | val        |
+------+------------+------------+
| P1   | to_days(d) | 1999-01-01 |
| P2   | to_days(d) | 2000-01-01 |
+------+------------+------------+
                              80

More Related Content

What's hot

How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
 
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Jaime Crespo
 
MySql Practical Partitioning
MySql Practical PartitioningMySql Practical Partitioning
MySql Practical PartitioningAndrei Tsibets
 
MySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsMySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsOSSCube
 
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsTop 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsCloudera, Inc.
 
MyRocks introduction and production deployment
MyRocks introduction and production deploymentMyRocks introduction and production deployment
MyRocks introduction and production deploymentYoshinori Matsunobu
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2Tanel Poder
 
Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013Jun Rao
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performancePostgreSQL-Consulting
 
MacOS memory allocator (libmalloc) Exploitation
MacOS memory allocator (libmalloc) ExploitationMacOS memory allocator (libmalloc) Exploitation
MacOS memory allocator (libmalloc) ExploitationAngel Boy
 
Top 5 Mistakes When Writing Spark Applications
Top 5 Mistakes When Writing Spark ApplicationsTop 5 Mistakes When Writing Spark Applications
Top 5 Mistakes When Writing Spark ApplicationsSpark Summit
 
Parallel Replication in MySQL and MariaDB
Parallel Replication in MySQL and MariaDBParallel Replication in MySQL and MariaDB
Parallel Replication in MySQL and MariaDBMydbops
 
Apache Spark At Scale in the Cloud
Apache Spark At Scale in the CloudApache Spark At Scale in the Cloud
Apache Spark At Scale in the CloudDatabricks
 
MySQL 8.0 EXPLAIN ANALYZE
MySQL 8.0 EXPLAIN ANALYZEMySQL 8.0 EXPLAIN ANALYZE
MySQL 8.0 EXPLAIN ANALYZENorvald Ryeng
 

What's hot (20)

How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
Load Data Fast!
Load Data Fast!Load Data Fast!
Load Data Fast!
 
Sql query patterns, optimized
Sql query patterns, optimizedSql query patterns, optimized
Sql query patterns, optimized
 
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
 
MySql Practical Partitioning
MySql Practical PartitioningMySql Practical Partitioning
MySql Practical Partitioning
 
MySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsMySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 Tips
 
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsTop 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
 
How to Use JSON in MySQL Wrong
How to Use JSON in MySQL WrongHow to Use JSON in MySQL Wrong
How to Use JSON in MySQL Wrong
 
MyRocks introduction and production deployment
MyRocks introduction and production deploymentMyRocks introduction and production deployment
MyRocks introduction and production deployment
 
MySQL SQL Tutorial
MySQL SQL TutorialMySQL SQL Tutorial
MySQL SQL Tutorial
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
 
Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013
 
Full Text Search In PostgreSQL
Full Text Search In PostgreSQLFull Text Search In PostgreSQL
Full Text Search In PostgreSQL
 
The PostgreSQL Query Planner
The PostgreSQL Query PlannerThe PostgreSQL Query Planner
The PostgreSQL Query Planner
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
MacOS memory allocator (libmalloc) Exploitation
MacOS memory allocator (libmalloc) ExploitationMacOS memory allocator (libmalloc) Exploitation
MacOS memory allocator (libmalloc) Exploitation
 
Top 5 Mistakes When Writing Spark Applications
Top 5 Mistakes When Writing Spark ApplicationsTop 5 Mistakes When Writing Spark Applications
Top 5 Mistakes When Writing Spark Applications
 
Parallel Replication in MySQL and MariaDB
Parallel Replication in MySQL and MariaDBParallel Replication in MySQL and MariaDB
Parallel Replication in MySQL and MariaDB
 
Apache Spark At Scale in the Cloud
Apache Spark At Scale in the CloudApache Spark At Scale in the Cloud
Apache Spark At Scale in the Cloud
 
MySQL 8.0 EXPLAIN ANALYZE
MySQL 8.0 EXPLAIN ANALYZEMySQL 8.0 EXPLAIN ANALYZE
MySQL 8.0 EXPLAIN ANALYZE
 

Viewers also liked

Partitions Performance with MySQL 5.1 and 5.5
Partitions Performance with MySQL 5.1 and 5.5Partitions Performance with MySQL 5.1 and 5.5
Partitions Performance with MySQL 5.1 and 5.5Giuseppe Maxia
 
Database Anti Patterns
Database Anti PatternsDatabase Anti Patterns
Database Anti PatternsRobert Treat
 
MySQL Sharding: Tools and Best Practices for Horizontal Scaling
MySQL Sharding: Tools and Best Practices for Horizontal ScalingMySQL Sharding: Tools and Best Practices for Horizontal Scaling
MySQL Sharding: Tools and Best Practices for Horizontal ScalingMats Kindahl
 
The Future Of Work & The Work Of The Future
The Future Of Work & The Work Of The FutureThe Future Of Work & The Work Of The Future
The Future Of Work & The Work Of The FutureArturo Pelayo
 

Viewers also liked (7)

Partitions Performance with MySQL 5.1 and 5.5
Partitions Performance with MySQL 5.1 and 5.5Partitions Performance with MySQL 5.1 and 5.5
Partitions Performance with MySQL 5.1 and 5.5
 
Database Anti Patterns
Database Anti PatternsDatabase Anti Patterns
Database Anti Patterns
 
Sql Antipatterns Strike Back
Sql Antipatterns Strike BackSql Antipatterns Strike Back
Sql Antipatterns Strike Back
 
Practical Object Oriented Models In Sql
Practical Object Oriented Models In SqlPractical Object Oriented Models In Sql
Practical Object Oriented Models In Sql
 
MySQL Sharding: Tools and Best Practices for Horizontal Scaling
MySQL Sharding: Tools and Best Practices for Horizontal ScalingMySQL Sharding: Tools and Best Practices for Horizontal Scaling
MySQL Sharding: Tools and Best Practices for Horizontal Scaling
 
Models for hierarchical data
Models for hierarchical dataModels for hierarchical data
Models for hierarchical data
 
The Future Of Work & The Work Of The Future
The Future Of Work & The Work Of The FutureThe Future Of Work & The Work Of The Future
The Future Of Work & The Work Of The Future
 

Similar to Boost Performance With My S Q L 51 Partitions

MySQL partitioning performance
MySQL partitioning performanceMySQL partitioning performance
MySQL partitioning performanceTommy Đột
 
Boost performance with MySQL 5.1 partitions
Boost performance with MySQL 5.1 partitionsBoost performance with MySQL 5.1 partitions
Boost performance with MySQL 5.1 partitionsGiuseppe Maxia
 
Partitioning Under The Hood
Partitioning Under The HoodPartitioning Under The Hood
Partitioning Under The HoodMySQLConference
 
Simple Works Best
 Simple Works Best Simple Works Best
Simple Works BestEDB
 
Master Thesis - UBC.pptx
Master Thesis - UBC.pptxMaster Thesis - UBC.pptx
Master Thesis - UBC.pptxHadi Sinaee
 
VMworld 2013: Just Because You Could, Doesn't Mean You Should: Lessons Learne...
VMworld 2013: Just Because You Could, Doesn't Mean You Should: Lessons Learne...VMworld 2013: Just Because You Could, Doesn't Mean You Should: Lessons Learne...
VMworld 2013: Just Because You Could, Doesn't Mean You Should: Lessons Learne...VMworld
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMySQLConference
 
UKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningUKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningFromDual GmbH
 
Kill mysql-performance
Kill mysql-performanceKill mysql-performance
Kill mysql-performancekriptonium
 
Sql Performance Tuning For Developers
Sql Performance Tuning For DevelopersSql Performance Tuning For Developers
Sql Performance Tuning For Developerssqlserver.co.il
 
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
 
Conference slides: MySQL Cluster Performance Tuning
Conference slides: MySQL Cluster Performance TuningConference slides: MySQL Cluster Performance Tuning
Conference slides: MySQL Cluster Performance TuningSeveralnines
 
Olap scalability
Olap scalabilityOlap scalability
Olap scalabilitylucboudreau
 
Inno Db Performance And Usability Patches
Inno Db Performance And Usability PatchesInno Db Performance And Usability Patches
Inno Db Performance And Usability PatchesMySQLConference
 
Google_A_Behind_the_Scenes_Tour_-_Jeff_Dean
Google_A_Behind_the_Scenes_Tour_-_Jeff_DeanGoogle_A_Behind_the_Scenes_Tour_-_Jeff_Dean
Google_A_Behind_the_Scenes_Tour_-_Jeff_DeanHiroshi Ono
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersJonathan Levin
 

Similar to Boost Performance With My S Q L 51 Partitions (20)

MySQL partitioning performance
MySQL partitioning performanceMySQL partitioning performance
MySQL partitioning performance
 
Boost performance with MySQL 5.1 partitions
Boost performance with MySQL 5.1 partitionsBoost performance with MySQL 5.1 partitions
Boost performance with MySQL 5.1 partitions
 
Partitioning Under The Hood
Partitioning Under The HoodPartitioning Under The Hood
Partitioning Under The Hood
 
MySQL 5.1 and beyond
MySQL 5.1 and beyondMySQL 5.1 and beyond
MySQL 5.1 and beyond
 
Partitioning 20061205
Partitioning 20061205Partitioning 20061205
Partitioning 20061205
 
Simple Works Best
 Simple Works Best Simple Works Best
Simple Works Best
 
Advanced Deployment
Advanced DeploymentAdvanced Deployment
Advanced Deployment
 
Master Thesis - UBC.pptx
Master Thesis - UBC.pptxMaster Thesis - UBC.pptx
Master Thesis - UBC.pptx
 
Quick Wins
Quick WinsQuick Wins
Quick Wins
 
VMworld 2013: Just Because You Could, Doesn't Mean You Should: Lessons Learne...
VMworld 2013: Just Because You Could, Doesn't Mean You Should: Lessons Learne...VMworld 2013: Just Because You Could, Doesn't Mean You Should: Lessons Learne...
VMworld 2013: Just Because You Could, Doesn't Mean You Should: Lessons Learne...
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With Maatkit
 
UKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningUKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL Tuning
 
Kill mysql-performance
Kill mysql-performanceKill mysql-performance
Kill mysql-performance
 
Sql Performance Tuning For Developers
Sql Performance Tuning For DevelopersSql Performance Tuning For Developers
Sql Performance Tuning For Developers
 
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
 
Conference slides: MySQL Cluster Performance Tuning
Conference slides: MySQL Cluster Performance TuningConference slides: MySQL Cluster Performance Tuning
Conference slides: MySQL Cluster Performance Tuning
 
Olap scalability
Olap scalabilityOlap scalability
Olap scalability
 
Inno Db Performance And Usability Patches
Inno Db Performance And Usability PatchesInno Db Performance And Usability Patches
Inno Db Performance And Usability Patches
 
Google_A_Behind_the_Scenes_Tour_-_Jeff_Dean
Google_A_Behind_the_Scenes_Tour_-_Jeff_DeanGoogle_A_Behind_the_Scenes_Tour_-_Jeff_Dean
Google_A_Behind_the_Scenes_Tour_-_Jeff_Dean
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for Developers
 

More from PerconaPerformance

Drizzles Approach To Improving Performance Of The Server
Drizzles  Approach To  Improving  Performance Of The  ServerDrizzles  Approach To  Improving  Performance Of The  Server
Drizzles Approach To Improving Performance Of The ServerPerconaPerformance
 
E M T Better Performance Monitoring
E M T  Better  Performance  MonitoringE M T  Better  Performance  Monitoring
E M T Better Performance MonitoringPerconaPerformance
 
Covering Indexes Ordersof Magnitude Improvements
Covering  Indexes  Ordersof Magnitude  ImprovementsCovering  Indexes  Ordersof Magnitude  Improvements
Covering Indexes Ordersof Magnitude ImprovementsPerconaPerformance
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And MavenPerconaPerformance
 
Galera Multi Master Synchronous My S Q L Replication Clusters
Galera  Multi Master  Synchronous  My S Q L  Replication  ClustersGalera  Multi Master  Synchronous  My S Q L  Replication  Clusters
Galera Multi Master Synchronous My S Q L Replication ClustersPerconaPerformance
 
My S Q L Replication Getting The Most From Slaves
My S Q L  Replication  Getting  The  Most  From  SlavesMy S Q L  Replication  Getting  The  Most  From  Slaves
My S Q L Replication Getting The Most From SlavesPerconaPerformance
 
Performance Instrumentation Beyond What You Do Now
Performance  Instrumentation  Beyond  What  You  Do  NowPerformance  Instrumentation  Beyond  What  You  Do  Now
Performance Instrumentation Beyond What You Do NowPerconaPerformance
 
Trees And More With Postgre S Q L
Trees And  More With  Postgre S Q LTrees And  More With  Postgre S Q L
Trees And More With Postgre S Q LPerconaPerformance
 
Database Performance With Proxy Architectures
Database  Performance With  Proxy  ArchitecturesDatabase  Performance With  Proxy  Architectures
Database Performance With Proxy ArchitecturesPerconaPerformance
 
Running A Realtime Stats Service On My Sql
Running A Realtime Stats Service On My SqlRunning A Realtime Stats Service On My Sql
Running A Realtime Stats Service On My SqlPerconaPerformance
 
How To Think About Performance
How To Think About PerformanceHow To Think About Performance
How To Think About PerformancePerconaPerformance
 
Object Oriented Css For High Performance Websites And Applications
Object Oriented Css For High Performance Websites And ApplicationsObject Oriented Css For High Performance Websites And Applications
Object Oriented Css For High Performance Websites And ApplicationsPerconaPerformance
 
Your Disk Array Is Slower Than It Should Be
Your Disk Array Is Slower Than It Should BeYour Disk Array Is Slower Than It Should Be
Your Disk Array Is Slower Than It Should BePerconaPerformance
 

More from PerconaPerformance (17)

Drizzles Approach To Improving Performance Of The Server
Drizzles  Approach To  Improving  Performance Of The  ServerDrizzles  Approach To  Improving  Performance Of The  Server
Drizzles Approach To Improving Performance Of The Server
 
E M T Better Performance Monitoring
E M T  Better  Performance  MonitoringE M T  Better  Performance  Monitoring
E M T Better Performance Monitoring
 
Covering Indexes Ordersof Magnitude Improvements
Covering  Indexes  Ordersof Magnitude  ImprovementsCovering  Indexes  Ordersof Magnitude  Improvements
Covering Indexes Ordersof Magnitude Improvements
 
Automated Performance Testing With J Meter And Maven
Automated  Performance  Testing With  J Meter And  MavenAutomated  Performance  Testing With  J Meter And  Maven
Automated Performance Testing With J Meter And Maven
 
Galera Multi Master Synchronous My S Q L Replication Clusters
Galera  Multi Master  Synchronous  My S Q L  Replication  ClustersGalera  Multi Master  Synchronous  My S Q L  Replication  Clusters
Galera Multi Master Synchronous My S Q L Replication Clusters
 
My S Q L Replication Getting The Most From Slaves
My S Q L  Replication  Getting  The  Most  From  SlavesMy S Q L  Replication  Getting  The  Most  From  Slaves
My S Q L Replication Getting The Most From Slaves
 
Performance Instrumentation Beyond What You Do Now
Performance  Instrumentation  Beyond  What  You  Do  NowPerformance  Instrumentation  Beyond  What  You  Do  Now
Performance Instrumentation Beyond What You Do Now
 
High Performance Erlang
High  Performance  ErlangHigh  Performance  Erlang
High Performance Erlang
 
Websites On Speed
Websites On  SpeedWebsites On  Speed
Websites On Speed
 
Trees And More With Postgre S Q L
Trees And  More With  Postgre S Q LTrees And  More With  Postgre S Q L
Trees And More With Postgre S Q L
 
Database Performance With Proxy Architectures
Database  Performance With  Proxy  ArchitecturesDatabase  Performance With  Proxy  Architectures
Database Performance With Proxy Architectures
 
Using Storage Class Memory
Using Storage Class MemoryUsing Storage Class Memory
Using Storage Class Memory
 
Websites On Speed
Websites On SpeedWebsites On Speed
Websites On Speed
 
Running A Realtime Stats Service On My Sql
Running A Realtime Stats Service On My SqlRunning A Realtime Stats Service On My Sql
Running A Realtime Stats Service On My Sql
 
How To Think About Performance
How To Think About PerformanceHow To Think About Performance
How To Think About Performance
 
Object Oriented Css For High Performance Websites And Applications
Object Oriented Css For High Performance Websites And ApplicationsObject Oriented Css For High Performance Websites And Applications
Object Oriented Css For High Performance Websites And Applications
 
Your Disk Array Is Slower Than It Should Be
Your Disk Array Is Slower Than It Should BeYour Disk Array Is Slower Than It Should Be
Your Disk Array Is Slower Than It Should Be
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Boost Performance With My S Q L 51 Partitions

  • 1. Boost performance with MySQL 5.1 partitions March 19, 2009 Giuseppe Maxia MySQL Community Team Lead Sun Microsystems
  • 3. 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
  • 7. Defining the problem YOUR NEEDS 6
  • 8. The problem(s) Too much data • Not enough RAM • Historical data • Growing data • Rotating data • 7
  • 9. Too much data data 8
  • 10. Not enough RAM RAM INDEXES INDEXES data 9
  • 11. Not enough RAM INDEXES RAM INDEXES data 10
  • 13. What is it? • Logical splitting of tables • Transparent to user 12
  • 14. Logical splitting • No need to create separate tables • No need to move chunks of data across files 13
  • 15. MySQL 5.1 partitions SQL TRANSPARENT 14
  • 16. COMPARED TO MERGE TABLES separate tables • MERGE TABLE risk of duplicates • insert in each table • no constraints • 15
  • 17. COMPARED TO MERGE TABLES One table • PARTITIONED TABLE No risk of duplicates • insert in one table • constraints enforced • 16
  • 18. Wait a minute ... • WHAT THE HELL DOES quot;LOGICAL SPLITquot; REALLY MEANS? • LET ME EXPLAIN ... 17
  • 20. Physical partitioning (2) • cut it into pieces 19
  • 21. Physical partitioning (3) • What you have, is several different pieces 20
  • 22. Physical partitioning (4) • If you want the map back, you need some application (adhesive tape) and you may get it wrong 21
  • 24. Logical partitioning (2) • fold it to show the piece you need 23
  • 25. Logical partitioning (3) • what you have is still a map, even if you see only one part. 24
  • 26. Logical partitioning (4) • if you unfold the map, you still have the whole thing 25
  • 27. What partitions can do logical split • but you can also split the data physically • granular partition (subpartitioning) • different methods (range, list, hash, key) • 26
  • 29. 4 main reasons to use partitions To make single inserts and selects faster • To make range selects faster • To help split the data across different paths • To store historical data efficiently • If you need to delete large chunks of data • INSTANTLY 28
  • 31. HOW TO MAKE PARTITIONS 30
  • 32. HOW TO MAKE PARTITIONS •RTFM ... 30
  • 33. HOW TO MAKE PARTITIONS •RTFM ... • No, seriously, the manual has everything 30
  • 34. HOW TO MAKE PARTITIONS •RTFM ... • No, seriously, the manual has everything • But if you absolutely insist ... 30
  • 35. 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) ) 31
  • 36. 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) ) 32
  • 37. HOW TO MAKE PARTITIONS CREATE TABLE t1 ( id int not null primary key ) ENGINE=InnoDB PARTITION BY HASH (id) PARTITIONS 10; 33
  • 38. HOW TO MAKE PARTITIONS CREATE TABLE t1 ( id int not null primary key ) ENGINE=InnoDB PARTITION BY KEY () PARTITIONS 10; 34
  • 39. 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 35
  • 40. PARTITIONING BY DATE CREATE TABLE t1 ( d date ) ENGINE=InnoDB PARTITION BY RANGE (year(d)) ( PARTITION P1 VALUES LESS THAN (1999), PARTITION P2 VALUES LESS THAN (2000) 36 )
  • 41. PARTITIONING BY DATE CREATE TABLE t1 ( d date ) ENGINE=InnoDB PARTITION BY RANGE (to_days(d)) ( PARTITION P1 VALUES LESS THAN (to_days('1999-01-01')), PARTITION P2 VALUES LESS THAN (to_days('2000-01-01')) 37 )
  • 43. When to use partitions? • if you have large tables • if you know that you will always query for the partitioning column • if you have historical tables that you want to purge quickly • if your indexes are larger than the available RAM 39
  • 44. MySQL 5.1 partitions HANDS ON 40
  • 45. components used for testing 41
  • 46. components used for testing • MySQL Sandbox > created MySQL instances in seconds > http://launchpad.net/mysql-sandbox 41
  • 47. components used for testing • MySQL Sandbox > created MySQL instances in seconds > http://launchpad.net/mysql-sandbox • MySQL Employees Test Database > has ~ 4 mil records in 6 tables > http://launchpad.net/test-db 41
  • 48. components used for testing • MySQL Sandbox > created MySQL instances in seconds > http://launchpad.net/mysql-sandbox • MySQL Employees Test Database > has ~ 4 mil records in 6 tables > http://launchpad.net/test-db • Command line ability > fingers > ingenuity 41
  • 50. How many partitions from information_schema.partitions +-------+-----------------+----------+ | pname | expr | descr | +-------+-----------------+----------+ | p01 | year(from_date) | 1985 | | p02 | year(from_date) | 1986 | ... | p13 | year(from_date) | 1997 | | p14 | year(from_date) | 1998 | | p15 | year(from_date) | 1999 | | p16 | year(from_date) | 2000 | ... | p19 | year(from_date) | MAXVALUE | +-------+-----------------+----------+ 43
  • 51. How many records select count(*) from salaries; +----------+ | count(*) | +----------+ | 2844047 | +----------+ 1 row in set (0.01 sec) 44
  • 52. How many records in 1998 not partitioned select count(*) from salaries where from_date between '1998-01-01' and '1998-12-31'; +----------+ | count(*) | +----------+ | 247489 | +----------+ 1 row in set (1.52 sec) # NOT PARTITIONED 45
  • 53. How many records in 1998 PARTITIONED select count(*) from salaries where from_date between '1998-01-01' and '1998-12-31'; +----------+ | count(*) | +----------+ | 247489 | +----------+ 1 row in set (0.41 sec) # partition p15 46
  • 54. How many records in 1999 not partitioned select count(*) from salaries where from_date between '1999-01-01' and '1999-12-31'; +----------+ | count(*) | +----------+ | 260957 | +----------+ 1 row in set (1.54 sec) # NOT PARTITIONED 47
  • 55. How many records in 1999 PARTITIONED select count(*) from salaries where from_date between '1999-01-01' and '1999-12-31'; +----------+ | count(*) | +----------+ | 260957 | +----------+ 1 row in set (0.17 sec) # partition p16 48
  • 56. Deleting 1998 records not partitioned delete from salaries where from_date between '1998-01-01' and '1998-12-31'; Query OK, 247489 rows affected (19.13 sec) # NOT PARTITIONED 49
  • 57. Deleting 1998 records partitioned alter table salaries drop partition p15; Query OK, 0 rows affected (1.35 sec) 50
  • 58. MySQL 5.1 partitions LEVERAGING REPLICATION 51
  • 59. Replication schemes INNODB INNODB NOT NOT MASTER PARTITIONED PARTITIONED SLAVE concurrent insert concurrent read INNODB MyISAM PARTITIONED PARTITIONED BY RANGE BY RANGE SLAVE SLAVE 52 concurrent batch processing large batch processing
  • 60. Replication schemes concurrent insert INNODB PARTITIONED MASTER INNODB NON PARTITIONED MyISAM PARTITIONED SLAVE SLAVE 53 batch processing concurrent reads
  • 62. Expressions • Partition by function • Search by column 55
  • 63. WRONG PARTITION BY RANGE(year(from_date)) select count(*) from salaries where year(from_date) = 1998; +----------+ | count(*) | +----------+ | 247489 | +----------+ 1 row in set (2.25 sec) 56
  • 64. RIGHT PARTITION BY RANGE(year(from_date)) select count(*) from salaries where from_date between '1998-01-01' and '1998-12-31'; +----------+ | count(*) | +----------+ | 247489 | +----------+ 1 row in set (0.46 sec) 57
  • 65. EXPLAIN explain partitions select count(*) from salaries where year(from_date) = 1998G ***** 1. row **** id: 1 select_type: SIMPLE table: salaries partitions: p01,p02,p03,p04,p05,p06,p07,p08,p09 ,p10,p11,p12,p13,p14,p15,p16,p17,p1 8,p19 type: index 58 ...
  • 66. EXPLAIN explain partitions select count(*) from salaries where from_date between '1998-01-01' and '1998-12-31'G ***** 1. row **** id: 1 select_type: SIMPLE table: salaries partitions: p14,p15 ... 59
  • 67. MySQL 5.1 partitions BENCHMARKS 60
  • 68. Partitions benchmarks (laptop) 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
  • 69. 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
  • 70. Partitioning storage (huge server) 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
  • 71. 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
  • 73. The partition helper • The INFORMATION_SCHEMA.PARTITIONS table • The partition helper > http://datacharmer.blogspot.com/2008/12/partition- helper-improving-usability.html > A Perl script that creates partitioning statements • ... anything you are creating right now :) 66
  • 75. TIPS • For large table ( indexes > available RAM) > DO NOT USE INDEXES > PARTITIONS ARE MORE EFFICIENT 68
  • 76. TIPS • Before adopting partitions in production, benchmark! • you can create partitions of different sizes > in historical tables, you can partition – current data by day – recent data by month – distant past data by year > ALL IN THE SAME TABLE! • If you want to enforce a constraint on a integer column, you may set a partition by list, with only the values you want to admit. 69
  • 77. TIPS • For large historical tables, consider using ARCHIVE + partitions > You see benefits for very large amounts of data ( > 500 MB) > Very effective when you run statistics > Almost the same performance of MyISAM > but 1/10 of storage 70
  • 79. MySQL 5.1 partitions BONUS SLIDES 72
  • 81. Annoyances with partitions • CREATE TABLE STATEMENT hard to read 74
  • 82. Annoyances with partitions • CREATE TABLE STATEMENT hard to read 74
  • 83. Annoyances with partitions • hard to read (FIXED!! in 5.1.31) 75
  • 84. Annoyances with partitions • hard to read (FIXED!! in 5.1.31) 75
  • 85. Annoyances with partitions • CREATE TABLE only keeps the result of the expression for each partition. • (you can use the information_schema to ease the pain in this case) 76
  • 86. Annoyances with partitions CREATE TABLE t1 ( d date ) ENGINE=InnoDB PARTITION BY RANGE (to_days(d)) ( PARTITION P1 VALUES LESS THAN (to_days('1999-01-01')), PARTITION P2 VALUES LESS THAN (to_days('2000-01-01')) 77 )
  • 87. Annoyances with partitions CREATE TABLE `t1` ( `d` date DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (to_days(d)) (PARTITION P1 VALUES LESS THAN (730120) ENGINE = InnoDB, PARTITION P2 VALUES LESS THAN (730485) ENGINE = InnoDB) */ 78
  • 88. Fixing annoyances with partitions select partition_name part, partition_expression expr, partition_description val from information_schema.partitions where table_name='t1'; +------+------------+--------+ | part | expr | val | +------+------------+--------+ | P1 | to_days(d) | 730120 | | P2 | to_days(d) | 730485 | 79 +------+------------+--------+
  • 89. fixing annoyances with partitions select partition_name part , partition_expression expr, from_days(partition_description) val from information_schema.partitions where table_name='t1'; +------+------------+------------+ | part | expr | val | +------+------------+------------+ | P1 | to_days(d) | 1999-01-01 | | P2 | to_days(d) | 2000-01-01 | +------+------------+------------+ 80