Presented by, MySQL AB® & O’Reilly Media, Inc. Applied Partitioning and Scaling Your (OLTP) Database System Phil Hildebrand thePlatform.

Slides:



Advertisements
Similar presentations
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Advertisements

MS-Access XP Lesson 1. Introduction to MS-Access Database Management System Software (DBMS) Store data in databases Database is a collection of table.
SQL Rohit Khokher.
Drop in replacement of MySQL. Agenda MySQL branch GPL licence Maria storage engine Virtual columns FederatedX storage engine PBXT storage engine XtraDB.
Big Data Working with Terabytes in SQL Server Andrew Novick
Day 3 - Basics of MySQL What is MySQL What is MySQL How to make basic tables How to make basic tables Simple MySQL commands. Simple MySQL commands.
Project Management Database and SQL Server Katmai New Features Qingsong Yao
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
Chapter Physical Database Design Methodology Software & Hardware Mapping Logical Design to DBMS Physical Implementation Security Implementation Monitoring.
Introduction to Structured Query Language (SQL)
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Lecture 6 Indexing Part 2 Column Stores. Indexes Recap Heap FileBitmapHash FileB+Tree InsertO(1) O( log B n ) DeleteO(P)O(1) O( log B n ) Range Scan O(P)--
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
Sarah Sproehnle Cloudera, Inc
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
Lecture 8 Index Organized Tables Clusters Index compression
Hive : A Petabyte Scale Data Warehouse Using Hadoop
Dbwebsites 2.1 Making Database backed Websites Session 2 The SQL… Where do we put the data?
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
Introduction to Internet Databases MySQL Database System Database Systems.
Applications hitting a wall today with SQL Server Locking/Latching Scale-up Throughput or latency SLA Applications which do not use SQL Server.
SQL Server Indexes Indexes. Overview Indexes are used to help speed search results in a database. A careful use of indexes can greatly improve search.
14-1 Goals of Database Design A database should provide for efficient storage, update, and retrieval of data. A database should be reliable—the stored.
Nitin Singh/AAO RTI ALLAHABAD 1 SQL Nitin Singh/AAO RTI ALLAHABAD 2 OBJECTIVES §What is SQL? §Types of SQL commands and their function §Query §Index.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Proactively Optimizing Queries with EXPLAIN and mk-query-digest Presented by: Sheeri K. Cabral Database Operations Manager MySQL Sunday at Oracle OpenWorld.
Introduction MySQL won't actually execute the query, just analyse it EXPLAIN helps us understand how and when MySQL will use indexes EXPLAIN returns a.
More Dimensional Modeling. Facts Types of Fact Design Transactional Periodic Snapshot –Predictable time period –Ex. Monthly, yearly, etc. Accumulating.
SQL Server 2005 Implementation and Maintenance Chapter 3: Tables and Views.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Praveen Srivatsa Director| AstrhaSoft Consulting blogs.asthrasoft.com/praveens |
Database Indexing 1 After this lecture, you should be able to:  Understand why we need database indexing.  Define indexes for your tables in MySQL. 
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Partition Architecture Yeon JongHeum
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
Chapter 5 Index and Clustering
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
What is MySQL? MySQL is a relational database management system (RDBMS) based on SQL (Structured Query Language). First released in January, Many.
1 MySQL and SQL. 2 Topics  Introducing Relational Databases  Terminology  Managing Databases MySQL and SQL.
Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata Performance Optimization.
There are two types of MySQL instructions (Data Definition Language) DDL: Create database, create table, alter table,,,. (Data Manipulation Language) DML.
CS 440 Database Management Systems Lecture 6: Data storage & access methods 1.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
LAB: Web-scale Data Management on a Cloud Lab 11. Query Execution Plan 2011/05/27.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata Physical Database Design Considerations.
IT 5433 LM4 Physical Design. Learning Objectives: Describe the physical database design process Explain how attributes transpose from the logical to physical.
Bend SQL to Your Will With EXPLAIN Ligaya Turmelle MySQL Support Engineer
Partitioning Sheeri K. Cabral Database Administrator The Pythian Group, January 12, 2009.
Index An index is a performance-tuning method of allowing faster retrieval of records. An index creates an entry for each value that appears in the indexed.
Optimizing MySQL Joins and Subqueries
Hive Mr. Sriram
MySQL Explain examples
Instant Add Columns in MySQL
MySQL Dr. Hsiang-Fu Yu National Taipei University of Education
Microsoft SQL Server 2014 for Oracle DBAs Module 7
Database systems Lecture 3 – SQL + CRUD
The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited)
Database Administration
CS222/CS122C: Principles of Data Management UCI, Fall 2018 Notes #03 Row/Column Stores, Heap Files, Buffer Manager, Catalogs Instructor: Chen Li.
Introduction to SQL Server and the Structure Query Language
Presentation transcript:

