Use Cases for Partitioning. Bill Karwin Percona, Inc

Similar documents
MySQL HA Solutions. Keeping it simple, kinda! By: Chris Schneider MySQL Architect Ning.com

Jargons, Concepts, Scope and Systems. Key Value Stores, Document Stores, Extensible Record Stores. Overview of different scalable relational systems

MySQL Architecture Design Patterns for Performance, Scalability, and Availability

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS

MySQL Cluster An Introduction

MySQL 101. Designing effective schema for InnoDB. Yves Trudeau April 2015

MySQL Replication Options. Peter Zaitsev, CEO, Percona Moscow MySQL User Meetup Moscow,Russia

Upgrading MySQL Best Practices. Apr 11-14, 2011 MySQL Conference and Expo Santa Clara,CA by Peter Zaitsev, Percona Inc

Introduction to MySQL NDB Cluster. Yves Trudeau Ph. D. Percona Live DC/January 2012

TIBCO StreamBase 10 Distributed Computing and High Availability. November 2017

Improvements in MySQL 5.5 and 5.6. Peter Zaitsev Percona Live NYC May 26,2011

Design Patterns for Large- Scale Data Management. Robert Hodges OSCON 2013

Choosing a MySQL HA Solution Today. Choosing the best solution among a myriad of options

CIT 668: System Architecture

A Non-Relational Storage Analysis

Various MySQL High Availability (HA) Solutions

<Insert Picture Here> Boosting performance with MySQL partitions

Azure-persistence MARTIN MUDRA

Scaling Without Sharding. Baron Schwartz Percona Inc Surge 2010

MySQL Database Scalability

Scaling. Marty Weiner Grayskull, Eternia. Yashh Nelapati Gotham City

Course Content MongoDB

Scaling Databases with DBIx::Router. Perrin Harkins We Also Walk Dogs

MySQL High Availability

MySQL Cluster Student Guide

Using SPIDER for sharding in production. Kentoku SHIBA Stephane Varoqui Kayoko Goto

MySQL 5.1 Past, Present and Future MySQL UC 2006 Santa Clara, CA

The Top 20 Design Tips

Hadoop Map Reduce 10/17/2018 1

MySQL usage of web applications from 1 user to 100 million. Peter Boros RAMP conference 2013

IT Best Practices Audit TCS offers a wide range of IT Best Practices Audit content covering 15 subjects and over 2200 topics, including:

Percona XtraDB Cluster powered by Galera. Peter Zaitsev CEO, Percona Slide Credits: Vadim Tkachenko Percona University, Washington,DC Sep 12,2013

PostgreSQL to MySQL A DBA's Perspective. Patrick

Project Genesis. Cafepress.com Product Catalog Hundreds of Millions of Products Millions of new products every week Accelerating growth

Lessons from database failures

The Future of Postgres Sharding

HA solution with PXC-5.7 with ProxySQL. Ramesh Sivaraman Krunal Bauskar

MySQL Replication. Rick Golba and Stephane Combaudon April 15, 2015

Scale out Read Only Workload by sharing data files of InnoDB. Zhai weixiang Alibaba Cloud

CISC 7610 Lecture 2b The beginnings of NoSQL

MariaDB 10.3 vs MySQL 8.0. Tyler Duzan, Product Manager Percona

Mastering phpmyadmiri 3.4 for

Inputs. Decisions. Leads to

MySQL High Availability. Michael Messina Senior Managing Consultant, Rolta-AdvizeX /

MySQL Database Administrator Training NIIT, Gurgaon India 31 August-10 September 2015

Delegates must have a working knowledge of MariaDB or MySQL Database Administration.

Lessons with Tera-Tom Teradata Architecture Video Series

The Hazards of Multi-writing in a Dual-Master Setup

MySQL and Virtualization Guide

<Insert Picture Here> MySQL Web Reference Architectures Building Massively Scalable Web Infrastructure

Rule 14 Use Databases Appropriately

MySQL Performance Improvements

A Brief Introduction of TiDB. Dongxu (Edward) Huang CTO, PingCAP

MongoDB Schema Design

Scaling. Yashh Nelapati Gotham City. Marty Weiner Krypton. Friday, July 27, 12

Chapter 24 NOSQL Databases and Big Data Storage Systems

Current Topics in OS Research. So, what s hot?

Postgres-XC PG session #3. Michael PAQUIER Paris, 2012/02/02

