SlideShare a Scribd company logo
know more about MySQL open source database




                 Salaria Software Services   1
 Storage engines
 Schema
 Normalization
 Data types
 Indexes
 Know more about your SQL queries - Using EXPLAIN
 Character set and Collation
 Resources



                        Salaria Software Services    2
 Generics are inefficient
• If you have chosen MySQL, take advantage of its
   strengths
• Having an understanding of the database helps you
   develop better-performing applications
   better to design a well-performing database-driven
    application from the start
   than try to fix a slow one after the fact!




                           Salaria Software Services     3
 MySQL supports several
 storage engines that act
 as handlers for different
 table types
   No other database
    vendor offers this
    capability




                         Salaria Software Services   4
 Dynamically add and remove storage engines.
 Change the storage engine on a table with
   “ALTER TABLE <table> ENGINE=InnoDB;”




                        Salaria Software Services   5
 Concurrency: some have more granular locks than
  others
   right locking can improve performance.
• Storage: how the data is stored on disk
   page size for tables, indexes, format used
• Indexes: b-trees, hash
• Memory usage
   caching strategy
• Transactions:
   not every application table needs transactions

                           Salaria Software Services   6
“As a developer, what do I need to know
   about storage engines, without being a
              MySQL expert?”
• Keep in mind the following questions:
   What type of data will you be storing?
   Is the data constantly changing?
   Is the data mostly logs (INSERTs)?
   requirements for reports?
   need for transaction control?


                         Salaria Software Services   7
 Default MySQL engine
• high-speed Query and Insert capability
   insert uses shared read lock
   updates, deletes use table-level locking, slower
• full-text indexing
   Good for text search
• Non-transactional, No foreign key support
• good choice for :
   read-only or read-mostly application tables that don't
    require transactions
   Web, data warehousing, logging, auditing

                           Salaria Software Services         8
 Transaction-safe and ACID
  (atomicity, consistency, isolation, durability) compliant
   crash recovery, foreign key constraints
• good query performance, depending on indexes
• row-level locking, Multi Version Concurrency Control
   (MVCC)
   allows fewer row locks by keeping data snapshots
     – Depending on the isolation level, no locking for SELECT
     – high concurrency possible
• uses more disk space and memory than ISAM
• Good for Online transaction processing (OLTP)
   Lots of users: eBay, Google, Yahoo!, Facebook, etc.


                              Salaria Software Services          9
 Entirely in-memory engine
   stores all data in RAM for extremely fast access
   Updated Data is not persisted
     – table loaded on restart
• Hash index used by default
• Good for
   Summary and transient data
   "lookup" tables,
   calculated table counts,
   for caching, temporary tables


                          Salaria Software Services    10
 Incredible insert speeds
• Great compression rates (zlib)?
   Typically 6-8x smaller than MyISAM
• No UPDATEs
• Ideal for storing and retrieving large amounts of
   historical data
   audit data, log files,Web traffic records
   Data that can never be updated




                          Salaria Software Services   11
 You can use multiple
  storage engines in a
  single application
   A storage engine for the
    same table on a slave can
    be different than that of
    the master
• Choose storage engine
   that's best for your
   applications requirements
   can greatly improve
    performance

                           Salaria Software Services   12
 Creating a table with a specified engine
   CREATE TABLE t1 (...)
    ENGINE=InnoDB;
• Changing existing tables
   ALTER TABLE t1 ENGINE=MyISAM;
• Finding all your available engines
   SHOW STORAGE ENGINES;




                         Salaria Software Services   13
Basic foundation of performance
• Normalization
• Data Types
   Smaller, smaller, smaller
     - Smaller tables use less disk, less memory, can give better
        performance
• Indexing
   Speeds up retrieval




                             Salaria Software Services              14
 Eliminate redundant data:
   Don't store the same data in more than one table
   Only store related data in a table
   reduces database size and errors




                          Salaria Software Services    15
 updates are usually faster.
   there's less data to change.
• tables are usually smaller, use less memory, which
   can give better performance.
