SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
Solving Performance Problems in MySQL Without Denormalization

                 RENORMALIZE

              Akiban Technologies, Inc. Confidential & Proprietary
Problem Statement


Schemas scale out

Data volume grows

Joins become a real bottleneck



Akiban Technologies, Inc. Confidential & Proprietary   2
Two Common Manifestations
SQL Joins
   Queries become slower as more tables are
   joined.


Application Object Creations
   Constructing an object is as expensive as
   SELECTing the sum of its parts


             Denormalize. Problem solved.

Akiban Technologies, Inc. Confidential & Proprietary   3
Application Growing Pains
                                                  Web     Cache
                                                 Server   Server




            V6 Release
            V5
            V4
            V3
            V1
            V2
            Rip & ReplaceDB
            Shard Database
            Add Customers!
            Get Caching
            Replicate DB
            De-normalize




                                                                       Complexity & Cost
Customers




                                                          MySQL

                          Rip & Replace Database Architecture
                              MySQL              MySQL
                                                          Slaves




                              MySQL   Sharding
                                                     ?
                                                 MySQL




                                                 Time

                                                                   4
De·nor·mal·ize
[de-nawr-muh-lahyze]
verb, -ized, -iz·ing.
–verb (used with object)
1.  the process of attempting to optimize the read
      performance of a database by adding redundant
      data or by grouping data wikipedia

2.  Denormalize means to allow redundancy in a
      table so that the table can remain flat UCSD Blink

3.  The process of restructuring a normalized data
      model to accommodate operational constraints or
      system limitations celiang.tongji.edu.cn


Akiban Technologies, Inc. Confidential & Proprietary       5
Materialized Views
Persistent database object
   Contains the results of a query
   Store summary and pre-joined tables
   Require maintenance/refresh for dynamic data
SELECT
DISTINCT(n.nid),n.sticky,n.title,n.created
FROM node n
INNER JOIN term_node tn0
         ON n.vid = tn0.vid
WHERE       n.status = 1
        AND tn0.tid IN (77)
ORDER BY   n.sticky DESC, n.created DESC
LIMIT 0, 25;