CSE 414: Section 7 Parallel Databases. November 8th, 2018

Which technology to choose in AWS?

MongoDB Architecture

Introduction to MySQL Cluster: Architecture and Use

Databasesystemer, forår 2005 IT Universitetet i København. Forelæsning 8: Database effektivitet. 31. marts Forelæser: Rasmus Pagh

CHAPTER. Oracle Database 11g Architecture Options

Switching to Innodb from MyISAM. Matt Yonkovit Percona

InnoDB Scalability Limits. Peter Zaitsev, Vadim Tkachenko Percona Inc MySQL Users Conference 2008 April 14-17, 2008

FromDual Annual Company Meeting

Physical DB design and tuning: outline

How to Scale MongoDB. Apr

MongoDB Backup and Recovery Field Guide. Tim Vaillancourt Sr Technical Operations Architect, Percona

MySQL Cluster (NDB) An Introduc+on and Overview. Ma3hew Boehm April

Split your database. Nicolai Plum Booking.com Database Engineering

Postgres-XC PostgreSQL Conference Michael PAQUIER Tokyo, 2012/02/24

High Availability and Automatic Failover in PostgreSQL using Open Source Solutions

Distributed computing: index building and use

How Tencent uses PGXZ(PGXC) in WeChat payment system. jason( 李跃森 )

Physical Design of Relational Databases

MySQL HA vs. HA. DOAG Konferenz 2016, Nürnberg. Oli Sennhauser. Senior MySQL Consultant, FromDual GmbH.

Postgres-XC Dynamic Cluster Management

MySQL High Availability Solutions. Alex Poritskiy Percona

Replication features of 2011

Writing High Performance SQL Statements. Tim Sharp July 14, 2014

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2016)

DB2 MOCK TEST DB2 MOCK TEST I

Using MySQL for Distributed Database Architectures

MySQL 5.0 Certification Study Guide

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2017)

NoVA MySQL October Meetup. Tim Callaghan VP/Engineering, Tokutek

MongoDB. David Murphy MongoDB Practice Manager, Percona

Choosing a MySQL HA Solution Today

MySQL Architecture Options:

To Shard or Not to Shard That is the question! Peter Zaitsev April 21, 2016

MySQL Worst Practices. Introduction. by Jonathan Baldie

Postgres-XC Postgres Open Michael PAQUIER 2011/09/16

PostgreSQL Replication 2.0

Massive Scalability With InterSystems IRIS Data Platform

Building Highly Available and Scalable Real- Time Services with MySQL Cluster

Conceptual Modeling on Tencent s Distributed Database Systems. Pan Anqun, Wang Xiaoyu, Li Haixiang Tencent Inc.

SQL, NoSQL, MongoDB. CSE-291 (Cloud Computing) Fall 2016 Gregory Kesden

What s new in Percona Xtradb Cluster 5.6. Jay Janssen Lead Consultant February 5th, 2014

Transcription:

Use Cases for Partitioning Bill Karwin Percona, Inc. 2011-02-16 1

Why Use Cases?! Anyone can read the reference manual: http://dev.mysql.com/doc/refman/5.1/en/partitioning.html! This talk is about when and why to use partitioning! and what options to use 2

Partitioning in MySQL 5.1! Horizontal partitioning (by rows)! Query across partitions transparently! Helps archiving old data! Query only against relevant partition of data! Supports more data than a single file or filesystem 3

Partitioning in MySQL 5.1! Choices for Partition type RANGE LIST HASH KEY! How to choose? 4

Partitioning in MySQL 5.5! New Partition types: RANGE COLUMNS, LIST COLUMNS Define ranges or lists against multiple columns Prune partitions for expressions over multiple columns Partition range or list against non-integer data types DATE, DATETIME, CHAR, VARCHAR! TRUNCATE PARTITION 5

Partitioning Is Not! Load balancing Alternative: Master-Slave Replication Alternative: MySQL Proxy Alternative: NDB Cluster 6

