SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Practical MySQL
    for web applications




       Domas Mituzas
  MySQL @ Sun Microsystems
    Wikimedia Foudnation
This is different world


• Not OLAP, Not OLTP
• OLWP. On line web processing
• OLP?
Web

• Need data now. Right now. Instantly.
• High scale, huge churns
• Repetitive reads
• Click, click, click!
MySQL

• Great network bit-bucket
• Lightweight and fast
• Likes reads a lot
 • Data clustering
 • Covering indexes
Data
• Mostly variable length
• Web users are lazy to type
• Tends to be short:
• Example of varchar(255) web supplied data
     length distribution:

800,000
600,000
400,000
200,000
      0
          <5   >5   >10   >15   >20   >25   >30   >35   >40   >45
Access
• Writes are small and rare
 • Inserts mostly
 • Text changes uncommon
• Reads are bigger and everywhere
 • Ordered data
 • Range scans
 • Pages
Views

• User
• Tag
• Time
• Related
Ordering
• Filesorts are bad.
 • TEXT/BLOB go to filesystem immediately
 • ORDER BY a LIMIT x will still scan whole
    range, 1000x costs
 • Filesort alone is more than 2x expensive
    operation, than just fetching rows
 • In Web, order is known and rarely changed
Indexing


• Provide index for every view pattern
• Composite indexes are a must
InnoDB
• Data is clustered by PK
 • Composite PKs group logical sets
• PK value is in secondary keys
 • Adding PK to index definition - cheap
 • Reading PK+SK values doesn’t read PK
    (table) itself - very very cheap
• Every read is in index-order
Covering index

• A (partial) copy of table for different access
  pattern/view
• Especially useful if table doesn’t fit in
  memory
• 100x less seeks for cold data
• Probably no need with SSDs :-)
JOIN orders
• 5.1 fixes this
• In 5.0, order on joined tables caused
  filesorts, even if indexes exist
• Might be faster fetching single row as
  separate SELECT, instead of joining to it
• May use FORCE INDEX and rely on implicit
  order, instead of ORDER BY. <-- DIRTY!
• Can use app-defined ordering columns in
  keys
Query cache
• Does not work for big apps (transactions,
  lots of changes)
• Does great job for small ones
 • Needs uniform queries
 • Less dynamic queries - better hitrate
• Primary tweak on shared hosting
Counts

• MyISAM count(*) works, sometimes
• Scanning rows - inefficient
• Maintaining counts is easy and cheap
 • Aggregate data is easier to keep hot
 • INSERT ... ON DUPLICATE KEY ...
BLOBs
• Keep in separate tables
• Keep outside search query logic, display only
 • Cheaper metadata updates, especially
    InnoDB
  • Less data to read in big scans, orders,
    grouping, etc
  • Can always revisit blobs in second query
  • Easier to move out afterwards
Paging


• Bad: OFFSET .. LIMIT ..
• Good: WHERE id>xxx LIMIT ..
 • Who cares about 15th page?
Character sets

• Lucky if latin1 (or other 8bit charset) is
  enough
• Even luckier if binary
• Have to be very careful with utf8 and friends
 • More expensive filesorts!
Connections
• Persistent - bad
 • Connect is cheap, connection is not
 • Applications may spend less than 20% time
    in db
 • Prepare application, do all db work,
    disconnect, continue with other work
 • ___QQQ___ instead of _Q_Q_Q_Q_
Locking
• SELECT ... FOR UPDATE - necessary evil
• Good: Hot potato transactions
• Bad: waiting for anything
 • Especially streaming of files, etc
 • Use output buffers!
   • ob_flush() after COMMIT, not before
• Delay and split big changes

Weitere ähnliche Inhalte

Was ist angesagt?

Graphs, parallelism and business cases
Graphs, parallelism and business casesGraphs, parallelism and business cases
Graphs, parallelism and business casesDanBelibov1
 
Graphs, parallelism and business cases
 Graphs, parallelism and business cases Graphs, parallelism and business cases
Graphs, parallelism and business casesDaniel Toader
 
What SQL should actually be...
What SQL should actually be...What SQL should actually be...
What SQL should actually be...Open Academy
 
Drupal Performance and Scaling
Drupal Performance and ScalingDrupal Performance and Scaling
Drupal Performance and ScalingGerald Villorente
 
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storagemoai kids
 