Result: using where, using filesort
Akiban Technologies, Inc. Confidential & Proprietary   6
Drupal Materialized View Project
CREATE TABLE `mv_drupalorg_node_by_term` (
                   `entity_type` varchar(64) NOT NULL,
                   `entity_id` int(10) unsigned NOT NULL DEFAULT '0’,
                   `term_tid` int(10) unsigned NOT NULL DEFAULT '0',
                   `node_sticky` int(11) NOT NULL DEFAULT '0',
                   `last_node_activity` int(11) NOT NULL DEFAULT '0',
                   `node_created` int(11) NOT NULL DEFAULT '0',
                   `node_title` varchar(255) NOT NULL DEFAULT '’,
  PRIMARY KEY (`entity_type`,`entity_id`,`term_tid`),
  KEY `activity`
  (`term_tid`,`node_sticky`,`last_node_activity`,`node_created`),
  KEY `creation` (`term_tid`,`node_sticky`,`node_created`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8

SELECT DISTINCT entity_id AS nid, node_sticky AS sticky, node_title
  AS title,
                    node_created AS created
  FROM mv_drupalorg_node_by_term
  WHERE term_tid IN (77)
  ORDER BY node_sticky DESC, node_created DESC
  LIMIT 0, 25;

               Result: using where, using temporary table

Akiban Technologies, Inc. Confidential & Proprietary              7
Denormalization Technique Listing
Technique                                Pros                           Cons

Materialized views                       Faster queries (no joins)      Data explosion
                                                                        Manually keep synched

Store object as Blob                     Fast object get                No modeling, or querying


Denormalize 1NF: Folding                 Data in one row                limited # of child rows
parent-child into parent table                                          Hard to query (UNION hell)


Denormalize 2NF to 1NF: repeat           Avoid join                     Data explosion
columns from 1 table in M table                                         Manually keep synched
(Double writing)

Adding derived columns                   Avoid joins, aggregation       Manually keep synched


Property bag (RDF)                       Schema flexibility             Manage schema in app
                 Akiban Technologies, Inc. Confidential & Proprietary   Hard to index or perform   8
Renormalization

Join for free
   - Improved performance. 10-100x!
   - Retrieve an object in one request




Akiban Technologies, Inc. Confidential & Proprietary   9
Introduction to Table-Groups
Traditional SQL
             Schema à Table à Column


Akiban newSQL
             Schema à GROUP à Table à Column


Table-Groups are first class citizens



Akiban Technologies, Inc. Confidential & Proprietary   10
Typical Relational DB Schema




Akiban Technologies, Inc. Confidential & Proprietary   11
Typical Schema: Grouped

Block
Group




          User
          Group



                             Node Group   12
Table-Groups Eliminate Joins
                                                                                                   Logical

                                                                                                 Physical
Users                          Users_Roles                      Sessions
                                                                                     Artist Table-group
 uid    name      pass
                                        id    rid
                                                                 id    sid           timestamp




  1     rriegel   ***                    1     1                 1    19390      2011-10-01-06:02.00

  2    twegner    ***                    1     2                 2    22828      2011-10-04-22:32.10

                                         2     1                 1    49377      2011-10-04-16:07.30




        Table                            Group
                                         Table                               Table
        bTree                            bTree                               bTree



         Akiban Technologies, Inc. Confidential & Proprietary                                          13
Benefits of Table-grouping
SQL join operations are fast
    -  Table Group access is equivalent to a
       single table access. Joins are free!
    -  Performance increases 10-100x


Applications do not change
    -  Maintain the same tables and SQL
    -  Objects (e.g. ORM) fetched in one request
    -  Akiban uses standard MySQL replication


Akiban Technologies, Inc. Confidential & Proprietary   14
Design Partner Sample Query

SELECT     t1.id , t3.c1,
           t3.c2, t3.c3, t3.c4
FROM       t1
INNER JOIN t2 on t2.id = t1.id
LEFT JOIN t3 ON t1.id = t3.id
WHERE      t2.region in (1297789)
     AND   t1.c1 = '0'
ORDER BY   t1.latestLogin DESC
LIMIT      500



 Akiban Technologies, Inc. Confidential & Proprietary   15
Typical MySQL EXPLAIN Plan

                                                               10     Project Results

Sort                                                       9

Temp Table                                       8


2 Joins                                 7

                                4                6                  2 Table Accesses

                       2                3                  5

              1                                                     3 Index Accesses


    Akiban Technologies, Inc. Confidential & Proprietary
Efficiency for Speed and Scale

                                                                                    No Joins,
Project Results                                              3                    Temp Tables or
                                                                                     Sorts!



1 Group Access                          2

1 Group Index Access                                           Typical MySQL EXPLAIN               Project Results


                                                                     Sort


                                                                     Temp Table
                  1
                                                                     2 Joins


                                                                                               2 Table Accesses




                                                                                               3 Index Accesses

                  Akiban Technologies, Inc. Confidential & Proprietary
Design Partner Acceleration: 27x




                    Concurrent Connections


Akiban Technologies, Inc. Confidential & Proprietary   18
Object Creation Query Stream

SELECT     *   FROM       t1     Where        u.uid=1387
SELECT     *   FROM       t2     Where        as.uid=1387
SELECT     *   FROM       t3     Where        os.uid=1387
SELECT     *   FROM       t4     Where        pm.uid=1387
SELECT     *   FROM       t5     Where        pl.uid=1387
SELECT     *   FROM       t6     Where        pa.uid=1387
...
...




         Akiban Technologies, Inc. Confidential & Proprietary   19
Becomes Single ORM Request
SELECT * ,
  (SELECT * FROM t2 where as.uid=u.uid),
  (SELECT * FROM t3 where as.uid=u.uid),
      ...
FROM t1 Where u.uid=1387;



Or simply:

get my_schema:t1:uid=1387




Akiban Technologies, Inc. Confidential & Proprietary   20
Object Access in One Request




Akiban Technologies, Inc. Confidential & Proprietary   21
Application Integration


Data replicated to Akiban                                                         Fully independent server

                                   HA Redirect Enabled
               MySQL Master                                                      Akiban Server




                                                             MySQL adapter
                                          Replication




             MyISAM / InnoDB
                 Storage




          Write Operations                                                   Problem Queries
               Akiban Technologies, Inc. Confidential & Proprietary                                   22
Akiban is looking for Design Partners!

Do you have
•  Slow multi-join read queries?
•  User concurrency or data volume challenges?

http://www.akiban.com/design-partner-program




          Akiban Technologies, Inc. Confidential & Proprietary   23
Ah, so you’re…
Denormalizing…no.
    -  Schema doesn’t change
    -  Data is stored once, more efficiently
Materializing Views…no.
    -  No triggers or post-processing
    -  No 2ndary logical objects
Introducing Write Latency…no.
    -  Previous design partner showed 2x write
          improvement

Akiban Technologies, Inc. Confidential & Proprietary   24
Table-Grouping: A Closer Look

Artist                                Each table maintains its own bTree
   id     name       gender


                                      Indexes add their own bTrees
   1     Lennon        M
                                                 •  Covering index
   2      Joplin        F
                                                 •  Index on frequently joined columns
   Covering
                                                 •  Index on common sort order
    Index
          Join Cols
            Index Sort
                   Order
                    Index
                                      How many indexes do you maintain?
                                                 •  Slow updates == reduced concurrency
          Table                                  •  More resources == more overhead
          bTree
                                                 •  Ongoing maintenance == high TCO

                      Akiban Technologies, Inc. Confidential & Proprietary                25

Contenu connexe

Tendances

Cassandra 3.0 advanced preview
Cassandra 3.0 advanced previewCassandra 3.0 advanced preview
Cassandra 3.0 advanced previewPatrick McFadin
 
Indexing in Exadata
Indexing in ExadataIndexing in Exadata
Indexing in ExadataEnkitec
 
Replication Tips & Trick for SMUG
Replication Tips & Trick for SMUGReplication Tips & Trick for SMUG
Replication Tips & Trick for SMUGMats Kindahl
 
Introduction to data modeling with apache cassandra
Introduction to data modeling with apache cassandraIntroduction to data modeling with apache cassandra
Introduction to data modeling with apache cassandraPatrick McFadin
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptChien Chung Shen
 
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
 Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo... Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...Enkitec
 
How History Justifies System Architecture (or Not)
How History Justifies System Architecture (or Not)How History Justifies System Architecture (or Not)
How History Justifies System Architecture (or Not)Thomas Zimmermann
 
Replication Tips & Tricks
Replication Tips & TricksReplication Tips & Tricks
Replication Tips & TricksMats Kindahl
 
MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011Mats Kindahl
 
Multi thread slave_performance_on_opc
Multi thread slave_performance_on_opcMulti thread slave_performance_on_opc
Multi thread slave_performance_on_opcShinya Sugiyama
 
Top five questions to ask when choosing a big data solution
Top five questions to ask when choosing a big data solutionTop five questions to ask when choosing a big data solution
Top five questions to ask when choosing a big data solutionjbellis
 
Oracle Database Management Basic 1
Oracle Database Management Basic 1Oracle Database Management Basic 1
Oracle Database Management Basic 1Chien Chung Shen
 
Storing time series data with Apache Cassandra
Storing time series data with Apache CassandraStoring time series data with Apache Cassandra
Storing time series data with Apache CassandraPatrick McFadin
 
Oracle 10g Performance: chapter 05 waits intro
Oracle 10g Performance: chapter 05 waits introOracle 10g Performance: chapter 05 waits intro
Oracle 10g Performance: chapter 05 waits introKyle Hailey
 
Overview of Optimizer Features in 5.6 and 5.7-Manyi Lu
Overview of Optimizer Features in 5.6 and 5.7-Manyi LuOverview of Optimizer Features in 5.6 and 5.7-Manyi Lu
Overview of Optimizer Features in 5.6 and 5.7-Manyi Lu郁萍 王
 
Oracle Exadata 1Z0-485 Certification
Oracle Exadata 1Z0-485 CertificationOracle Exadata 1Z0-485 Certification
Oracle Exadata 1Z0-485 CertificationExadatadba
 
Cassandra presentation at NoSQL
Cassandra presentation at NoSQLCassandra presentation at NoSQL
Cassandra presentation at NoSQLEvan Weaver
 

Tendances (17)

Cassandra 3.0 advanced preview
Cassandra 3.0 advanced previewCassandra 3.0 advanced preview
Cassandra 3.0 advanced preview
 
Indexing in Exadata
Indexing in ExadataIndexing in Exadata
Indexing in Exadata
 
Replication Tips & Trick for SMUG
Replication Tips & Trick for SMUGReplication Tips & Trick for SMUG
Replication Tips & Trick for SMUG
 
Introduction to data modeling with apache cassandra
Introduction to data modeling with apache cassandraIntroduction to data modeling with apache cassandra
Introduction to data modeling with apache cassandra
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning Concept
 
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
 Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo... Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
 
How History Justifies System Architecture (or Not)
How History Justifies System Architecture (or Not)How History Justifies System Architecture (or Not)
How History Justifies System Architecture (or Not)
 
Replication Tips & Tricks
Replication Tips & TricksReplication Tips & Tricks
Replication Tips & Tricks
 
MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011
 
Multi thread slave_performance_on_opc
Multi thread slave_performance_on_opcMulti thread slave_performance_on_opc
Multi thread slave_performance_on_opc
 
Top five questions to ask when choosing a big data solution
Top five questions to ask when choosing a big data solutionTop five questions to ask when choosing a big data solution
Top five questions to ask when choosing a big data solution
 
Oracle Database Management Basic 1
Oracle Database Management Basic 1Oracle Database Management Basic 1
Oracle Database Management Basic 1
 
Storing time series data with Apache Cassandra
Storing time series data with Apache CassandraStoring time series data with Apache Cassandra
Storing time series data with Apache Cassandra
 
Oracle 10g Performance: chapter 05 waits intro
Oracle 10g Performance: chapter 05 waits introOracle 10g Performance: chapter 05 waits intro
Oracle 10g Performance: chapter 05 waits intro
 
Overview of Optimizer Features in 5.6 and 5.7-Manyi Lu
Overview of Optimizer Features in 5.6 and 5.7-Manyi LuOverview of Optimizer Features in 5.6 and 5.7-Manyi Lu
Overview of Optimizer Features in 5.6 and 5.7-Manyi Lu
 
Oracle Exadata 1Z0-485 Certification
Oracle Exadata 1Z0-485 CertificationOracle Exadata 1Z0-485 Certification
Oracle Exadata 1Z0-485 Certification
 
Cassandra presentation at NoSQL
Cassandra presentation at NoSQLCassandra presentation at NoSQL
Cassandra presentation at NoSQL
 

Similaire à Solving Performance Problems in MySQL Without Denormalization

MySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion QueriesMySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion QueriesBernd Ocklin
 
Breakthrough performance with MySQL Cluster (2012)
Breakthrough performance with MySQL Cluster (2012)Breakthrough performance with MySQL Cluster (2012)
Breakthrough performance with MySQL Cluster (2012)Frazer Clement
 
Conference slides: MySQL Cluster Performance Tuning
Conference slides: MySQL Cluster Performance TuningConference slides: MySQL Cluster Performance Tuning
Conference slides: MySQL Cluster Performance TuningSeveralnines
 
NewSQL Database Overview
NewSQL Database OverviewNewSQL Database Overview
NewSQL Database OverviewSteve Min
 
oracle 9i cheat sheet
oracle 9i cheat sheetoracle 9i cheat sheet
oracle 9i cheat sheetPiyush Mittal
 
Python Utilities for Managing MySQL Databases
Python Utilities for Managing MySQL DatabasesPython Utilities for Managing MySQL Databases
Python Utilities for Managing MySQL DatabasesMats Kindahl
 
Building and deploying large scale real time news system with my sql and dist...
Building and deploying large scale real time news system with my sql and dist...Building and deploying large scale real time news system with my sql and dist...
Building and deploying large scale real time news system with my sql and dist...Tao Cheng
 
20141011 my sql clusterv01pptx
20141011 my sql clusterv01pptx20141011 my sql clusterv01pptx
20141011 my sql clusterv01pptxIvan Ma
 
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...Trivadis
 
Oracle SQL Basics by Ankur Raina
Oracle SQL Basics by Ankur RainaOracle SQL Basics by Ankur Raina
Oracle SQL Basics by Ankur RainaAnkur Raina
 
OracleStore: A Highly Performant RawStore Implementation for Hive Metastore
OracleStore: A Highly Performant RawStore Implementation for Hive MetastoreOracleStore: A Highly Performant RawStore Implementation for Hive Metastore
OracleStore: A Highly Performant RawStore Implementation for Hive MetastoreDataWorks Summit
 
MySQL cluster 72 in the Cloud
MySQL cluster 72 in the CloudMySQL cluster 72 in the Cloud
MySQL cluster 72 in the CloudMarco Tusa
 
Jan Steemann: Modelling data in a schema free world (Talk held at Froscon, 2...
Jan Steemann: Modelling data in a schema free world  (Talk held at Froscon, 2...Jan Steemann: Modelling data in a schema free world  (Talk held at Froscon, 2...
Jan Steemann: Modelling data in a schema free world (Talk held at Froscon, 2...ArangoDB Database
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersJonathan Levin
 
Postgres indexing and toward big data application
Postgres indexing and toward big data applicationPostgres indexing and toward big data application
Postgres indexing and toward big data application柏瑀 黃
 

Similaire à Solving Performance Problems in MySQL Without Denormalization (20)

orical
oricalorical
orical
 
MySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion QueriesMySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion Queries
 
Breakthrough performance with MySQL Cluster (2012)
Breakthrough performance with MySQL Cluster (2012)Breakthrough performance with MySQL Cluster (2012)
Breakthrough performance with MySQL Cluster (2012)
 
Conference slides: MySQL Cluster Performance Tuning
Conference slides: MySQL Cluster Performance TuningConference slides: MySQL Cluster Performance Tuning
Conference slides: MySQL Cluster Performance Tuning
 
NewSQL Database Overview
NewSQL Database OverviewNewSQL Database Overview
NewSQL Database Overview
 
oracle 9i cheat sheet
oracle 9i cheat sheetoracle 9i cheat sheet
oracle 9i cheat sheet
 
Python Utilities for Managing MySQL Databases
Python Utilities for Managing MySQL DatabasesPython Utilities for Managing MySQL Databases
Python Utilities for Managing MySQL Databases
 
Building and deploying large scale real time news system with my sql and dist...
Building and deploying large scale real time news system with my sql and dist...Building and deploying large scale real time news system with my sql and dist...
Building and deploying large scale real time news system with my sql and dist...
 
SQLFire at Strata 2012
SQLFire at Strata 2012SQLFire at Strata 2012
SQLFire at Strata 2012
 
20141011 my sql clusterv01pptx
20141011 my sql clusterv01pptx20141011 my sql clusterv01pptx
20141011 my sql clusterv01pptx
 
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...
Trivadis TechEvent 2017 Oracle to My SQL Migration - Challenges by Robert Bia...
 
SQLFire Webinar
SQLFire WebinarSQLFire Webinar
SQLFire Webinar
 
Oracle SQL Basics by Ankur Raina
Oracle SQL Basics by Ankur RainaOracle SQL Basics by Ankur Raina
Oracle SQL Basics by Ankur Raina
 
OracleStore: A Highly Performant RawStore Implementation for Hive Metastore
OracleStore: A Highly Performant RawStore Implementation for Hive MetastoreOracleStore: A Highly Performant RawStore Implementation for Hive Metastore
OracleStore: A Highly Performant RawStore Implementation for Hive Metastore
 
What's New in Apache Hive
What's New in Apache HiveWhat's New in Apache Hive
What's New in Apache Hive
 
MySQL cluster 72 in the Cloud
MySQL cluster 72 in the CloudMySQL cluster 72 in the Cloud
MySQL cluster 72 in the Cloud
 
Jan Steemann: Modelling data in a schema free world (Talk held at Froscon, 2...
Jan Steemann: Modelling data in a schema free world  (Talk held at Froscon, 2...Jan Steemann: Modelling data in a schema free world  (Talk held at Froscon, 2...
Jan Steemann: Modelling data in a schema free world (Talk held at Froscon, 2...
 
My sql tutorial-oscon-2012
My sql tutorial-oscon-2012My sql tutorial-oscon-2012
My sql tutorial-oscon-2012
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for Developers
 
Postgres indexing and toward big data application
Postgres indexing and toward big data applicationPostgres indexing and toward big data application
Postgres indexing and toward big data application
 

Dernier

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Dernier (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

Solving Performance Problems in MySQL Without Denormalization

  • 1. Solving Performance Problems in MySQL Without Denormalization RENORMALIZE Akiban Technologies, Inc. Confidential & Proprietary
  • 2. Problem Statement Schemas scale out Data volume grows Joins become a real bottleneck Akiban Technologies, Inc. Confidential & Proprietary 2
  • 3. Two Common Manifestations SQL Joins Queries become slower as more tables are joined. Application Object Creations Constructing an object is as expensive as SELECTing the sum of its parts Denormalize. Problem solved. Akiban Technologies, Inc. Confidential & Proprietary 3
  • 4. Application Growing Pains Web Cache Server Server V6 Release V5 V4 V3 V1 V2 Rip & ReplaceDB Shard Database Add Customers! Get Caching Replicate DB De-normalize Complexity & Cost Customers MySQL Rip & Replace Database Architecture MySQL MySQL Slaves MySQL Sharding ? MySQL Time 4
  • 5. De·nor·mal·ize [de-nawr-muh-lahyze] verb, -ized, -iz·ing. –verb (used with object) 1.  the process of attempting to optimize the read performance of a database by adding redundant data or by grouping data wikipedia 2.  Denormalize means to allow redundancy in a table so that the table can remain flat UCSD Blink 3.  The process of restructuring a normalized data model to accommodate operational constraints or system limitations celiang.tongji.edu.cn Akiban Technologies, Inc. Confidential & Proprietary 5
  • 6. Materialized Views Persistent database object Contains the results of a query Store summary and pre-joined tables Require maintenance/refresh for dynamic data SELECT DISTINCT(n.nid),n.sticky,n.title,n.created FROM node n INNER JOIN term_node tn0 ON n.vid = tn0.vid WHERE n.status = 1 AND tn0.tid IN (77) ORDER BY n.sticky DESC, n.created DESC LIMIT 0, 25; Result: using where, using filesort Akiban Technologies, Inc. Confidential & Proprietary 6
  • 7. Drupal Materialized View Project CREATE TABLE `mv_drupalorg_node_by_term` ( `entity_type` varchar(64) NOT NULL, `entity_id` int(10) unsigned NOT NULL DEFAULT '0’, `term_tid` int(10) unsigned NOT NULL DEFAULT '0', `node_sticky` int(11) NOT NULL DEFAULT '0', `last_node_activity` int(11) NOT NULL DEFAULT '0', `node_created` int(11) NOT NULL DEFAULT '0', `node_title` varchar(255) NOT NULL DEFAULT '’, PRIMARY KEY (`entity_type`,`entity_id`,`term_tid`), KEY `activity` (`term_tid`,`node_sticky`,`last_node_activity`,`node_created`), KEY `creation` (`term_tid`,`node_sticky`,`node_created`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 SELECT DISTINCT entity_id AS nid, node_sticky AS sticky, node_title AS title, node_created AS created FROM mv_drupalorg_node_by_term WHERE term_tid IN (77) ORDER BY node_sticky DESC, node_created DESC LIMIT 0, 25; Result: using where, using temporary table Akiban Technologies, Inc. Confidential & Proprietary 7
  • 8. Denormalization Technique Listing Technique Pros Cons Materialized views Faster queries (no joins) Data explosion Manually keep synched Store object as Blob Fast object get No modeling, or querying Denormalize 1NF: Folding Data in one row limited # of child rows parent-child into parent table Hard to query (UNION hell) Denormalize 2NF to 1NF: repeat Avoid join Data explosion columns from 1 table in M table Manually keep synched (Double writing) Adding derived columns Avoid joins, aggregation Manually keep synched Property bag (RDF) Schema flexibility Manage schema in app Akiban Technologies, Inc. Confidential & Proprietary Hard to index or perform 8
  • 9. Renormalization Join for free - Improved performance. 10-100x! - Retrieve an object in one request Akiban Technologies, Inc. Confidential & Proprietary 9
  • 10. Introduction to Table-Groups Traditional SQL Schema à Table à Column Akiban newSQL Schema à GROUP à Table à Column Table-Groups are first class citizens Akiban Technologies, Inc. Confidential & Proprietary 10
  • 11. Typical Relational DB Schema Akiban Technologies, Inc. Confidential & Proprietary 11
  • 12. Typical Schema: Grouped Block Group User Group Node Group 12
  • 13. Table-Groups Eliminate Joins Logical Physical Users Users_Roles Sessions Artist Table-group uid name pass id rid id sid timestamp 1 rriegel *** 1 1 1 19390 2011-10-01-06:02.00 2 twegner *** 1 2 2 22828 2011-10-04-22:32.10 2 1 1 49377 2011-10-04-16:07.30 Table Group Table Table bTree bTree bTree Akiban Technologies, Inc. Confidential & Proprietary 13
  • 14. Benefits of Table-grouping SQL join operations are fast -  Table Group access is equivalent to a single table access. Joins are free! -  Performance increases 10-100x Applications do not change -  Maintain the same tables and SQL -  Objects (e.g. ORM) fetched in one request -  Akiban uses standard MySQL replication Akiban Technologies, Inc. Confidential & Proprietary 14
  • 15. Design Partner Sample Query SELECT t1.id , t3.c1, t3.c2, t3.c3, t3.c4 FROM t1 INNER JOIN t2 on t2.id = t1.id LEFT JOIN t3 ON t1.id = t3.id WHERE t2.region in (1297789) AND t1.c1 = '0' ORDER BY t1.latestLogin DESC LIMIT 500 Akiban Technologies, Inc. Confidential & Proprietary 15
  • 16. Typical MySQL EXPLAIN Plan 10 Project Results Sort 9 Temp Table 8 2 Joins 7 4 6 2 Table Accesses 2 3 5 1 3 Index Accesses Akiban Technologies, Inc. Confidential & Proprietary
  • 17. Efficiency for Speed and Scale No Joins, Project Results 3 Temp Tables or Sorts! 1 Group Access 2 1 Group Index Access Typical MySQL EXPLAIN Project Results Sort Temp Table 1 2 Joins 2 Table Accesses 3 Index Accesses Akiban Technologies, Inc. Confidential & Proprietary
  • 18. Design Partner Acceleration: 27x Concurrent Connections Akiban Technologies, Inc. Confidential & Proprietary 18
  • 19. Object Creation Query Stream SELECT * FROM t1 Where u.uid=1387 SELECT * FROM t2 Where as.uid=1387 SELECT * FROM t3 Where os.uid=1387 SELECT * FROM t4 Where pm.uid=1387 SELECT * FROM t5 Where pl.uid=1387 SELECT * FROM t6 Where pa.uid=1387 ... ... Akiban Technologies, Inc. Confidential & Proprietary 19
  • 20. Becomes Single ORM Request SELECT * , (SELECT * FROM t2 where as.uid=u.uid), (SELECT * FROM t3 where as.uid=u.uid), ... FROM t1 Where u.uid=1387; Or simply: get my_schema:t1:uid=1387 Akiban Technologies, Inc. Confidential & Proprietary 20
  • 21. Object Access in One Request Akiban Technologies, Inc. Confidential & Proprietary 21
  • 22. Application Integration Data replicated to Akiban Fully independent server HA Redirect Enabled MySQL Master Akiban Server MySQL adapter Replication MyISAM / InnoDB Storage Write Operations Problem Queries Akiban Technologies, Inc. Confidential & Proprietary 22
  • 23. Akiban is looking for Design Partners! Do you have •  Slow multi-join read queries? •  User concurrency or data volume challenges? http://www.akiban.com/design-partner-program Akiban Technologies, Inc. Confidential & Proprietary 23
  • 24. Ah, so you’re… Denormalizing…no. -  Schema doesn’t change -  Data is stored once, more efficiently Materializing Views…no. -  No triggers or post-processing -  No 2ndary logical objects Introducing Write Latency…no. -  Previous design partner showed 2x write improvement Akiban Technologies, Inc. Confidential & Proprietary 24
  • 25. Table-Grouping: A Closer Look Artist Each table maintains its own bTree id name gender Indexes add their own bTrees 1 Lennon M •  Covering index 2 Joplin F •  Index on frequently joined columns Covering •  Index on common sort order Index Join Cols Index Sort Order Index How many indexes do you maintain? •  Slow updates == reduced concurrency Table •  More resources == more overhead bTree •  Ongoing maintenance == high TCO Akiban Technologies, Inc. Confidential & Proprietary 25