SlideShare a Scribd company logo
Boosting MySQL (for starters)
This is not a DB
optimization talk
It’s a talk about how doing things in a specific way leads to getting way
better results by default
“Preoptimization”
 Don’t denormalize by default
 Maintenance is King (by default)
 1 Thread Performance != Parallel
Performance
MyISAM vs InnoDB
Fast != Scalable
“Preoptimization”
I’ll just tune MySQL Parameters…
 Will get you out of SOME trouble
 But not a good “default” solution, specially if the
base is flawed
 Please do tune MySQLs defaults
 Not the theme for today 
Boosting MySQL (for starters)
Start with your Schema
 Your schema is probably the root cause of your
“My DB doesn’t scale” problems
 The solution is not “have a loose/no schema”
 How to fake a DB Design (Curtis Ovid Poe)
 https://www.youtube.com/watch?v=y1tcbhWLiUM
Data types: how (not) to bloat your DB
 Selecting data types with a bit of care is very
productive
 It makes more data fit in less space
 Optimizes use of InnoDB Buffer Pool, MyISAM Key
Buffer, Join Buffer, Sort Buffer, Smaller indexes
Your new best friend
 http://dev.mysql.com/doc/refman/5.6/en/storage-requirements.html
 http://dev.mysql.com/doc/refman/5.5/en/storage-requirements.html
 …
DataTypes: NULL vs NOT NULL
 I don’t care about the NULL debate
 Saves Space
 Gives the DB hints
 Use NULLs wisely
Data Types: Integers
DataTypes: Integers
INT(1) == INT(10) == 4 bytes
That’s it!
DataTypes: Integer family
TINYINT: 1 byte
SMALLINT: 2 bytes
MEDIUMINT: 3 bytes
INT
BIGINT:8 bytes
UNSIGNED: “double”
the range
INTS and surrogate keys
 It’s good to have a surrogate key
 Just unique index the unique column
 Why?
 InnoDB stores the PK on the leafs of all indexes
 Indexes bloat if they’re “big keys”
Id columns for your tables
 INT by default for “things that can get big”
 Smaller INTs for smaller sets
 Do you really need a BIGINT?
 The magnitude comparison trick:
 Epochs in Unix have 4 bytes
 The epoch has been counting since 1970. Will run out in 2038
 An INT can identify ONE THING HAPPENING EVERY SECOND for 68 YEARS!
 Do you STILL need a BIGINT?
DataTypes: Integer family
TINYINT: 1 byte
SMALLINT: 2 bytes
MEDIUMINT: 3 bytes
INT
BIGINT:8 bytes
UNSIGNED: “double”
the range
DataTypes: Integer family
TINYINT: 1 byte
SMALLINT: 2 bytes
MEDIUMINT: 3 bytes
INT
BIGINT:8 bytes
UNSIGNED: “double”
the range
Data Types: Texts
DataTypes: Texts
 Texts are strings of bytes with a charset and a collation
BINARY and VARBINARY
CHAR and VARCHAR
DataTypes: Texts
BINARY(10) == 10 bytes
CHAR(10) ==? 10 bytes
DataTypes: Texts
BINARY(10) == 10 bytes
CHAR(10) ==? 10 bytes
CHAR(10) latin1: 10 bytes
CHAR(19) utf-8: 30 bytes
DataTypes: Texts
BINARY(10) == 10 bytes
CHAR(10) ==? 10 bytes
CHAR(10) latin1: 10 bytes
CHAR(19) utf-8: 30 bytes
VARBINARY(10) == 1 to 11 bytes
VARCHAR(10) ==? 1 to 11 bytes
DataTypes: Texts
BINARY(10) == 10 bytes
CHAR(10) ==? 10 bytes
CHAR(10) latin1: 10 bytes
CHAR(10) utf-8: 30 bytes
VARBINARY(10) == 1 to 11 bytes
VARCHAR(10) ==? 1 to 11 bytes
VARCHAR(10) latin 1: 1 to 11 bytes
VARCHAR(10) utf-8: 1 to 31 bytes
So I’ll just go for VARCHAR(255) on all
text columns
 “After all… I’ll just consume the number of bytes + 1”