Database , 15 Object DBMS
Database , 15 Object DBMSDatabase , 15 Object DBMS
Database , 15 Object DBMSAli Usman
 
Learn how zheap works
 Learn how zheap works Learn how zheap works
Learn how zheap worksEDB
 
Php & web server performace
Php & web server performacePhp & web server performace
Php & web server performaceTuyển Đoàn
 
Database ,16 P2P
Database ,16 P2P Database ,16 P2P
Database ,16 P2P Ali Usman
 
Pagereplacement algorithm(computional concept)
Pagereplacement algorithm(computional concept)Pagereplacement algorithm(computional concept)
Pagereplacement algorithm(computional concept)Siddhi Viradiya
 
What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010jbellis
 
COUNTWORDSFREE - WORD COUNTER
COUNTWORDSFREE - WORD COUNTERCOUNTWORDSFREE - WORD COUNTER
COUNTWORDSFREE - WORD COUNTERKirylTravulka
 
Web Service and Mobile Integrated Day II
Web Service and Mobile Integrated Day IIWeb Service and Mobile Integrated Day II
Web Service and Mobile Integrated Day IIAnuchit Chalothorn
 
Evan Ellis "Tumblr. Massively Sharded MySQL"
Evan Ellis "Tumblr. Massively Sharded MySQL"Evan Ellis "Tumblr. Massively Sharded MySQL"
Evan Ellis "Tumblr. Massively Sharded MySQL"Alexey Mahotkin
 
Guide of speeding up WordPress Website
Guide of speeding up WordPress WebsiteGuide of speeding up WordPress Website
Guide of speeding up WordPress WebsiteXin Peng
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IAnuchit Chalothorn
 

Was ist angesagt? (19)

Graphs, parallelism and business cases
Graphs, parallelism and business casesGraphs, parallelism and business cases
Graphs, parallelism and business cases
 
Graphs, parallelism and business cases
 Graphs, parallelism and business cases Graphs, parallelism and business cases
Graphs, parallelism and business cases
 
What SQL should actually be...
What SQL should actually be...What SQL should actually be...
What SQL should actually be...
 
Drupal Performance and Scaling
Drupal Performance and ScalingDrupal Performance and Scaling
Drupal Performance and Scaling
 
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage
 
Ajax
AjaxAjax
Ajax
 
Database , 15 Object DBMS
Database , 15 Object DBMSDatabase , 15 Object DBMS
Database , 15 Object DBMS
 
Learn how zheap works
 Learn how zheap works Learn how zheap works
Learn how zheap works
 
Php & web server performace
Php & web server performacePhp & web server performace
Php & web server performace
 
Database ,16 P2P
Database ,16 P2P Database ,16 P2P
Database ,16 P2P
 
Pagereplacement algorithm(computional concept)
Pagereplacement algorithm(computional concept)Pagereplacement algorithm(computional concept)
Pagereplacement algorithm(computional concept)
 
What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010
 
COUNTWORDSFREE - WORD COUNTER
COUNTWORDSFREE - WORD COUNTERCOUNTWORDSFREE - WORD COUNTER
COUNTWORDSFREE - WORD COUNTER
 
Web Service and Mobile Integrated Day II
Web Service and Mobile Integrated Day IIWeb Service and Mobile Integrated Day II
Web Service and Mobile Integrated Day II
 
Evan Ellis "Tumblr. Massively Sharded MySQL"
Evan Ellis "Tumblr. Massively Sharded MySQL"Evan Ellis "Tumblr. Massively Sharded MySQL"
Evan Ellis "Tumblr. Massively Sharded MySQL"
 
No SQL and MongoDB - Hyderabad Scalability Meetup
No SQL and MongoDB - Hyderabad Scalability MeetupNo SQL and MongoDB - Hyderabad Scalability Meetup
No SQL and MongoDB - Hyderabad Scalability Meetup
 
Guide of speeding up WordPress Website
Guide of speeding up WordPress WebsiteGuide of speeding up WordPress Website
Guide of speeding up WordPress Website
 
Quixote
QuixoteQuixote
Quixote
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day I
 

Andere mochten auch

Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...Indus Khaitan
 
Pentaho Bi Server Pivot Olap
Pentaho Bi Server Pivot OlapPentaho Bi Server Pivot Olap
Pentaho Bi Server Pivot OlapFeris Thia
 