• better performance for distinct or group by queries




                          Salaria Software Services     16
 However Normalized database causes joins for queries
• excessively normalized database:
   queries take more time to complete, as data has to be
    retrieved from more tables.
• Normalized better for writes OLTP
• De-normalized better for reads , reporting
• Real World Mixture:
   normalized schema
   Cache selected columns in memory table



                         Salaria Software Services          17
Smaller => less disk => less memory => better
 performance

 Use the smallest data type possible
• The smaller your data types, The more index (and data)
  can fit into a block of memory, the faster your queries
  will be.
   Period.
   Especially for indexed fields



                          Salaria Software Services         18
 MySQL has 9 numeric data types
    Compared to Oracle's 1
• Integer:
    TINYINT , SMALLINT, MEDIUMINT, INT, BIGINT
    Require 8, 16, 24, 32, and 64 bits of space.
• Use UNSIGNED when you don't need negative numbers – one more level of data
   integrity
• BIGINT is not needed for AUTO_INCREMENT
    INT UNSIGNED stores 4.3 billion values!
    Summation of values... yes, use BIGINT
 Floating Point: FLOAT, DOUBLE
    Approximate calculations
• Fixed Point: DECIMAL
    Always use DECIMAL for monetary/currency fields, never use FLOAT or
      DOUBLE!
• Other: BIT
    Store 0,1 values

                                  Salaria Software Services                    19
 VARCHAR(n) variable length
   uses only space it needs
     – Can save disk space = better performance
   Use :
    – Max column length > avg
    – when updates rare (updates fragment)
• CHAR(n) fixed length
   Use:
     – short strings, Mostly same length, or changed frequently




                            Salaria Software Services             20
 Always define columns as NOT NULL
     – unless there is a good reason not to
   Can save a byte per column
   nullable columns make indexes, index statistics, and
    value comparisons more complicated.
• Use the same data types for columns that will be
  compared in JOINs
   Otherwise converted for comparison
• Use BLOBs very sparingly
   Use the filesystem for what it was intended


                          Salaria Software Services        21
“The more records you can fit into a single page of
  memory/disk, the faster your seeks and scans will be.”
• Use appropriate data types
• Keep primary keys small
• Use TEXT sparingly
   Consider separate tables
• Use BLOBs very sparingly
   Use the filesystem for what it was intended




                         Salaria Software Services         22
 Indexes Speed up Queries,
   SELECT...WHERE name = 'carol'
   only if there is good selectivity:
     – % of distinct values in a column
• But... each index will slow down INSERT, UPDATE, and
  DELETE operations




                            Salaria Software Services    23
 Always have an index on join conditions
• Look to add indexes on columns used in WHERE and
  GROUP BY expressions
• PRIMARY KEY, UNIQUE , and Foreign key Constraint
  columns are automatically indexed.
   other columns can be indexed (CREATE INDEX..)




                       Salaria Software Services     24
 use the MySQL slow query log and use Explain
• Append EXPLAIN to your SELECT statement
   shows how the MySQL optimizer has chosen to execute
    the query
• You Want to make your queries access less data:
   are queries accessing too many rows or columns?
     – select only the columns that you need
• Use to see where you should add indexes
   Consider adding an index for slow queries or cause a lot
    of load.
     – ensures that missing indexes are picked up early in the
       development process

                            Salaria Software Services            25
 Find and fix problem SQL:
• how long a query took
• how the optimizer handled it
   Drill downs, results of EXPLAIN statements
• Historical and real-time analysis
   query execution counts, run time


  “Its not just slow running queries that are a problem,
  Sometimes its SQL that executes a lot that kills your
                          system”

                         Salaria Software Services         26
 Just append EXPLAIN to
   your SELECT statement
• Provides the execution plan
   chosen by the MySQL
   optimizer for a specific
   SELECT statement
   Shows how the MySQL
    optimizer executes the
    query