Presented by, MySQL AB® & O’Reilly Media, Inc. Applied Partitioning and Scaling Your (OLTP) Database System Phil Hildebrand thePlatform for Media, Inc.

Objectives  Review classic uses of database partitioning  Applying partitioning to MySQL OLTP applications  Hash partitioning with MySQL OLTP applications Implementation examples  Q&A

Classic Partitioning  Old School – union in the archive tables  Auto partitioning and partition pruning  Lends itself to Data Warehouses Archival and Date based partitioning Predictable growth patterns  Benefits within Data Warehouses Maintenance benefits Query performance improved

Applying Partitioning to OLTP  Design Issues Often id driven access vs. date driven access Difficulties in estimating partition ranges / sizes Intelligent keys increase complexity in partitions  Operational Issues Difficult to schedule downtime for DDL changes General lack of use outside of data warehousing

Applying Partitioning to OLTP  Understanding the Benefits Reducing seek and scan set sizes Limiting insert / update transaction durations Creates additional options for Maint processes

Reducing scan/seek set sizes mysql> explain partitions select my_store.city,my_employee_old.name from my_store, my_employee_old where my_store.id in (5,8,10) and my_store.id = my_employee_old.store_id and my_employee_old.id = (ROUND(RAND()*50000,0)); |id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra | | 1 | SIMPLE | my_store | p5,p8,p10 | range | PRIMARY | PRIMARY | 8 | NULL | 3 | Using where | | 1 | SIMPLE | my_employee_old | NULL | ALL | NULL | NULL | NULL | NULL | | Using where; Using join buffer | +_ mysql> explain partitions select my_store.city,my_employee.name from my_store, my_employee where my_store.id in (5,8,10) and my_store.id = my_employee.store_id and my_employee.id = (ROUND(RAND()*50000,0)); | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra | | 1 | SIMPLE | my_store | p5,p8,p10 | range | PRIMARY | PRIMARY | 8 | NULL | 3 | Using where | | 1 | SIMPLE | my_employee | p5,p8,p10 | ALL | NULL | NULL | NULL | NULL | 2979 | Using where; Using join buffer |

Simple join with out partitions $ time mysqlslap -u root --create-schema=conf --query=sel_store_employee_old.sql -c 5 -i F ";" Benchmark Average number of seconds to run all queries: seconds Minimum number of seconds to run all queries: seconds Maximum number of seconds to run all queries: seconds Number of clients running queries: 5 Average number of queries per client: 1 real 2m22.018s user 0m0.217s sys 0m0.445s

Simple join with partitions $ time mysqlslap -u root --create-schema=conf --query=sel_store_employee.sql -c 5 -i F ";" Benchmark Average number of seconds to run all queries: seconds Minimum number of seconds to run all queries: seconds Maximum number of seconds to run all queries: seconds Number of clients running queries: 5 Average number of queries per client: 1 real 0m6.660s user 0m0.133s sys 0m0.306s