Geospatial Business Intelligence made easy with GeoMondrian & SOLAPLayers
Geospatial Business Intelligence made easy with GeoMondrian & SOLAPLayersGeospatial Business Intelligence made easy with GeoMondrian & SOLAPLayers
Geospatial Business Intelligence made easy with GeoMondrian & SOLAPLayersThierry Badard
 
Mondrian update (Pentaho community meetup 2012, Amsterdam)
Mondrian update (Pentaho community meetup 2012, Amsterdam)Mondrian update (Pentaho community meetup 2012, Amsterdam)
Mondrian update (Pentaho community meetup 2012, Amsterdam)Julian Hyde
 
Mondrian and OLAP Overview
Mondrian and OLAP OverviewMondrian and OLAP Overview
Mondrian and OLAP OverviewAlex Meadows
 
Performance optimisations PHP meetup Rotterdam
Performance optimisations PHP meetup RotterdamPerformance optimisations PHP meetup Rotterdam
Performance optimisations PHP meetup RotterdamDimitri Vanoverbeke
 
Big Data MDX with Mondrian and Apache Kylin
Big Data MDX with Mondrian and Apache KylinBig Data MDX with Mondrian and Apache Kylin
Big Data MDX with Mondrian and Apache Kylininovex GmbH
 
Mondrian - Geo Mondrian
Mondrian - Geo MondrianMondrian - Geo Mondrian
Mondrian - Geo MondrianSimone Campora
 
eazyBI Overview - Embedding Mondrian in other applications
eazyBI Overview - Embedding Mondrian in other applicationseazyBI Overview - Embedding Mondrian in other applications
eazyBI Overview - Embedding Mondrian in other applicationsRaimonds Simanovskis
 
Data Warehouses and Multi-Dimensional Data Analysis
Data Warehouses and Multi-Dimensional Data AnalysisData Warehouses and Multi-Dimensional Data Analysis
Data Warehouses and Multi-Dimensional Data AnalysisRaimonds Simanovskis
 
Optiq: A dynamic data management framework
Optiq: A dynamic data management frameworkOptiq: A dynamic data management framework
Optiq: A dynamic data management frameworkJulian Hyde
 
Introduction To Pentaho Analysis
Introduction To Pentaho AnalysisIntroduction To Pentaho Analysis
Introduction To Pentaho AnalysisDataminingTools Inc
 
Open Source Business Intelligence Overview
Open Source Business Intelligence OverviewOpen Source Business Intelligence Overview
Open Source Business Intelligence OverviewAlex Meadows
 
Cost-based query optimization in Apache Hive
Cost-based query optimization in Apache HiveCost-based query optimization in Apache Hive
Cost-based query optimization in Apache HiveJulian Hyde
 

Andere mochten auch (17)

Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
Creating Interactive Olap Applications With My Sql Enterprise And Mondrian Pr...
 
Pentaho Bi Server Pivot Olap
Pentaho Bi Server Pivot OlapPentaho Bi Server Pivot Olap
Pentaho Bi Server Pivot Olap
 
Geospatial Business Intelligence made easy with GeoMondrian & SOLAPLayers
Geospatial Business Intelligence made easy with GeoMondrian & SOLAPLayersGeospatial Business Intelligence made easy with GeoMondrian & SOLAPLayers
Geospatial Business Intelligence made easy with GeoMondrian & SOLAPLayers
 
Mondrian update (Pentaho community meetup 2012, Amsterdam)
Mondrian update (Pentaho community meetup 2012, Amsterdam)Mondrian update (Pentaho community meetup 2012, Amsterdam)
Mondrian update (Pentaho community meetup 2012, Amsterdam)
 
Mondrian and OLAP Overview
Mondrian and OLAP OverviewMondrian and OLAP Overview
Mondrian and OLAP Overview
 
Performance optimisations PHP meetup Rotterdam
Performance optimisations PHP meetup RotterdamPerformance optimisations PHP meetup Rotterdam
Performance optimisations PHP meetup Rotterdam
 
Big Data MDX with Mondrian and Apache Kylin
Big Data MDX with Mondrian and Apache KylinBig Data MDX with Mondrian and Apache Kylin
Big Data MDX with Mondrian and Apache Kylin
 
Mondrian - Geo Mondrian
Mondrian - Geo MondrianMondrian - Geo Mondrian
Mondrian - Geo Mondrian
 