So I’ll just go for VARCHAR(255) on all
text columns
 “After all… I’ll just consume the number of bytes + 1”
 When we need a temporary table
 https://dev.mysql.com/doc/refman/5.6/en/memory-storage-engine.html
 “MEMORY tables use a fixed-length row-storage format. Variable-length types such
as VARCHAR are stored using a fixed length”
Boosting MySQL (for starters)
So I’ll just go for VARCHAR(255) on all
text columns
Congrats! All your VARCHAR(255) are now
CHAR(255) in memory
That’s 255 bytes latin-1. Or 765 bytes utf-8
O_o
Note: do the maths on VARCHAR(65535)
DataTypes: BLOBS
 TEXT == BLOB == problems
 TEXT = BLOB + charset + collation
 TEXT fields are not unlimited!
 TINYTEXT and TINYBLOB (up to 256 bytes == x chars)
 TEXT / BLOB (up to 65KB == x chars)
 MEDIUMBLOB / MEDIUMTEXT (up to 16MB == x chars)
 LONGTEXT / LONGBLOB (up to 2GB == x chars)
SELECT * IS YOUR FRIEND?
 IF a SELECT contains a BLOB/TEXT column
Temporary tables go DIRECTLY to DISK
Boosting MySQL (for starters)
SELECT * IS YOUR FRIEND?
 IF a SELECT contains a BLOB/TEXT column
Temporary tables go DIRECTLY to DISK
Note: “Big” columns belong on a filesystem or an object store
DataTypes: Small Sets
 ENUM
 One value out of the possibilities (‘big’, ‘small’)
 SET
 A set of possible values (‘pool’,’terrace’,’fence’)
 SETS are NOT good for finding stuff
 FIND_IN_SET is a function. No indexes 
 Default to a separate table + relation
DataTypes: Dates
 YEAR = 1 byte (range from 1901 to 2155)
 DATE = 3 bytes
 TIME = 3 bytes
 DATETIME = 8 bytes
 TIMESTAMP = 4 bytes
Timestamp is an epoch. Ideal for “things that
happen now” (sold time, renewal date, etc)
Masked Data
Masked Types
An IP Address
234.34.123.92
CHAR(15)? VARCHAR(15)?
Masked Types
INT
INSERT INTO table (col) VALUES (INET_ATON(’10.10.10.10’));
SELECT INET_NTOA(col) FROM table;
Masked Types
MD5("The quick brown fox jumps over the lazy cat")
 71bd588d5ad9b6abe87b831b45f8fa95
 CHAR(32)
BINARY(16)
Masked Types
 UUIDs
 HASH functions
 Network masks
Indexes for starters
Indexes for starters
Index the two sides of relations
PK
Index the two sides of relations
Index this guy too!
Index the two sides of relations
Index this guy too!
And this guy!
Boosting MySQL (for starters)
Boosting MySQL (for starters)
PK is (contract_id, customer_id)
(Implied uniqueness)
Index “both ways”:
(customer_id, contract_id)
InnoDB optimization: Don’t index the full (customer_id, contract_id). The
index ALREADY HAS customer_id in it’s leafs. So just index (customer_id)
N-M relation: Junction tables
Boosting MySQL (for starters)
Don’t operate on fields
 Because they can’t use indexes
 WHERE column = ‘x’
WHERE column > 2000
WHERE column LIKE ‘prefix%’
 WHERE column + 2000 > 2013