Partitioning Is Not! Hot backup No redundancy. Table is split, not cloned. Alternative: Master-Master Replication Alternative: MMM (http://mysql-mmm.org/) 7

Partitioning Is Not! Software RAID Alternative: Software RAID Alternative: Hardware RAID 8

Partitioning Is Not! Parallel query Alternative: NDB Cluster Alternative: MySQL Proxy Alternative: Shard-Query (http://code.google.com/p/shard-query/)! Parallel aggregation Alternative: MySQL Proxy Alternative: Shard-Query 9

Use Case: Query by PK! If you want rows to fill partitions approximately equally! If you don t care which partition a given row lives in! CREATE TABLE Tweets (! TweetId SERIAL PRIMARY KEY,!... ) PARTITION BY HASH( TweetId ) PARTITIONS 8;! SELECT * FROM Tweets WHERE TweetId = 1234; 10

Use Case: Query by PK! If you don t care if partitions are filled as equally! If you want to add/drop/merge/split partitions faster! CREATE TABLE Tweets (! TweetId SERIAL PRIMARY KEY,!... ) PARTITION BY LINEAR HASH( TweetId ) PARTITIONS 8;! SELECT * FROM Tweets WHERE TweetId = 1234;! ALTER TABLE Tweets COALESCE PARTITION 4; -- remove 4 partitions! ALTER TABLE Tweets ADD PARTITIONS 6; -- add 6 partitions 11

Use Case: Query by PK! If your primary key is not an integer! CREATE TABLE Tweets (! TweetToken BINARY(16) PRIMARY KEY,!... ) PARTITION BY KEY( TweetToken ) PARTITIONS 8;! SELECT * FROM Tweets WHERE TweetToken = UNHEX(MD5( 1234 )); 12

Use Case: Query by Expression! If you want rows with close values to be stored together! If you can make an integer expression to group rows! CREATE TABLE Tweets (! Tweet VARCHAR(140),! TweetDate DATETIME,!... ) PARTITION BY RANGE( TO_DAYS(TweetDate) ) PARTITION p0 VALUES LESS THAN (734472), -- 2010-12-01 PARTITION p1 VALUES LESS THAN (734503), -- 2011-01-01 PARTITION p2 VALUES LESS THAN (734534), -- 2011-02-01 PARTITION p3 VALUES LESS THAN (734562), -- 2011-03-01 PARTITION p4 VALUES LESS THAN (734593); -- 2011-04-01 13

Use Case: Query by Expression! If you query with a compatible expression, MySQL touches only the relevant partition(s).! SELECT * FROM Tweets WHERE TO_DAYS(TweetDate) >= TO_DAYS( 2011-02-16 );! Partition pruning by expression supports only functions YEAR(), TO_DAYS(), and in MySQL 5.5, TO_SECONDS(). You can use other functions in expressions, but not benefit from pruning. 14

Use Case: INSERT! INSERT INTO Tweets (Tweet, TweetDate) VALUES ( Percona Live SF 2/16, NOW()); 15

Use Case: UPDATE! UPDATE Tweets SET IsDeleted = 1 WHERE TweetToken = UNHEX(MD5( 1234 ));! Does this benefit from partition pruning? Yes, if partition on TweetToken No, if partition on TweetDate! UPDATE Tweets SET IsDeleted = 1 WHERE TweetToken = UNHEX(MD5( 1234 )) AND TO_DAYS(TweetDate) = TO_DAYS( 2011-02-16 ); 16

Use Case: UPDATE! UPDATE Tweets SET IsDeleted = 1 WHERE TweetToken = UNHEX(MD5( 1234 )) AND TO_DAYS(TweetDate) = TO_DAYS( 2011-02-16 );! Does this benefit from partition pruning? Yes, if partition on TweetToken Yes, if partition on TweetDate 17

Use Case: DELETE / Archiving! ALTER TABLE Tweets DROP PARTITION p0; Fast, works with no temporary table! Only works with RANGE / LIST partitioning Why? DROP a RANGE / LIST partition deletes data rows in partition COALESCE a HASH / KEY partition set redistributes rows, which rebuilds the table! If you want to archive / retire old data, use RANGE / LIST partition types 18

Use Case: Really Big Table! Larger than your filesystem You can specify physical path for each partition: CREATE TABLE Tweets (... ) PARTITION BY RANGE( TO_DAYS(TweetDate) ) PARTITION p0 VALUES LESS THAN (734472) ( DATA DIRECTORY = /disk0/data, INDEX DIRECTORY = /disk0/index ), PARTITION p1 VALUES LESS THAN (734503) ( DATA DIRECTORY = /disk1/data, INDEX DIRECTORY = /disk1/index ),... 19

! We'll be at the MySQL Conference April 11-14, 2011. Please join us!!! Register with 20% discount using this code: mys11pka 20