eazyBI Overview - Embedding Mondrian in other applications
eazyBI Overview - Embedding Mondrian in other applicationseazyBI Overview - Embedding Mondrian in other applications
eazyBI Overview - Embedding Mondrian in other applications
 
Data Warehouses and Multi-Dimensional Data Analysis
Data Warehouses and Multi-Dimensional Data AnalysisData Warehouses and Multi-Dimensional Data Analysis
Data Warehouses and Multi-Dimensional Data Analysis
 
mondrian-olap JRuby library
mondrian-olap JRuby librarymondrian-olap JRuby library
mondrian-olap JRuby library
 
Optiq: A dynamic data management framework
Optiq: A dynamic data management frameworkOptiq: A dynamic data management framework
Optiq: A dynamic data management framework
 
Introduction To Pentaho Analysis
Introduction To Pentaho AnalysisIntroduction To Pentaho Analysis
Introduction To Pentaho Analysis
 
Open Source Business Intelligence Overview
Open Source Business Intelligence OverviewOpen Source Business Intelligence Overview
Open Source Business Intelligence Overview
 
Pentaho
PentahoPentaho
Pentaho
 
Cost-based query optimization in Apache Hive
Cost-based query optimization in Apache HiveCost-based query optimization in Apache Hive
Cost-based query optimization in Apache Hive
 
Metadata in Business Intelligence
Metadata in Business IntelligenceMetadata in Business Intelligence
Metadata in Business Intelligence
 

Ähnlich wie Practical MySQL

Scalarea Aplicatiilor Web - 2009
Scalarea Aplicatiilor Web - 2009Scalarea Aplicatiilor Web - 2009
Scalarea Aplicatiilor Web - 2009Andrei Gheorghe
 
[Roblek] Distributed computing in practice
[Roblek] Distributed computing in practice[Roblek] Distributed computing in practice
[Roblek] Distributed computing in practicejavablend
 
No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...
No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...
No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...Brian Brazil
 
Extending The My Sql Data Landscape
Extending The My Sql Data LandscapeExtending The My Sql Data Landscape
Extending The My Sql Data LandscapeRonald Bradford
 
Кирилл Шутемов aka “kas” - О Transparent Hugepages и Huge zero page
Кирилл Шутемов aka “kas” - О Transparent Hugepages и Huge zero pageКирилл Шутемов aka “kas” - О Transparent Hugepages и Huge zero page
Кирилл Шутемов aka “kas” - О Transparent Hugepages и Huge zero pageMinsk Linux User Group
 
MongoDB Aggregation Performance
MongoDB Aggregation PerformanceMongoDB Aggregation Performance
MongoDB Aggregation PerformanceMongoDB
 
Building a Database for the End of the World
Building a Database for the End of the WorldBuilding a Database for the End of the World
Building a Database for the End of the Worldjhugg
 
Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014marvin herrera
 
Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)Don Demcsak
 
UKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningUKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningFromDual GmbH
 
Practical Intro Merb
Practical Intro MerbPractical Intro Merb
Practical Intro MerbPaul Pajo
 
Practical Intro Merb
Practical Intro MerbPractical Intro Merb
Practical Intro MerbPaul Pajo
 
My S Q L Replication Getting The Most From Slaves
My S Q L  Replication  Getting  The  Most  From  SlavesMy S Q L  Replication  Getting  The  Most  From  Slaves
My S Q L Replication Getting The Most From SlavesPerconaPerformance
 
CASSANDRA MEETUP - Choosing the right cloud instances for success
CASSANDRA MEETUP - Choosing the right cloud instances for successCASSANDRA MEETUP - Choosing the right cloud instances for success
CASSANDRA MEETUP - Choosing the right cloud instances for successErick Ramirez
 

Ähnlich wie Practical MySQL (20)

Advanced Deployment
Advanced DeploymentAdvanced Deployment
Advanced Deployment
 
Mysql Optimization
Mysql OptimizationMysql Optimization
Mysql Optimization
 
Scalarea Aplicatiilor Web - 2009
Scalarea Aplicatiilor Web - 2009Scalarea Aplicatiilor Web - 2009
Scalarea Aplicatiilor Web - 2009
 
[Roblek] Distributed computing in practice
[Roblek] Distributed computing in practice[Roblek] Distributed computing in practice
[Roblek] Distributed computing in practice
 