• Use to see where you should
  add indexes
   ensures that missing
    indexes are picked up early
    in the development
    process
                             Salaria Software Services   27
 A character set is a set of symbols and encodings.
 A collation is a set of rules for comparing characters in a
  character set.
 MySQL can do these things for you:
   Store strings using a variety of character sets
   Compare strings using a variety of collations
   Mix strings with different character sets or collations in the
    same server, the same database, or even the same table
   Allow specification of character set and collation at any level
      - Mysql > SET NAMES 'utf8';
      - Mysql > SHOW CHARACTER SET


                             Salaria Software Services                28
 Two different character sets cannot have the same
  collation.
 Each character set has one collation that is the default
  collation. For example, the default collation for latin1 is
  latin1_swedish_ci. The output for “SHOW CHARACTER
  SET” indicates which collation is the default for each
  displayed character set.
 There is a convention for collation names: They start with
  the name of the character set with which they are
  associated, they usually include a language name, and they
  end with _ci (case insensitive), _cs (case sensitive), or _bin
  (binary).

                           Salaria Software Services               29
 <meta http-equiv="Content-Type" content="text/html;
  charset=utf-8" />
 <?php mysql_query('SET NAMES utf8'); ?>
 CREATE DATABASE mydatabase DEFAULT CHARACTER
  SET utf8 COLLATE utf8_general_ci;
 CREATE TABLE mytable (
    mydata VARCHAR(128) NOT NULL
  ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8
  COLLATE utf8_general_ci;



                        Salaria Software Services       30
 MySQL Forge and the Forge Wiki
http://forge.mysql.com/
 Planet MySQL
 http://planetmysql.org/
 MySQL DevZone
http://dev.mysql.com/
 High Performance MySQL book




                      Salaria Software Services   31
?

Salaria Software Services   32
Mahesh Salaria
  mahesh@salaria.net
Salaria Software Services
 http://salariasoft.com
      Salaria Software Services   33

More Related Content

What's hot

SQL Server 2016 Editions
SQL Server 2016 Editions SQL Server 2016 Editions
SQL Server 2016 Editions
Onomi
 
Optimization SQL Server for Dynamics AX 2012 R3
Optimization SQL Server for Dynamics AX 2012 R3Optimization SQL Server for Dynamics AX 2012 R3
Optimization SQL Server for Dynamics AX 2012 R3
Juan Fabian
 
SQL Server 2016 novelties
SQL Server 2016 noveltiesSQL Server 2016 novelties
SQL Server 2016 novelties
MSDEVMTL
 
SQL Server 2016 BI updates
SQL Server 2016 BI updatesSQL Server 2016 BI updates
SQL Server 2016 BI updates
Chris Testa-O'Neill
 
SQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and EnhancementsSQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and Enhancements
John Martin
 
Star schema my sql
Star schema   my sqlStar schema   my sql
Star schema my sql
deathsubte
 
Sql 2016 - What's New
Sql 2016 - What's NewSql 2016 - What's New
Sql 2016 - What's New
dpcobb
 
Everything you need to know about SQL Server 2016
Everything you need to know about SQL Server 2016Everything you need to know about SQL Server 2016
Everything you need to know about SQL Server 2016
Softchoice Corporation
 
Real Time Operational Analytics with Microsoft Sql Server 2016 [Liviu Ieran]
Real Time Operational Analytics with Microsoft Sql Server 2016 [Liviu Ieran]Real Time Operational Analytics with Microsoft Sql Server 2016 [Liviu Ieran]
Real Time Operational Analytics with Microsoft Sql Server 2016 [Liviu Ieran]
ITCamp
 
SQL server 2016 New Features
SQL server 2016 New FeaturesSQL server 2016 New Features
SQL server 2016 New Features
aminmesbahi
 
Student projects with open source CSQL
Student projects with open source CSQLStudent projects with open source CSQL
Student projects with open source CSQL
Prabakaran Thirumalai
 
Exploring sql server 2016
Exploring sql server 2016Exploring sql server 2016
Exploring sql server 2016
Antonios Chatzipavlis
 
Scalable relational database with SQL Azure
Scalable relational database with SQL AzureScalable relational database with SQL Azure
Scalable relational database with SQL Azure
Shy Engelberg
 
Redshift deep dive
Redshift deep diveRedshift deep dive
Redshift deep dive
Amazon Web Services LATAM
 
Monitorando performance no Azure SQL Database
Monitorando performance no Azure SQL DatabaseMonitorando performance no Azure SQL Database
Monitorando performance no Azure SQL Database
Vitor Fava
 
Introduction to Azure Data Lake
Introduction to Azure Data LakeIntroduction to Azure Data Lake
Introduction to Azure Data Lake
Antonios Chatzipavlis
 
SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2
sqlserver.co.il
 
Sql server 2016 new features
Sql server 2016 new featuresSql server 2016 new features
Sql server 2016 new features
Ajeet Singh
 
Exploring T-SQL Anti-Patterns
Exploring T-SQL Anti-Patterns Exploring T-SQL Anti-Patterns
Exploring T-SQL Anti-Patterns
Antonios Chatzipavlis
 
Using extended events for troubleshooting sql server
Using extended events for troubleshooting sql serverUsing extended events for troubleshooting sql server
Using extended events for troubleshooting sql server
Antonios Chatzipavlis
 

What's hot (20)

SQL Server 2016 Editions
SQL Server 2016 Editions SQL Server 2016 Editions
SQL Server 2016 Editions
 
Optimization SQL Server for Dynamics AX 2012 R3
Optimization SQL Server for Dynamics AX 2012 R3Optimization SQL Server for Dynamics AX 2012 R3
Optimization SQL Server for Dynamics AX 2012 R3
 
SQL Server 2016 novelties
SQL Server 2016 noveltiesSQL Server 2016 novelties
SQL Server 2016 novelties
 
SQL Server 2016 BI updates
SQL Server 2016 BI updatesSQL Server 2016 BI updates
SQL Server 2016 BI updates
 
SQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and EnhancementsSQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and Enhancements
 
Star schema my sql
Star schema   my sqlStar schema   my sql
Star schema my sql
 
Sql 2016 - What's New
Sql 2016 - What's NewSql 2016 - What's New
Sql 2016 - What's New
 
Everything you need to know about SQL Server 2016
Everything you need to know about SQL Server 2016Everything you need to know about SQL Server 2016
Everything you need to know about SQL Server 2016
 
Real Time Operational Analytics with Microsoft Sql Server 2016 [Liviu Ieran]
Real Time Operational Analytics with Microsoft Sql Server 2016 [Liviu Ieran]Real Time Operational Analytics with Microsoft Sql Server 2016 [Liviu Ieran]
Real Time Operational Analytics with Microsoft Sql Server 2016 [Liviu Ieran]
 
SQL server 2016 New Features
SQL server 2016 New FeaturesSQL server 2016 New Features
SQL server 2016 New Features
 
Student projects with open source CSQL
Student projects with open source CSQLStudent projects with open source CSQL
Student projects with open source CSQL
 
Exploring sql server 2016
Exploring sql server 2016Exploring sql server 2016
Exploring sql server 2016
 
Scalable relational database with SQL Azure
Scalable relational database with SQL AzureScalable relational database with SQL Azure
Scalable relational database with SQL Azure
 
Redshift deep dive
Redshift deep diveRedshift deep dive
Redshift deep dive
 
Monitorando performance no Azure SQL Database
Monitorando performance no Azure SQL DatabaseMonitorando performance no Azure SQL Database
Monitorando performance no Azure SQL Database
 
Introduction to Azure Data Lake
Introduction to Azure Data LakeIntroduction to Azure Data Lake
Introduction to Azure Data Lake
 
SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2
 
Sql server 2016 new features
Sql server 2016 new featuresSql server 2016 new features
Sql server 2016 new features
 
Exploring T-SQL Anti-Patterns
Exploring T-SQL Anti-Patterns Exploring T-SQL Anti-Patterns
Exploring T-SQL Anti-Patterns
 
Using extended events for troubleshooting sql server
Using extended events for troubleshooting sql serverUsing extended events for troubleshooting sql server
Using extended events for troubleshooting sql server
 

Viewers also liked

Test Driven Development and Automation
Test Driven Development and AutomationTest Driven Development and Automation
Test Driven Development and Automation
Mahesh Salaria
 
Drupal8 render pipeline
Drupal8 render pipelineDrupal8 render pipeline
Drupal8 render pipeline
Mahesh Salaria
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
Rogério Vicente
 
TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25
Jeremy Kendall
 
Hackathon @Kayako
Hackathon @KayakoHackathon @Kayako
Hackathon @Kayako
Mahesh Salaria
 
Clean code and Coding Standards
Clean code and Coding StandardsClean code and Coding Standards
Clean code and Coding Standards
Mahesh Salaria
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
Luminary Labs
 

Viewers also liked (7)

Test Driven Development and Automation
Test Driven Development and AutomationTest Driven Development and Automation
Test Driven Development and Automation
 
Drupal8 render pipeline
Drupal8 render pipelineDrupal8 render pipeline
Drupal8 render pipeline
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
 
TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25
 
Hackathon @Kayako
Hackathon @KayakoHackathon @Kayako
Hackathon @Kayako
 
Clean code and Coding Standards
Clean code and Coding StandardsClean code and Coding Standards
Clean code and Coding Standards
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Similar to MySQL: Know more about open Source Database

Mysql For Developers
Mysql For DevelopersMysql For Developers
Mysql For Developers
Carol McDonald
 
25 snowflake
25 snowflake25 snowflake
25 snowflake
剑飞 陈
 
Azure data platform overview
Azure data platform overviewAzure data platform overview
Azure data platform overview
Alessandro Melchiori
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
ColdFusionConference
 
Technical Introduction to PostgreSQL and PPAS
Technical Introduction to PostgreSQL and PPASTechnical Introduction to PostgreSQL and PPAS
Technical Introduction to PostgreSQL and PPAS
Ashnikbiz
 
Powering GIS Application with PostgreSQL and Postgres Plus
Powering GIS Application with PostgreSQL and Postgres Plus Powering GIS Application with PostgreSQL and Postgres Plus
Powering GIS Application with PostgreSQL and Postgres Plus
Ashnikbiz
 
MySQL :What's New #GIDS16
MySQL :What's New #GIDS16MySQL :What's New #GIDS16
MySQL :What's New #GIDS16
Sanjay Manwani
 
Database storage engines
Database storage enginesDatabase storage engines
Database storage engines
University of Sindh, Jamshoro
 
Nosql data models
Nosql data modelsNosql data models
Nosql data models
Viet-Trung TRAN
 
(ISM303) Migrating Your Enterprise Data Warehouse To Amazon Redshift
(ISM303) Migrating Your Enterprise Data Warehouse To Amazon Redshift(ISM303) Migrating Your Enterprise Data Warehouse To Amazon Redshift
(ISM303) Migrating Your Enterprise Data Warehouse To Amazon Redshift
Amazon Web Services
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
Amazon Web Services
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
Amazon Web Services
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
Rajesh Gunasundaram
 
AWS Webcast - Backup & Restore for ElastiCache/Redis: Getting Started & Best ...
AWS Webcast - Backup & Restore for ElastiCache/Redis: Getting Started & Best ...AWS Webcast - Backup & Restore for ElastiCache/Redis: Getting Started & Best ...
AWS Webcast - Backup & Restore for ElastiCache/Redis: Getting Started & Best ...
Amazon Web Services
 
Handling Massive Writes
Handling Massive WritesHandling Massive Writes
Handling Massive Writes
Liran Zelkha
 
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
Amazon Web Services
 
amazon database
amazon databaseamazon database
amazon database
PrasannaBhalerao3
 
MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014
Ryusuke Kajiyama
 
Oracle Database in-Memory Overivew
Oracle Database in-Memory OverivewOracle Database in-Memory Overivew
Oracle Database in-Memory Overivew
Maria Colgan
 
Best Practices – Extreme Performance with Data Warehousing on Oracle Databa...
Best Practices –  Extreme Performance with Data Warehousing  on Oracle Databa...Best Practices –  Extreme Performance with Data Warehousing  on Oracle Databa...
Best Practices – Extreme Performance with Data Warehousing on Oracle Databa...
Edgar Alejandro Villegas
 

Similar to MySQL: Know more about open Source Database (20)

Mysql For Developers
Mysql For DevelopersMysql For Developers
Mysql For Developers
 
25 snowflake
25 snowflake25 snowflake
25 snowflake
 
Azure data platform overview
Azure data platform overviewAzure data platform overview
Azure data platform overview
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
Technical Introduction to PostgreSQL and PPAS
Technical Introduction to PostgreSQL and PPASTechnical Introduction to PostgreSQL and PPAS
Technical Introduction to PostgreSQL and PPAS
 
Powering GIS Application with PostgreSQL and Postgres Plus
Powering GIS Application with PostgreSQL and Postgres Plus Powering GIS Application with PostgreSQL and Postgres Plus
Powering GIS Application with PostgreSQL and Postgres Plus
 
MySQL :What's New #GIDS16
MySQL :What's New #GIDS16MySQL :What's New #GIDS16
MySQL :What's New #GIDS16
 
Database storage engines
Database storage enginesDatabase storage engines
Database storage engines
 
Nosql data models
Nosql data modelsNosql data models
Nosql data models
 
(ISM303) Migrating Your Enterprise Data Warehouse To Amazon Redshift
(ISM303) Migrating Your Enterprise Data Warehouse To Amazon Redshift(ISM303) Migrating Your Enterprise Data Warehouse To Amazon Redshift
(ISM303) Migrating Your Enterprise Data Warehouse To Amazon Redshift
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
 
AWS Webcast - Backup & Restore for ElastiCache/Redis: Getting Started & Best ...
AWS Webcast - Backup & Restore for ElastiCache/Redis: Getting Started & Best ...AWS Webcast - Backup & Restore for ElastiCache/Redis: Getting Started & Best ...
AWS Webcast - Backup & Restore for ElastiCache/Redis: Getting Started & Best ...
 
Handling Massive Writes
Handling Massive WritesHandling Massive Writes
Handling Massive Writes
 
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
 
amazon database
amazon databaseamazon database
amazon database
 
MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014
 
Oracle Database in-Memory Overivew
Oracle Database in-Memory OverivewOracle Database in-Memory Overivew
Oracle Database in-Memory Overivew
 
Best Practices – Extreme Performance with Data Warehousing on Oracle Databa...
Best Practices –  Extreme Performance with Data Warehousing  on Oracle Databa...Best Practices –  Extreme Performance with Data Warehousing  on Oracle Databa...
Best Practices – Extreme Performance with Data Warehousing on Oracle Databa...
 

Recently uploaded

Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 

Recently uploaded (20)

Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 

MySQL: Know more about open Source Database

  • 1. know more about MySQL open source database Salaria Software Services 1
  • 2.  Storage engines  Schema  Normalization  Data types  Indexes  Know more about your SQL queries - Using EXPLAIN  Character set and Collation  Resources Salaria Software Services 2
  • 3.  Generics are inefficient • If you have chosen MySQL, take advantage of its strengths • Having an understanding of the database helps you develop better-performing applications  better to design a well-performing database-driven application from the start  than try to fix a slow one after the fact! Salaria Software Services 3
  • 4.  MySQL supports several storage engines that act as handlers for different table types  No other database vendor offers this capability Salaria Software Services 4
  • 5.  Dynamically add and remove storage engines.  Change the storage engine on a table with “ALTER TABLE <table> ENGINE=InnoDB;” Salaria Software Services 5
  • 6.  Concurrency: some have more granular locks than others  right locking can improve performance. • Storage: how the data is stored on disk  page size for tables, indexes, format used • Indexes: b-trees, hash • Memory usage  caching strategy • Transactions:  not every application table needs transactions Salaria Software Services 6
  • 7. “As a developer, what do I need to know about storage engines, without being a MySQL expert?” • Keep in mind the following questions:  What type of data will you be storing?  Is the data constantly changing?  Is the data mostly logs (INSERTs)?  requirements for reports?  need for transaction control? Salaria Software Services 7
  • 8.  Default MySQL engine • high-speed Query and Insert capability  insert uses shared read lock  updates, deletes use table-level locking, slower • full-text indexing  Good for text search • Non-transactional, No foreign key support • good choice for :  read-only or read-mostly application tables that don't require transactions  Web, data warehousing, logging, auditing Salaria Software Services 8
  • 9.  Transaction-safe and ACID (atomicity, consistency, isolation, durability) compliant  crash recovery, foreign key constraints • good query performance, depending on indexes • row-level locking, Multi Version Concurrency Control (MVCC)  allows fewer row locks by keeping data snapshots – Depending on the isolation level, no locking for SELECT – high concurrency possible • uses more disk space and memory than ISAM • Good for Online transaction processing (OLTP)  Lots of users: eBay, Google, Yahoo!, Facebook, etc. Salaria Software Services 9
  • 10.  Entirely in-memory engine  stores all data in RAM for extremely fast access  Updated Data is not persisted – table loaded on restart • Hash index used by default • Good for  Summary and transient data  "lookup" tables,  calculated table counts,  for caching, temporary tables Salaria Software Services 10
  • 11.  Incredible insert speeds • Great compression rates (zlib)?  Typically 6-8x smaller than MyISAM • No UPDATEs • Ideal for storing and retrieving large amounts of historical data  audit data, log files,Web traffic records  Data that can never be updated Salaria Software Services 11
  • 12.  You can use multiple storage engines in a single application  A storage engine for the same table on a slave can be different than that of the master • Choose storage engine that's best for your applications requirements  can greatly improve performance Salaria Software Services 12
  • 13.  Creating a table with a specified engine  CREATE TABLE t1 (...) ENGINE=InnoDB; • Changing existing tables  ALTER TABLE t1 ENGINE=MyISAM; • Finding all your available engines  SHOW STORAGE ENGINES; Salaria Software Services 13
  • 14. Basic foundation of performance • Normalization • Data Types  Smaller, smaller, smaller - Smaller tables use less disk, less memory, can give better performance • Indexing  Speeds up retrieval Salaria Software Services 14
  • 15.  Eliminate redundant data:  Don't store the same data in more than one table  Only store related data in a table  reduces database size and errors Salaria Software Services 15
  • 16.  updates are usually faster.  there's less data to change. • tables are usually smaller, use less memory, which can give better performance. • better performance for distinct or group by queries Salaria Software Services 16
  • 17.  However Normalized database causes joins for queries • excessively normalized database:  queries take more time to complete, as data has to be retrieved from more tables. • Normalized better for writes OLTP • De-normalized better for reads , reporting • Real World Mixture:  normalized schema  Cache selected columns in memory table Salaria Software Services 17
  • 18. Smaller => less disk => less memory => better performance  Use the smallest data type possible • The smaller your data types, The more index (and data) can fit into a block of memory, the faster your queries will be.  Period.  Especially for indexed fields Salaria Software Services 18
  • 19.  MySQL has 9 numeric data types  Compared to Oracle's 1 • Integer:  TINYINT , SMALLINT, MEDIUMINT, INT, BIGINT  Require 8, 16, 24, 32, and 64 bits of space. • Use UNSIGNED when you don't need negative numbers – one more level of data integrity • BIGINT is not needed for AUTO_INCREMENT  INT UNSIGNED stores 4.3 billion values!  Summation of values... yes, use BIGINT  Floating Point: FLOAT, DOUBLE  Approximate calculations • Fixed Point: DECIMAL  Always use DECIMAL for monetary/currency fields, never use FLOAT or DOUBLE! • Other: BIT  Store 0,1 values Salaria Software Services 19
  • 20.  VARCHAR(n) variable length  uses only space it needs – Can save disk space = better performance  Use : – Max column length > avg – when updates rare (updates fragment) • CHAR(n) fixed length  Use: – short strings, Mostly same length, or changed frequently Salaria Software Services 20
  • 21.  Always define columns as NOT NULL – unless there is a good reason not to  Can save a byte per column  nullable columns make indexes, index statistics, and value comparisons more complicated. • Use the same data types for columns that will be compared in JOINs  Otherwise converted for comparison • Use BLOBs very sparingly  Use the filesystem for what it was intended Salaria Software Services 21
  • 22. “The more records you can fit into a single page of memory/disk, the faster your seeks and scans will be.” • Use appropriate data types • Keep primary keys small • Use TEXT sparingly  Consider separate tables • Use BLOBs very sparingly  Use the filesystem for what it was intended Salaria Software Services 22
  • 23.  Indexes Speed up Queries,  SELECT...WHERE name = 'carol'  only if there is good selectivity: – % of distinct values in a column • But... each index will slow down INSERT, UPDATE, and DELETE operations Salaria Software Services 23
  • 24.  Always have an index on join conditions • Look to add indexes on columns used in WHERE and GROUP BY expressions • PRIMARY KEY, UNIQUE , and Foreign key Constraint columns are automatically indexed.  other columns can be indexed (CREATE INDEX..) Salaria Software Services 24
  • 25.  use the MySQL slow query log and use Explain • Append EXPLAIN to your SELECT statement  shows how the MySQL optimizer has chosen to execute the query • You Want to make your queries access less data:  are queries accessing too many rows or columns? – select only the columns that you need • Use to see where you should add indexes  Consider adding an index for slow queries or cause a lot of load. – ensures that missing indexes are picked up early in the development process Salaria Software Services 25
  • 26.  Find and fix problem SQL: • how long a query took • how the optimizer handled it  Drill downs, results of EXPLAIN statements • Historical and real-time analysis  query execution counts, run time “Its not just slow running queries that are a problem, Sometimes its SQL that executes a lot that kills your system” Salaria Software Services 26
  • 27.  Just append EXPLAIN to your SELECT statement • Provides the execution plan chosen by the MySQL optimizer for a specific SELECT statement  Shows how the MySQL optimizer executes the query • Use to see where you should add indexes  ensures that missing indexes are picked up early in the development process Salaria Software Services 27
  • 28.  A character set is a set of symbols and encodings.  A collation is a set of rules for comparing characters in a character set.  MySQL can do these things for you:  Store strings using a variety of character sets  Compare strings using a variety of collations  Mix strings with different character sets or collations in the same server, the same database, or even the same table  Allow specification of character set and collation at any level - Mysql > SET NAMES 'utf8'; - Mysql > SHOW CHARACTER SET Salaria Software Services 28
  • 29.  Two different character sets cannot have the same collation.  Each character set has one collation that is the default collation. For example, the default collation for latin1 is latin1_swedish_ci. The output for “SHOW CHARACTER SET” indicates which collation is the default for each displayed character set.  There is a convention for collation names: They start with the name of the character set with which they are associated, they usually include a language name, and they end with _ci (case insensitive), _cs (case sensitive), or _bin (binary). Salaria Software Services 29
  • 30.  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  <?php mysql_query('SET NAMES utf8'); ?>  CREATE DATABASE mydatabase DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;  CREATE TABLE mytable ( mydata VARCHAR(128) NOT NULL ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; Salaria Software Services 30
  • 31.  MySQL Forge and the Forge Wiki http://forge.mysql.com/  Planet MySQL http://planetmysql.org/  MySQL DevZone http://dev.mysql.com/  High Performance MySQL book Salaria Software Services 31
  • 33. Mahesh Salaria mahesh@salaria.net Salaria Software Services http://salariasoft.com Salaria Software Services 33