Rebuilding by partition mysql> optimize table my_employee_old; | Table | Op | Msg_type | Msg_text | | conf.my_employee_old | optimize | status | OK | row in set (1.14 sec) mysql> alter table my_employee rebuild partition p1; Query OK, 0 rows affected (0.03 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> alter table my_employee rebuild partition p1,p2,p3,p4,p5,p6,p7,p8,p9,p10; Query OK, 0 rows affected (0.27 sec) Records: 0 Duplicates: 0 Warnings: 0

Applying Partitioning to OLTP  Design Considerations Table sizes and predicted growth patterns Access patterns Keys and indexes Availability and Scalability requirements Manageability considerations Reuse considerations

Choosing a Partitioning Method  Range Partitioning Data usually accessed by date Limited number of (primary) partitions needed Ordered Intelligent keys Supports Sub Partitions  List Partitioning Grouping data in partitions out of order (1,5,7 in partition x) Limited number of (primary) partitions needed Intelligent keys Supports Sub Partitions  Hash Partitioning Low maintenance Works with limited or large number of partitions Non-intelligent keys (can work with some cases of intelligent keys)  Key Partitioning Non-integer based partitioned keys (md5 hash) Low maintenance

Hash Partitioning and OLTP  Applying a hash to the partitioning key Hash Partitions Key Partitions  Fixed number of partitions Number of partitions determined by hash (mod%num_partitions)

My Retail Store App mysql> show columns from my_store; | Field | Type | Null | Key | Default | | id | bigint(20) | NO | PRI | NULL | | city | varchar(128) | YES | | NULL | | country | varchar(128) | YES | | NULL | mysql> show columns from my_employee; | Field | Type | Null | Key | Default | | id | bigint(20) | NO | PRI | NULL | | store_id | bigint(20) | NO | PRI | NULL | | name | varchar(56) | YES | | NULL | mysql> show columns from my_inventory; | Field | Type | Null | Key | Default | | id | bigint(20) | NO | PRI | NULL | | store_id | bigint(20) | NO | PRI | NULL | | name | varchar(56) | YES | | NULL | | in_stock | bit(1) | YES | | NULL | | on_order | bit(1) | YES | | NULL | | item_cnt | bigint(20) | YES | | NULL | | cost | float | YES | | NULL |

Applying Hash Partitioning  Partition on Store ID mysql> ALTER TABLE MY_STORE PARTITION BY HASH (id) PARTITIONS 50 ; Query OK, 50 rows affected (0.76 sec) Records: 50 Duplicates: 0 Warnings: 0 mysql> ALTER TABLE MY_EMPLOYEE PARTITION BY HASH (store_id) PARTITIONS 50 ; Query OK, rows affected (25.28 sec) Records: Duplicates: 0 Warnings: 0 mysql> ALTER TABLE MY_INVENTORY PARTITION BY HASH (store_id) PARTITIONS 50 ; Query OK, rows affected (2 min 8.32 sec) Records: Duplicates: 0 Warnings: 0

Splitting Partitions  Expanding into Australia with 2 new stores: mysql> ALTER TABLE MY_STORE ADD PARTITION PARTITIONS 2; Query OK, 0 rows affected (0.86 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> ALTER TABLE MY_EMPLOYEE ADD PARTITION PARTITIONS 2; Query OK, 0 rows affected (2.43 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> ALTER TABLE MY_INVENTORY ADD PARTITION PARTITIONS 2; Query OK, 0 rows affected (7.60 sec) Records: 0 Duplicates: 0 Warnings: 0

Splitting Partitions mysql> select table_name,partition_name,table_rows -> from information_schema.partitions -> where table_schema = 'conf' -> and table_name in ('MY_STORE','MY_INVENTORY','MY_EMPLOYEE') -> and table_rows < 1; | table_name | partition_name | table_rows | | my_employee | p0 | 0 | | my_employee | p51 | 0 | | my_inventory | p0 | 0 | | my_inventory | p51 | 0 | | my_store | p0 | 0 | | my_store | p51 | 0 |

Merging Partitions  Closing All Stores in China (4 stores) : mysql> ALTER TABLE MY_STORE COALESCE PARTITION 4; Query OK, 0 rows affected (0.40 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> ALTER TABLE MY_EMPLOYEE COALESCE PARTITION 4; Query OK, 0 rows affected (2.71 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> ALTER TABLE MY_INVENTORY COALESCE PARTITION 4; Query OK, 0 rows affected (7.81 sec) Records: 0 Duplicates: 0 Warnings: 0

Merging Partitions  Closing All Stores in China (4 stores) : mysql> select table_name,count(*) -> from information_schema.partitions -> where table_schema = 'conf' -> and table_name in ('MY_STORE','MY_INVENTORY','MY_EMPLOYEE') -> group by table_name; | table_name | count(*) | | my_employee | 48 | | my_inventory | 48 | | my_store | 48 |

A Few More Stats… (No Partitions) mysql> explain partitions select my_store_no_part.city,my_employee_no_part.name,count(*) from my_store_no_part, my_employee_no_part, my_inventory_no_part where my_store_no_part.id in (5,8,10,23,80) and my_store_no_part.id = my_employee_no_part.store_id and my_store_no_part.id = my_inventory_no_part.store_id and my_employee_no_part.id < 2000 and my_inventory_no_part.in_stock = (ROUND(RAND(),0)) group by my_store_no_part.city,my_employee_no_part.name; |id | select_type | table | partitions | type | possible_keys | key | ref | rows | Extra | | 1 | SIMPLE | my_employee_no_part | NULL | range | PRIMARY | PRIMARY | NULL | 3962 | Using where; Using temporary; Using filesort | | 1 | SIMPLE | my_store_no_part | NULL | eq_ref | PRIMARY | PRIMARY | conf.my_employee_no_part.store_id | 1 | | | 1 | SIMPLE | my_inventory_no_part | NULL | ALL | NULL | NULL | NULL | | Using where; Using join buffer | mysql> select my_store_no_part.city,my_employee_no_part.name,count(*) from my_store_no_part, my_employee_no_part, my_inventory_no_part where my_store_no_part.id in (5,8,10,23,80) and my_store_no_part.id = my_employee_no_part.store_id and my_store_no_part.id = my_inventory_no_part.store_id and my_employee_no_part.id < 2000 and my_inventory_no_part.in_stock = (ROUND(RAND(),0)) group by my_store_no_part.city,my_employee_no_part.name; | city | name | count(*) | | Delhi | Employee #0 | | | Istanbul | Employee #0 | | | Karachi | Employee #0 | | | Seoul | Employee #0 | | rows in set (16.45 sec)

A Few More Stats… (Partitions) mysql> explain partitions select my_store_lrg.city,my_employee_lrg.name,count(*) from my_store_lrg, my_employee_lrg, my_inventory_lrg where my_store_lrg.id in (5,8,10,23,80) and my_store_lrg.id = my_employee_lrg.store_id and my_store_lrg.id = my_inventory_lrg.store_id and my_employee_lrg.id < 2000 and my_inventory_lrg.in_stock = (ROUND(RAND(),0)) group by my_store_lrg.city,my_employee_lrg.name; |id | select_type | table | partitions | type | possible_keys | key | ref | rows | Extra | |1 | SIMPLE | my_employee_lrg | p5,p8,p10,p23,p80 | range | PRIMARY | PRIMARY | NULL | 94 | Using where; Using temporary; Using filesort | |1 | SIMPLE | my_store_lrg | p5,p8,p10,p23,p80 | eq_ref | PRIMARY | PRIMARY | conf.my_employee_lrg.store_id | 1 | | |1 | SIMPLE | my_inventory_lrg | p5,p8,p10,p23,p80 | ALL | NULL | NULL | NULL | | Using where; Using join buffer | mysql> select my_store_lrg.city,my_employee_lrg.name,count(*) from my_store_lrg, my_employee_lrg, my_inventory_lrg where my_store_lrg.id in (5,8,10,23,80) and my_store_lrg.id = my_employee_lrg.store_id and my_store_lrg.id = my_inventory_lrg.store_id and my_employee_lrg.id < 2000 and my_inventory_lrg.in_stock = (ROUND(RAND(),0)) group by my_store_lrg.city,my_employee_lrg.name; | city | name | count(*) | | Delhi | Employee #0 | | | Istanbul | Employee #0 | | | Karachi | Employee #0 | | | Seoul | Employee #0 | | rows in set (1.89 sec)

Summing it Up  Partitioning provides an easy way to scale within a database  Partitioning has a place in OLTP  Remember access methods and maintenance  Use Range/List for intelligent partitioning  Use Hash/Key for low maintenance, many partitions

Questions Anyone?