No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...
No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...
No C-QL (Or how I learned to stop worrying, and love eventual consistency) (N...
 
Extending The My Sql Data Landscape
Extending The My Sql Data LandscapeExtending The My Sql Data Landscape
Extending The My Sql Data Landscape
 
Http Status Report
Http Status ReportHttp Status Report
Http Status Report
 
Кирилл Шутемов aka “kas” - О Transparent Hugepages и Huge zero page
Кирилл Шутемов aka “kas” - О Transparent Hugepages и Huge zero pageКирилл Шутемов aka “kas” - О Transparent Hugepages и Huge zero page
Кирилл Шутемов aka “kas” - О Transparent Hugepages и Huge zero page
 
MongoDB Aggregation Performance
MongoDB Aggregation PerformanceMongoDB Aggregation Performance
MongoDB Aggregation Performance
 
Building a Database for the End of the World
Building a Database for the End of the WorldBuilding a Database for the End of the World
Building a Database for the End of the World
 
Qure Tech Presentation
Qure Tech PresentationQure Tech Presentation
Qure Tech Presentation
 
Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014
 
Shootout at the PAAS Corral
Shootout at the PAAS CorralShootout at the PAAS Corral
Shootout at the PAAS Corral
 
Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)
 
UKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL TuningUKOUG 2011: Practical MySQL Tuning
UKOUG 2011: Practical MySQL Tuning
 
Practical Intro Merb
Practical Intro MerbPractical Intro Merb
Practical Intro Merb
 
Practical Intro Merb
Practical Intro MerbPractical Intro Merb
Practical Intro Merb
 
MySQL Tuning
MySQL TuningMySQL Tuning
MySQL Tuning
 
My S Q L Replication Getting The Most From Slaves
My S Q L  Replication  Getting  The  Most  From  SlavesMy S Q L  Replication  Getting  The  Most  From  Slaves
My S Q L Replication Getting The Most From Slaves
 
CASSANDRA MEETUP - Choosing the right cloud instances for success
CASSANDRA MEETUP - Choosing the right cloud instances for successCASSANDRA MEETUP - Choosing the right cloud instances for success
CASSANDRA MEETUP - Choosing the right cloud instances for success
 

Mehr von Indus Khaitan

Product marketing in B2B SaaS Startup Indus Khaitan 2018
Product marketing in B2B SaaS Startup Indus Khaitan 2018Product marketing in B2B SaaS Startup Indus Khaitan 2018
Product marketing in B2B SaaS Startup Indus Khaitan 2018Indus Khaitan
 
Bringing Contracts to Life | Keynote session at IACCM Dublin Ireland, May 2015
Bringing Contracts to Life | Keynote session at IACCM Dublin Ireland, May 2015Bringing Contracts to Life | Keynote session at IACCM Dublin Ireland, May 2015
Bringing Contracts to Life | Keynote session at IACCM Dublin Ireland, May 2015Indus Khaitan
 
Oracle OpenWorld | CON9707 Enterprise Mobile Security Architecture beyond the...
Oracle OpenWorld | CON9707 Enterprise Mobile Security Architecture beyond the...Oracle OpenWorld | CON9707 Enterprise Mobile Security Architecture beyond the...
Oracle OpenWorld | CON9707 Enterprise Mobile Security Architecture beyond the...Indus Khaitan
 
Oracle OpenWorld 2015 | CON9456 Mobile Security in the Cloud
Oracle OpenWorld 2015 | CON9456 Mobile Security in the CloudOracle OpenWorld 2015 | CON9456 Mobile Security in the Cloud
Oracle OpenWorld 2015 | CON9456 Mobile Security in the CloudIndus Khaitan
 
Lets talk about decision making - UC Berkeley
Lets talk about decision making - UC BerkeleyLets talk about decision making - UC Berkeley
Lets talk about decision making - UC BerkeleyIndus Khaitan
 
Bitzer Mobile TiECON 2013 Pitch Indus Khaitan
Bitzer Mobile TiECON 2013 Pitch Indus KhaitanBitzer Mobile TiECON 2013 Pitch Indus Khaitan
Bitzer Mobile TiECON 2013 Pitch Indus KhaitanIndus Khaitan
 
NSDC at NASSCOM Product Conclave 2010
NSDC at NASSCOM Product Conclave 2010NSDC at NASSCOM Product Conclave 2010
NSDC at NASSCOM Product Conclave 2010Indus Khaitan
 