WHERE FIND_IN_SET(column)
WHERE CONCAT(f1,f2) = “xxxx.com”
WHERE YEAR(date) = 2015
WHERE column LIKE ‘%.com’
Polish your maths: Algebra
Doesn’t use index
WHERE column + 2000 > 2013
WHERE FIND_IN_SET(‘pool’,column)
WHERE CONCAT(f1,’.’,f2) =
“xxxx.com”
WHERE YEAR(date) = 2015
WHERE column LIKE ‘%.com’
Uses index
WHERE column > 13
?
WHERE f1 = ‘xxxx’ AND f2 = ‘com’
WHERE date BETWEEN ’01-01-2015’
and ’31-12-2015’
?
The old switcheroo…
Doesn’t use index
WHERE column + 2000 > 2013
WHERE FIND_IN_SET(‘pool’,column)
WHERE CONCAT(f1,’.’,f2) =
“xxxx.com”
WHERE YEAR(date) = 2015
WHERE column LIKE ‘%.com’
Uses index
WHERE has_pool = 1
WHERE column_rev LIKE ‘moc.%’
The old switcheroo…
Doesn’t use index
WHERE column + 2000 > 2013
WHERE FIND_IN_SET(‘pool’,column)
WHERE CONCAT(f1,’.’,f2) =
“xxxx.com”
WHERE YEAR(date) = 2015
WHERE column LIKE ‘%.com’
Uses index
WHERE has_pool = 1
UPDATE t SET has_pool =
FIND_IN_SET(‘pool’,column);
WHERE column_rev LIKE ‘moc.%’
UPDATE t SET
column_rev=REVERSE(column)
Boosting MySQL (for starters)
CAT IS HERE
Wrap up
Schema
Data Types
How to select them
Masked Types
Indexes
Relations
Using them
Wrap up
 Smaller is better
VS
Boosting MySQL (for starters)
cpsd.es/SRE-job-team

More Related Content

PPTX
2019 02 21_biological_databases_part2_v_upload
PPTX
2019 03 05_biological_databases_part5_v_upload
PPTX
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
PPTX
Building an aws sdk for Perl - Granada Perl Workshop 2014
PPTX
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
PPTX
Plenv and carton
PPTX
Paws - A Perl AWS SDK
PPTX
Paws - Perl AWS SDK Update - November 2015
2019 02 21_biological_databases_part2_v_upload
2019 03 05_biological_databases_part5_v_upload
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
Building an aws sdk for Perl - Granada Perl Workshop 2014
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
Plenv and carton
Paws - A Perl AWS SDK
Paws - Perl AWS SDK Update - November 2015

Viewers also liked (17)

PPTX
NRD: Nagios Result Distributor
PPT
Make Extra Income Online
PPT
Pptplan morgenjuli2011 pptbehandelcoordinatoren
PPTX
My music based magazine evaluation
PDF
Алексей Левинсон Пространства протеста. Московские митинги и сообщество горожан
PPT
iPad Game Design -- Develop Liverpool Dec' 2011
PPT
Questionnaire results
PPTX
Infinity
PPTX
Sophiie compu
PDF
Estilo apa 6aed_directrizes_gerais_mja
PDF
Polifonia_6.18
PDF
Success factors in football
PPT
Kutner and olsen
PDF
introduccion
PDF
Polifonia_6.16
PPTX
My fist drafts presnetation
PPT
Daniel & Ernesto's presentation
NRD: Nagios Result Distributor
Make Extra Income Online
Pptplan morgenjuli2011 pptbehandelcoordinatoren
My music based magazine evaluation
Алексей Левинсон Пространства протеста. Московские митинги и сообщество горожан
iPad Game Design -- Develop Liverpool Dec' 2011
Questionnaire results
Infinity
Sophiie compu
Estilo apa 6aed_directrizes_gerais_mja
Polifonia_6.18
Success factors in football
Kutner and olsen
introduccion
Polifonia_6.16
My fist drafts presnetation
Daniel & Ernesto's presentation
Ad

Similar to Boosting MySQL (for starters) (20)