NSEF India - Why become a social entrepreneur now
NSEF India - Why become a social entrepreneur nowNSEF India - Why become a social entrepreneur now
NSEF India - Why become a social entrepreneur nowIndus Khaitan
 
Building Winning Teams - Jain International Trade Organization Bangalore 06_J...
Building Winning Teams - Jain International Trade Organization Bangalore 06_J...Building Winning Teams - Jain International Trade Organization Bangalore 06_J...
Building Winning Teams - Jain International Trade Organization Bangalore 06_J...Indus Khaitan
 
Disha 2010 Presentation on Entrepreneurship Jan'10 -- Indus Khaitan
Disha 2010 Presentation on Entrepreneurship Jan'10 -- Indus Khaitan Disha 2010 Presentation on Entrepreneurship Jan'10 -- Indus Khaitan
Disha 2010 Presentation on Entrepreneurship Jan'10 -- Indus Khaitan Indus Khaitan
 
Ford Motor Company 1902 Indus Khaitan
Ford Motor Company 1902 Indus KhaitanFord Motor Company 1902 Indus Khaitan
Ford Motor Company 1902 Indus KhaitanIndus Khaitan
 
5 Bare Minimum Things A Web Startup CTO Must Worry About
5 Bare Minimum Things A Web Startup CTO Must Worry About5 Bare Minimum Things A Web Startup CTO Must Worry About
5 Bare Minimum Things A Web Startup CTO Must Worry AboutIndus Khaitan
 

Mehr von Indus Khaitan (13)

Product marketing in B2B SaaS Startup Indus Khaitan 2018
Product marketing in B2B SaaS Startup Indus Khaitan 2018Product marketing in B2B SaaS Startup Indus Khaitan 2018
Product marketing in B2B SaaS Startup Indus Khaitan 2018
 
Bringing Contracts to Life | Keynote session at IACCM Dublin Ireland, May 2015
Bringing Contracts to Life | Keynote session at IACCM Dublin Ireland, May 2015Bringing Contracts to Life | Keynote session at IACCM Dublin Ireland, May 2015
Bringing Contracts to Life | Keynote session at IACCM Dublin Ireland, May 2015
 
Oracle OpenWorld | CON9707 Enterprise Mobile Security Architecture beyond the...
Oracle OpenWorld | CON9707 Enterprise Mobile Security Architecture beyond the...Oracle OpenWorld | CON9707 Enterprise Mobile Security Architecture beyond the...
Oracle OpenWorld | CON9707 Enterprise Mobile Security Architecture beyond the...
 
Oracle OpenWorld 2015 | CON9456 Mobile Security in the Cloud
Oracle OpenWorld 2015 | CON9456 Mobile Security in the CloudOracle OpenWorld 2015 | CON9456 Mobile Security in the Cloud
Oracle OpenWorld 2015 | CON9456 Mobile Security in the Cloud
 
Lets talk about decision making - UC Berkeley
Lets talk about decision making - UC BerkeleyLets talk about decision making - UC Berkeley
Lets talk about decision making - UC Berkeley
 
Bitzer Mobile TiECON 2013 Pitch Indus Khaitan
Bitzer Mobile TiECON 2013 Pitch Indus KhaitanBitzer Mobile TiECON 2013 Pitch Indus Khaitan
Bitzer Mobile TiECON 2013 Pitch Indus Khaitan
 
Mobile Security
Mobile SecurityMobile Security
Mobile Security
 
NSDC at NASSCOM Product Conclave 2010
NSDC at NASSCOM Product Conclave 2010NSDC at NASSCOM Product Conclave 2010
NSDC at NASSCOM Product Conclave 2010
 
NSEF India - Why become a social entrepreneur now
NSEF India - Why become a social entrepreneur nowNSEF India - Why become a social entrepreneur now
NSEF India - Why become a social entrepreneur now
 
Building Winning Teams - Jain International Trade Organization Bangalore 06_J...
Building Winning Teams - Jain International Trade Organization Bangalore 06_J...Building Winning Teams - Jain International Trade Organization Bangalore 06_J...
Building Winning Teams - Jain International Trade Organization Bangalore 06_J...
 