PPT
Database Sizing
PDF
MySQL Index Cookbook
PDF
Clustered Columnstore - Deep Dive
PPTX
It's Not You. It's Your Data Model.
PPTX
Redis Indices (#RedisTLV)
PPTX
Maryna Popova "Deep dive AWS Redshift"
ODT
Sql and mysql database concepts
PPT
15 Ways to Kill Your Mysql Application Performance
PPTX
Data oriented design and c++
PPTX
Lesson4.2 u4 l1 binary squences
PDF
Your backend architecture is what matters slideshare
PPTX
Introduction to Databases, SQL and querying.pptx
PDF
SQL cheat sheet.pdf
PPTX
2017 biological databasespart2
PPTX
What's new in MariaDB TX 3.0
PDF
MySQL innoDB split and merge pages
PPTX
Inside sql server in memory oltp sql sat nyc 2017
PPT
扩展世界上最大的图片Blog社区
PPT
Fotolog: Scaling the World's Largest Photo Blogging Community
PDF
Use Your MySQL Knowledge to Become an Instant Cassandra Guru
Database Sizing
MySQL Index Cookbook
Clustered Columnstore - Deep Dive
It's Not You. It's Your Data Model.
Redis Indices (#RedisTLV)
Maryna Popova "Deep dive AWS Redshift"
Sql and mysql database concepts
15 Ways to Kill Your Mysql Application Performance
Data oriented design and c++
Lesson4.2 u4 l1 binary squences
Your backend architecture is what matters slideshare
Introduction to Databases, SQL and querying.pptx
SQL cheat sheet.pdf
2017 biological databasespart2
What's new in MariaDB TX 3.0
MySQL innoDB split and merge pages
Inside sql server in memory oltp sql sat nyc 2017
扩展世界上最大的图片Blog社区
Fotolog: Scaling the World's Largest Photo Blogging Community
Use Your MySQL Knowledge to Become an Instant Cassandra Guru
Ad

More from Jose Luis Martínez (10)

PDF
Being cloudy with perl
PPTX
Modern Perl toolchain (help building microservices)
PDF
Escribir plugins para Nagios en Perl
PPTX
Perl and AWS
PDF
Writing nagios plugins in perl
PPTX
Ficheros y directorios
PPTX
DBIx::Class
PPTX
The modern perl toolchain
PPTX
Introducción a las Expresiones Regulares
Being cloudy with perl
Modern Perl toolchain (help building microservices)
Escribir plugins para Nagios en Perl
Perl and AWS
Writing nagios plugins in perl
Ficheros y directorios
DBIx::Class
The modern perl toolchain
Introducción a las Expresiones Regulares

Recently uploaded (20)

PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Cloud computing and distributed systems.
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
MYSQL Presentation for SQL database connectivity
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
Teaching material agriculture food technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Advanced methodologies resolving dimensionality complications for autism neur...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Cloud computing and distributed systems.
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
MYSQL Presentation for SQL database connectivity
The AUB Centre for AI in Media Proposal.docx
Reach Out and Touch Someone: Haptics and Empathic Computing
Understanding_Digital_Forensics_Presentation.pptx
Encapsulation theory and applications.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
NewMind AI Monthly Chronicles - July 2025
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Teaching material agriculture food technology

Boosting MySQL (for starters)

  • 2. This is not a DB optimization talk It’s a talk about how doing things in a specific way leads to getting way better results by default
  • 3. “Preoptimization”  Don’t denormalize by default  Maintenance is King (by default)  1 Thread Performance != Parallel Performance MyISAM vs InnoDB Fast != Scalable
  • 5. I’ll just tune MySQL Parameters…  Will get you out of SOME trouble  But not a good “default” solution, specially if the base is flawed  Please do tune MySQLs defaults  Not the theme for today 
  • 7. Start with your Schema  Your schema is probably the root cause of your “My DB doesn’t scale” problems  The solution is not “have a loose/no schema”  How to fake a DB Design (Curtis Ovid Poe)  https://www.youtube.com/watch?v=y1tcbhWLiUM
  • 8. Data types: how (not) to bloat your DB  Selecting data types with a bit of care is very productive  It makes more data fit in less space  Optimizes use of InnoDB Buffer Pool, MyISAM Key Buffer, Join Buffer, Sort Buffer, Smaller indexes
  • 9. Your new best friend  http://dev.mysql.com/doc/refman/5.6/en/storage-requirements.html  http://dev.mysql.com/doc/refman/5.5/en/storage-requirements.html  …
  • 10. DataTypes: NULL vs NOT NULL  I don’t care about the NULL debate  Saves Space  Gives the DB hints  Use NULLs wisely
  • 12. DataTypes: Integers INT(1) == INT(10) == 4 bytes That’s it!
  • 13. DataTypes: Integer family TINYINT: 1 byte SMALLINT: 2 bytes MEDIUMINT: 3 bytes INT BIGINT:8 bytes UNSIGNED: “double” the range
  • 14. INTS and surrogate keys  It’s good to have a surrogate key  Just unique index the unique column  Why?  InnoDB stores the PK on the leafs of all indexes  Indexes bloat if they’re “big keys”
  • 15. Id columns for your tables  INT by default for “things that can get big”  Smaller INTs for smaller sets  Do you really need a BIGINT?  The magnitude comparison trick:  Epochs in Unix have 4 bytes  The epoch has been counting since 1970. Will run out in 2038  An INT can identify ONE THING HAPPENING EVERY SECOND for 68 YEARS!  Do you STILL need a BIGINT?
  • 16. DataTypes: Integer family TINYINT: 1 byte SMALLINT: 2 bytes MEDIUMINT: 3 bytes INT BIGINT:8 bytes UNSIGNED: “double” the range
  • 17. DataTypes: Integer family TINYINT: 1 byte SMALLINT: 2 bytes MEDIUMINT: 3 bytes INT BIGINT:8 bytes UNSIGNED: “double” the range
  • 19. DataTypes: Texts  Texts are strings of bytes with a charset and a collation BINARY and VARBINARY CHAR and VARCHAR
  • 20. DataTypes: Texts BINARY(10) == 10 bytes CHAR(10) ==? 10 bytes
  • 21. DataTypes: Texts BINARY(10) == 10 bytes CHAR(10) ==? 10 bytes CHAR(10) latin1: 10 bytes CHAR(19) utf-8: 30 bytes
  • 22. DataTypes: Texts BINARY(10) == 10 bytes CHAR(10) ==? 10 bytes CHAR(10) latin1: 10 bytes CHAR(19) utf-8: 30 bytes VARBINARY(10) == 1 to 11 bytes VARCHAR(10) ==? 1 to 11 bytes
  • 23. DataTypes: Texts BINARY(10) == 10 bytes CHAR(10) ==? 10 bytes CHAR(10) latin1: 10 bytes CHAR(10) utf-8: 30 bytes VARBINARY(10) == 1 to 11 bytes VARCHAR(10) ==? 1 to 11 bytes VARCHAR(10) latin 1: 1 to 11 bytes VARCHAR(10) utf-8: 1 to 31 bytes
  • 24. So I’ll just go for VARCHAR(255) on all text columns  “After all… I’ll just consume the number of bytes + 1”
  • 25. So I’ll just go for VARCHAR(255) on all text columns  “After all… I’ll just consume the number of bytes + 1”  When we need a temporary table  https://dev.mysql.com/doc/refman/5.6/en/memory-storage-engine.html  “MEMORY tables use a fixed-length row-storage format. Variable-length types such as VARCHAR are stored using a fixed length”
  • 27. So I’ll just go for VARCHAR(255) on all text columns Congrats! All your VARCHAR(255) are now CHAR(255) in memory That’s 255 bytes latin-1. Or 765 bytes utf-8 O_o Note: do the maths on VARCHAR(65535)
  • 28. DataTypes: BLOBS  TEXT == BLOB == problems  TEXT = BLOB + charset + collation  TEXT fields are not unlimited!  TINYTEXT and TINYBLOB (up to 256 bytes == x chars)  TEXT / BLOB (up to 65KB == x chars)  MEDIUMBLOB / MEDIUMTEXT (up to 16MB == x chars)  LONGTEXT / LONGBLOB (up to 2GB == x chars)
  • 29. SELECT * IS YOUR FRIEND?  IF a SELECT contains a BLOB/TEXT column Temporary tables go DIRECTLY to DISK
  • 31. SELECT * IS YOUR FRIEND?  IF a SELECT contains a BLOB/TEXT column Temporary tables go DIRECTLY to DISK Note: “Big” columns belong on a filesystem or an object store
  • 32. DataTypes: Small Sets  ENUM  One value out of the possibilities (‘big’, ‘small’)  SET  A set of possible values (‘pool’,’terrace’,’fence’)  SETS are NOT good for finding stuff  FIND_IN_SET is a function. No indexes   Default to a separate table + relation
  • 33. DataTypes: Dates  YEAR = 1 byte (range from 1901 to 2155)  DATE = 3 bytes  TIME = 3 bytes  DATETIME = 8 bytes  TIMESTAMP = 4 bytes Timestamp is an epoch. Ideal for “things that happen now” (sold time, renewal date, etc)
  • 35. Masked Types An IP Address 234.34.123.92 CHAR(15)? VARCHAR(15)?
  • 37. INT
  • 38. INSERT INTO table (col) VALUES (INET_ATON(’10.10.10.10’)); SELECT INET_NTOA(col) FROM table;
  • 39. Masked Types MD5("The quick brown fox jumps over the lazy cat")  71bd588d5ad9b6abe87b831b45f8fa95  CHAR(32)
  • 41. Masked Types  UUIDs  HASH functions  Network masks
  • 44. Index the two sides of relations PK
  • 45. Index the two sides of relations Index this guy too!
  • 46. Index the two sides of relations Index this guy too! And this guy!
  • 49. PK is (contract_id, customer_id) (Implied uniqueness) Index “both ways”: (customer_id, contract_id) InnoDB optimization: Don’t index the full (customer_id, contract_id). The index ALREADY HAS customer_id in it’s leafs. So just index (customer_id) N-M relation: Junction tables
  • 51. Don’t operate on fields  Because they can’t use indexes  WHERE column = ‘x’ WHERE column > 2000 WHERE column LIKE ‘prefix%’  WHERE column + 2000 > 2013 WHERE FIND_IN_SET(column) WHERE CONCAT(f1,f2) = “xxxx.com” WHERE YEAR(date) = 2015 WHERE column LIKE ‘%.com’
  • 52. Polish your maths: Algebra Doesn’t use index WHERE column + 2000 > 2013 WHERE FIND_IN_SET(‘pool’,column) WHERE CONCAT(f1,’.’,f2) = “xxxx.com” WHERE YEAR(date) = 2015 WHERE column LIKE ‘%.com’ Uses index WHERE column > 13 ? WHERE f1 = ‘xxxx’ AND f2 = ‘com’ WHERE date BETWEEN ’01-01-2015’ and ’31-12-2015’ ?
  • 53. The old switcheroo… Doesn’t use index WHERE column + 2000 > 2013 WHERE FIND_IN_SET(‘pool’,column) WHERE CONCAT(f1,’.’,f2) = “xxxx.com” WHERE YEAR(date) = 2015 WHERE column LIKE ‘%.com’ Uses index WHERE has_pool = 1 WHERE column_rev LIKE ‘moc.%’
  • 54. The old switcheroo… Doesn’t use index WHERE column + 2000 > 2013 WHERE FIND_IN_SET(‘pool’,column) WHERE CONCAT(f1,’.’,f2) = “xxxx.com” WHERE YEAR(date) = 2015 WHERE column LIKE ‘%.com’ Uses index WHERE has_pool = 1 UPDATE t SET has_pool = FIND_IN_SET(‘pool’,column); WHERE column_rev LIKE ‘moc.%’ UPDATE t SET column_rev=REVERSE(column)
  • 57. Wrap up Schema Data Types How to select them Masked Types Indexes Relations Using them
  • 58. Wrap up  Smaller is better VS