Disha 2010 Presentation on Entrepreneurship Jan'10 -- Indus Khaitan
Disha 2010 Presentation on Entrepreneurship Jan'10 -- Indus Khaitan Disha 2010 Presentation on Entrepreneurship Jan'10 -- Indus Khaitan
Disha 2010 Presentation on Entrepreneurship Jan'10 -- Indus Khaitan
 
Ford Motor Company 1902 Indus Khaitan
Ford Motor Company 1902 Indus KhaitanFord Motor Company 1902 Indus Khaitan
Ford Motor Company 1902 Indus Khaitan
 
5 Bare Minimum Things A Web Startup CTO Must Worry About
5 Bare Minimum Things A Web Startup CTO Must Worry About5 Bare Minimum Things A Web Startup CTO Must Worry About
5 Bare Minimum Things A Web Startup CTO Must Worry About
 

Kürzlich hochgeladen

Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Practical MySQL

  • 1. Practical MySQL for web applications Domas Mituzas MySQL @ Sun Microsystems Wikimedia Foudnation
  • 2. This is different world • Not OLAP, Not OLTP • OLWP. On line web processing • OLP?
  • 3. Web • Need data now. Right now. Instantly. • High scale, huge churns • Repetitive reads • Click, click, click!
  • 4. MySQL • Great network bit-bucket • Lightweight and fast • Likes reads a lot • Data clustering • Covering indexes
  • 5. Data • Mostly variable length • Web users are lazy to type • Tends to be short: • Example of varchar(255) web supplied data length distribution: 800,000 600,000 400,000 200,000 0 <5 >5 >10 >15 >20 >25 >30 >35 >40 >45
  • 6. Access • Writes are small and rare • Inserts mostly • Text changes uncommon • Reads are bigger and everywhere • Ordered data • Range scans • Pages
  • 7. Views • User • Tag • Time • Related
  • 8. Ordering • Filesorts are bad. • TEXT/BLOB go to filesystem immediately • ORDER BY a LIMIT x will still scan whole range, 1000x costs • Filesort alone is more than 2x expensive operation, than just fetching rows • In Web, order is known and rarely changed
  • 9. Indexing • Provide index for every view pattern • Composite indexes are a must
  • 10. InnoDB • Data is clustered by PK • Composite PKs group logical sets • PK value is in secondary keys • Adding PK to index definition - cheap • Reading PK+SK values doesn’t read PK (table) itself - very very cheap • Every read is in index-order
  • 11. Covering index • A (partial) copy of table for different access pattern/view • Especially useful if table doesn’t fit in memory • 100x less seeks for cold data • Probably no need with SSDs :-)
  • 12. JOIN orders • 5.1 fixes this • In 5.0, order on joined tables caused filesorts, even if indexes exist • Might be faster fetching single row as separate SELECT, instead of joining to it • May use FORCE INDEX and rely on implicit order, instead of ORDER BY. <-- DIRTY! • Can use app-defined ordering columns in keys
  • 13. Query cache • Does not work for big apps (transactions, lots of changes) • Does great job for small ones • Needs uniform queries • Less dynamic queries - better hitrate • Primary tweak on shared hosting
  • 14. Counts • MyISAM count(*) works, sometimes • Scanning rows - inefficient • Maintaining counts is easy and cheap • Aggregate data is easier to keep hot • INSERT ... ON DUPLICATE KEY ...
  • 15. BLOBs • Keep in separate tables • Keep outside search query logic, display only • Cheaper metadata updates, especially InnoDB • Less data to read in big scans, orders, grouping, etc • Can always revisit blobs in second query • Easier to move out afterwards
  • 16. Paging • Bad: OFFSET .. LIMIT .. • Good: WHERE id>xxx LIMIT .. • Who cares about 15th page?
  • 17. Character sets • Lucky if latin1 (or other 8bit charset) is enough • Even luckier if binary • Have to be very careful with utf8 and friends • More expensive filesorts!
  • 18. Connections • Persistent - bad • Connect is cheap, connection is not • Applications may spend less than 20% time in db • Prepare application, do all db work, disconnect, continue with other work • ___QQQ___ instead of _Q_Q_Q_Q_
  • 19. Locking • SELECT ... FOR UPDATE - necessary evil • Good: Hot potato transactions • Bad: waiting for anything • Especially streaming of files, etc • Use output buffers! • ob_flush() after COMMIT, not before • Delay and split big changes

Hinweis der Redaktion