SlideShare uma empresa Scribd logo
1 de 42
MySQL Indexing 
Best Practices for MySQL 5.6 
Peter Zaitsev 
CEO, Percona 
Highload++ 2014, Moscow, Russia 
Nov 1, 2014
www.percona.com 
About Percona 
Open Source 
Software for MySQL 
Ecosystem 
• Percona Server 
• Percona XtraDB 
Cluster (PXC) 
• Percona Xtrabackup 
• Percona Toolkit 
Solutions to succeed 
with MySQL 
• Consulting 
• Support 
• Managed Services 
2
www.percona.com 
You’ve Made a Great Choice ! 
Understanding indexing is crucial both for 
Developers and DBAs 
Poor index choices are responsible for large 
portion of production problems 
Indexing is not a rocket science
www.percona.com 
MySQL Indexing: Agenda 
Understanding Indexing 
Setting up best indexes for your 
applications 
Working around common MySQL 
limitations
www.percona.com 
Indexing in the Nutshell 
• Speed up access in the database 
• Help to enforce constraints 
(UNIQUE, FOREIGN KEY) 
• Queries can be ran without any 
indexes 
• But it can take a really long time 
What 
are 
indexes 
for ?
Types of Indexes you might heard about 
• Majority of indexes you deal in MySQL is 
this type BTREE Indexes 
www.percona.com 
RTREE Indexes • MyISAM only, for GIS 
HASH Indexes • MEMORY, NDB 
FULLTEXT Indexes • MyISAM, Innodb starting 5.6
www.percona.com 
Family of BTREE like Indexes 
• Share same properties in what operations 
they can speed up 
• Memory vs Disk is life changer 
A lot of different 
implementations 
• Data stored in leaf nodes 
B+ Trees are 
typically used for 
Disk storage 
• But physically a lot different 
TokuDB Fractal 
Trees are logically 
similar
www.percona.com 
B+Tree Example 
Branch/Root Node 
Less than 3 
Data Pointers Leaf Node
www.percona.com 
Indexes in MyISAM vs Innodb 
In MyISAM data pointers 
point to physical offset in 
the data file 
• All indexes are 
essentially equivalent 
In Innodb 
• PRIMARY KEY (Explicit 
or Implicit) - stores data 
in the leaf pages of the 
index, not pointer 
• Secondary Indexes – 
store primary key as 
data pointer
What Operations can BTREE Index do ? 
Find all rows with KEY=5 (point lookup) 
www.percona.com 
Find all rows with KEY>5 (open range) 
Find all rows with 5<KEY<10 (closed range) 
NOT find all rows with last digit of the KEY is Zero 
• This can’t be defined as a “range” operation
www.percona.com 
String Indexes 
• Sort order is defined for strings 
(collation) 
• “AAAA” < “AAAB” 
There is no 
difference… 
really 
• LIKE “ABC%” means 
• “ABC[LOWEST]”<KEY<“ABC[HIGHEST]” 
• LIKE “%ABC” can’t be optimized by use 
of the index 
Prefix LIKE is 
a special type 
of Range
www.percona.com 
Multiple Column Indexes 
•KEY(col1,col2,col3) 
•(1,2,3) < (1,3,1) 
Sort Order is 
defined, 
comparing leading 
column, then 
second etc 
•not a separate BTREE 
index for each level 
It is still one BTREE 
Index
www.percona.com 
Overhead of The Indexing 
Indexes are costly; Do not add more than you 
need 
• In most cases extending index is better than adding new one 
Writes - Updating indexes is often major cost of 
database writes 
Reads - Wasted space on disk and in memory; 
additional overhead during query optimization
www.percona.com 
Indexing Innodb Tables 
• Pick PRIMARY KEY what suites you best 
• For comments – (POST_ID,COMMENT_ID) can be 
good PRIMARY KEY storing all comments for 
single post close together 
• Alternatively “pack” to single BIGINT 
Data is 
clustered by 
Primary Key 
• KEY (A) is really KEY (A,ID) internally 
• Useful for sorting, Covering Index. 
PRIMARY KEY 
is implicitly 
appended to 
all indexes
www.percona.com 
How MySQL Uses Indexes 
Data Lookups 
Sorting 
Avoiding reading “data” 
Special Optimizations
www.percona.com 
Using Indexes for Data Lookups 
• The classical use of index on 
(LAST_NAME) 
SELECT * FROM 
EMPLOYEES WHERE 
LAST_NAME=“Smith” 
• SELECT * FROM EMPLOYEES WHERE 
LAST_NAME=“Smith” AND 
DEPT=“Accounting” 
• Will use index on (DEPT,LAST_NAME) 
Can use Multiple 
column indexes
www.percona.com 
It Gets Tricky With Multiple Columns 
Index (A,B,C) •- order of columns matters 
•A>5 
•A=5 AND B>6 
•A=5 AND B=6 AND C=7 
•A=5 AND B IN (2,3) AND C>5 
Will use Index for lookup 
(all listed keyparts) 
•B>5 – Leading column is not referenced 
•B=6 AND C=7 - Leading column is not referenced Will NOT use Index 
•A>5 AND B=2 - range on first column; only use this key part 
•A=5 AND B>6 AND C=2 - range on second column, use 2 parts Will use Part of the index
www.percona.com 
The First Rule of MySQL Optimizer 
MySQL will stop using key parts in 
multi part index as soon as it met 
the real range (<,>, BETWEEN), it 
however is able to continue using 
key parts further to the right if 
IN(…) range is used
www.percona.com 
Using Index for Sorting 
• Will use index on SCORE column 
• Without index MySQL will do “filesort” 
(external sort) which is very expensive 
SELECT * FROM 
PLAYERS ORDER 
BY SCORE DESC 
LIMIT 10 
• SELECT * FROM PLAYERS WHERE 
COUNTRY=“US” ORDER BY SCORE DESC LIMIT 
10 
• Best served by Index on (COUNTRY,SCORE) 
Often 
Combined with 
using Index for 
lookup
Multi Column indexes for efficient sorting 
www.percona.com 
• It becomes even more restricted! 
• KEY(A,B) 
• Will use Index for Sorting 
– ORDER BY A - sorting by leading column 
– A=5 ORDER BY B - EQ filtering by 1st and sorting by 2nd 
– ORDER BY A DESC, B DESC - Sorting by 2 columns in same order 
– A>5 ORDER BY A - Range on the column, sorting on the same 
• Will NOT use Index for Sorting 
– ORDER BY B - Sorting by second column in the index 
– A>5 ORDER BY B – Range on first column, sorting by second 
– A IN(1,2) ORDER BY B - In-Range on first column 
– ORDER BY A ASC, B DESC - Sorting in the different order
www.percona.com 
MySQL Using Index for Sorting Rules 
You can’t sort in different order by 2 columns 
You can only have Equality comparison (=) 
for columns which are not part of ORDER BY 
• Not even IN() works in this case
www.percona.com 
Avoiding Reading The data 
• Applies to index use for specific query, 
not type of index. 
“Covering Index” 
• Index is typically smaller than data Reading Index ONLY and 
not accessing the “data” 
• KEY(CUSTOMER_ID,STATUS) 
SELECT STATUS FROM 
ORDERS WHERE 
CUSTOMER_ID=123 
• Access through data pointers is often 
quite “random” 
Access is a lot more 
sequential
www.percona.com 
Min/Max Optimizations 
• Index help MIN()/MAX() aggregate functions 
– But only these 
• SELECT MAX(ID) FROM TBL; 
• SELECT MAX(SALARY) FROM EMPLOYEE 
GROUP BY DEPT_ID 
– Will benefit from (DEPT_ID,SALARY) index 
– “Using index for group-by”
www.percona.com 
Indexes and Joins 
• SELECT * FROM POSTS,COMMENTS WHERE AUTHOR=“Peter” AND 
COMMENTS.POST_ID=POSTS.ID 
• Scan table POSTS finding all posts which have Peter as an Author 
• For every such post go to COMMENTS table to fetch all comments 
MySQL Performs 
Joins as “Nested 
Loops” 
• The index on POSTS.ID is not needed for this query performance 
Index is only needed 
on table which is 
being looked up 
• Re-Design JOIN queries which can’t be well indexed 
Very important to 
have all JOINs 
Indexed
www.percona.com 
Using Multiple Indexes for the table 
• “Index Merge” 
MySQL Can use 
More than one 
index 
• Can often use Indexes on (A) and (B) 
separately 
• Index on (A,B) is much better 
SELECT * FROM 
TBL WHERE A=5 
AND B=6 
• 2 separate indexes is as good as it gets 
• Index (A,B) can’t be used for this query 
SELECT * FROM 
TBL WHERE A=5 
OR B=6
www.percona.com 
Prefix Indexes 
• ALTER TABLE TITLE ADD 
KEY(TITLE(20)); 
• Needed to index BLOB/TEXT 
columns 
• Can be significantly smaller 
• Can’t be used as covering index 
• Choosing prefix length becomes the 
question 
You can 
build Index 
on the 
leftmost 
prefix of 
the column
www.percona.com 
Choosing Prefix Length 
• Prefix should be “Selective enough” 
– Check number of distinct prefixes vs number of 
total distinct values 
mysql> select count(distinct(title)) total, 
count(distinct(left(title,10))) p10, 
count(distinct(left(title,20))) p20 from title; 
+--------+--------+--------+ 
| total | p10 | p20 | 
+--------+--------+--------+ 
| 998335 | 624949 | 960894 | 
+--------+--------+--------+ 
1 row in set (44.19 sec)
Most common Titles Most Common Title Prefixes 
www.percona.com 
Choosing Prefix Length 
• Check for Outliers 
– Ensure there are not too many rows sharing the 
same prefix 
mysql> select count(*) cnt, title tl 
from title group by tl order by cnt desc 
limit 3; 
+-----+-----------------+ 
| cnt | tl | 
+-----+-----------------+ 
| 136 | The Wedding | 
| 129 | Lost and Found | 
| 112 | Horror Marathon | 
+-----+-----------------+ 
3 rows in set (27.49 sec) 
mysql> select count(*) cnt, left(title,20) tl 
from title group by tl order by cnt desc 
limit 3; 
+-----+----------------------+ 
| cnt | tl | 
+-----+----------------------+ 
| 184 | Wetten, dass..? aus | 
| 136 | The Wedding | 
| 129 | Lost and Found | 
+-----+----------------------+ 
3 rows in set (33.23 sec)
www.percona.com 
What is new with MySQL 5.6 ? 
• Most of them will make your queries better 
automatically 
• join_buffer_size variable has whole new meaning 
• Values if 32MB+ can make sense 
Many Optimizer 
improvements 
• Most important one: ICP (Index Condition 
Pushdown) 
Focus on Index 
Design Practices 
for this 
presentation
www.percona.com 
Understanding ICP 
• Think NAME LIKE “%ill%” (will not 
convert to range) 
Push where clause 
“Conditions” for 
Storage engine to filter 
• Plus filtering done on the engine level 
– efficient 
“Much more flexible 
covering Index” 
• All or none. All is resolved through the 
index or “row” is read if within range 
Before MySQL 5.5
www.percona.com 
ICP Examples 
• SELECT A … WHERE B=2 AND C LIKE “%ill%’ 
– MySQL 5.5 and below 
• KEY (B) – Traditional. Using index for range only 
• KEY (B,C,A) - Covering. All involved columns included 
– MySQL 5.6 
• KEY(B,C) 
– Range access by B; Filter clause on C only read full row if match 
• More cases 
– SELECT * …WHERE A=5 and C=6 ; KEY (A,B,C) 
• Will scan all index entries with A=5 not all rows
How MySQL Picks which Index to Use ? 
• The constants in query texts 
matter a lot 
www.percona.com 
Performs dynamic 
picking for every 
query execution 
• by doing “dive” in the table 
Estimates number of 
rows it needs to 
access for given index 
• This is what ANALYZE TABLE 
updates 
Uses “Cardinality” 
statistics if impossible
www.percona.com 
More on Picking the Index 
• Looking to minimize the “cost” not query performance 
Not Just minimizing 
number of scanned 
rows 
•PRIMARY Key is special for Innodb 
•Covering Index benefits 
•Full table scan is faster, all being equal 
•Can we also use index for Sorting 
Lots of other 
heuristics and 
hacks 
•Verify plan MySQL is actually using 
•Note it can change dynamically based on constants and data Things to know
www.percona.com 
Use EXPLAIN 
• EXPLAIN is a great tool to see how MySQL 
plans to execute the query 
– http://dev.mysql.com/doc/refman/5.6/en/using-explain. 
html 
– Remember real execution might be different 
mysql> explain select max(season_nr) from title group by production_year; 
+----+-------------+-------+-------+---------------+-----------------+---------+------+------+--------------------------+ 
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | 
+----+-------------+-------+-------+---------------+-----------------+---------+------+------+--------------------------+ 
| 1 | SIMPLE | title | range | NULL | production_year | 5 | NULL | 201 | Using index for group-by | 
+----+-------------+-------+-------+---------------+-----------------+---------+------+------+--------------------------+ 
1 row in set (0.01 sec)
www.percona.com 
Indexing Strategy 
• Look at them together not just one by 
one 
Build indexes for set of 
your performance critical 
queries 
• At least most selective parts are 
Best if all WHERE clause 
and JOIN clauses are using 
indexes for lookups 
• There are some exceptions 
Generally extend index if 
you can, instead of 
creating new indexes 
• Revisit Performance of All Queries! 
Validate performance 
impact as you’re doing 
changes
www.percona.com 
MySQL 5.6 JSON EXPLAIN FORMAT 
mysql> EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t2 ON t1.i = t2.i WHERE t1.j > 1 
AND t2.j < 3; 
| { 
"query_block": { 
"select_id": 1, 
"nested_loop": [ 
{ 
"table": { 
"table_name": "t1", 
"access_type": "ALL", 
"rows": 3, 
"filtered": 100, 
"attached_condition": "((`test`.`t1`.`j` > 1) and (`test`.`t1`.`i` is not null))" 
} /* table */ 
}, 
….
www.percona.com 
Indexing Strategy Example 
• SELECT * FROM TBL WHERE A=5 AND B=6 
• SELECT * FROM TBL WHERE A>5 AND B=6 
• KEY (B,A) Is better for such query mix 
Build Index order 
which benefits more 
queries 
• Do not start with this! 
All being equal put 
more selective key 
part first 
• Many indexes slow system down 
Do not add indexes 
for non performance 
critical queries
www.percona.com 
Tools ? 
• Percona Toolkit 
– Pt-query-digest 
• Percona Cloud Tools 
– http://cloud.percona.com
www.percona.com 
Trick #1: Enumerating Ranges 
• Assume we need to stick to 
this order 
KEY (A,B) 
• Will only use first key part of 
the index 
SELECT * FROM TBL 
WHERE A BETWEEN 
2 AND 4 AND B=5 
• Will use both key parts 
SELECT * FROM TBL 
WHERE A IN (2,3,4) 
AND B=5
www.percona.com 
Trick #2: Adding Fake Filter 
KEY (GENDER,CITY) • Want to use one index only 
• Will not be able to use the index at all SELECT * FROM PEOPLE 
WHERE CITY=“NEW YORK” 
• Will be able to use the index 
SELECT * FROM PEOPLE 
WHERE GENDER IN (“M”,”F”) 
AND CITY=“NEW YORK” 
• Gender, Status, Boolean Types etc The trick works best with low 
selectivity columns.
www.percona.com 
Trick #3: Unionizing Filesort 
KEY(A,B) • No Other key would work ether 
• Will not be able to use index for 
SORTING 
SELECT * FROM TBL WHERE A 
IN (1,2) ORDER BY B LIMIT 5; 
• Will use the index for Sorting. “filesort” 
will be needed only to sort over 10 rows. 
(SELECT * FROM TBL WHERE 
A=1 ORDER BY B LIMIT 5) 
UNION ALL (SELECT * FROM 
TBL WHERE A=2 ORDER BY B 
LIMIT 5) ORDER BY B LIMIT 5;
www.percona.com 
Thank You ! 
• pz@percona.com 
• http://www.percona.com 
• @percona at Twitter 
• http://www.facebook.com/Percona

Mais conteúdo relacionado

Mais procurados

Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Jaime Crespo
 
MySQL Indexing
MySQL IndexingMySQL Indexing
MySQL IndexingBADR
 
How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15oysteing
 
Optimizer overviewoow2014
Optimizer overviewoow2014Optimizer overviewoow2014
Optimizer overviewoow2014Mysql User Camp
 
Multi faceted responsive search, autocomplete, feeds engine & logging
Multi faceted responsive search, autocomplete, feeds engine & loggingMulti faceted responsive search, autocomplete, feeds engine & logging
Multi faceted responsive search, autocomplete, feeds engine & logginglucenerevolution
 
MySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesMySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesIsaac Mosquera
 
Goldilocks and the Three MySQL Queries
Goldilocks and the Three MySQL QueriesGoldilocks and the Three MySQL Queries
Goldilocks and the Three MySQL QueriesDave Stokes
 
MySQL Optimizer Overview
MySQL Optimizer OverviewMySQL Optimizer Overview
MySQL Optimizer OverviewOlav Sandstå
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
 
Юра Гуляев. Oracle tables
Юра Гуляев. Oracle tablesЮра Гуляев. Oracle tables
Юра Гуляев. Oracle tablesAleksandr Motsjonov
 
Optimizing queries MySQL
Optimizing queries MySQLOptimizing queries MySQL
Optimizing queries MySQLGeorgi Sotirov
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
 
New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 Richie Rump
 
Database indexing framework
Database indexing frameworkDatabase indexing framework
Database indexing frameworkNitin Pande
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
 
How to Fine-Tune Performance Using Amazon Redshift
How to Fine-Tune Performance Using Amazon RedshiftHow to Fine-Tune Performance Using Amazon Redshift
How to Fine-Tune Performance Using Amazon RedshiftAWS Germany
 
Database index
Database indexDatabase index
Database indexRiteshkiit
 
Top 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsTop 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsNirav Shah
 

Mais procurados (20)

Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
 
MySQL Indexing
MySQL IndexingMySQL Indexing
MySQL Indexing
 
How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15How to analyze and tune sql queries for better performance percona15
How to analyze and tune sql queries for better performance percona15
 
Optimizer overviewoow2014
Optimizer overviewoow2014Optimizer overviewoow2014
Optimizer overviewoow2014
 
San diegophp
San diegophpSan diegophp
San diegophp
 
Multi faceted responsive search, autocomplete, feeds engine & logging
Multi faceted responsive search, autocomplete, feeds engine & loggingMulti faceted responsive search, autocomplete, feeds engine & logging
Multi faceted responsive search, autocomplete, feeds engine & logging
 
MySQL Performance Tips & Best Practices
MySQL Performance Tips & Best PracticesMySQL Performance Tips & Best Practices
MySQL Performance Tips & Best Practices
 
Goldilocks and the Three MySQL Queries
Goldilocks and the Three MySQL QueriesGoldilocks and the Three MySQL Queries
Goldilocks and the Three MySQL Queries
 
MySQL Optimizer Overview
MySQL Optimizer OverviewMySQL Optimizer Overview
MySQL Optimizer Overview
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
Юра Гуляев. Oracle tables
Юра Гуляев. Oracle tablesЮра Гуляев. Oracle tables
Юра Гуляев. Oracle tables
 
Optimizing queries MySQL
Optimizing queries MySQLOptimizing queries MySQL
Optimizing queries MySQL
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012
 
Table functions - Planboard Symposium 2013
Table functions - Planboard Symposium 2013Table functions - Planboard Symposium 2013
Table functions - Planboard Symposium 2013
 
Database indexing framework
Database indexing frameworkDatabase indexing framework
Database indexing framework
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
How to Fine-Tune Performance Using Amazon Redshift
How to Fine-Tune Performance Using Amazon RedshiftHow to Fine-Tune Performance Using Amazon Redshift
How to Fine-Tune Performance Using Amazon Redshift
 
Database index
Database indexDatabase index
Database index
 
Top 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsTop 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tips
 

Destaque

Оптимизация программ для современных процессоров и Linux, Александр Крижановс...
Оптимизация программ для современных процессоров и Linux, Александр Крижановс...Оптимизация программ для современных процессоров и Linux, Александр Крижановс...
Оптимизация программ для современных процессоров и Linux, Александр Крижановс...Ontico
 
Лекция 6: Словари. Хеш-таблицы
Лекция 6: Словари. Хеш-таблицыЛекция 6: Словари. Хеш-таблицы
Лекция 6: Словари. Хеш-таблицыMikhail Kurnosov
 
Linux Kernel Extension for Databases / Александр Крижановский (Tempesta Techn...
Linux Kernel Extension for Databases / Александр Крижановский (Tempesta Techn...Linux Kernel Extension for Databases / Александр Крижановский (Tempesta Techn...
Linux Kernel Extension for Databases / Александр Крижановский (Tempesta Techn...Ontico
 
MySQL 5.7 - NoSQL - JSON, Protocol X, Document Store / Петр Зайцев (Percona)
MySQL 5.7 - NoSQL - JSON, Protocol X, Document Store / Петр Зайцев (Percona)MySQL 5.7 - NoSQL - JSON, Protocol X, Document Store / Петр Зайцев (Percona)
MySQL 5.7 - NoSQL - JSON, Protocol X, Document Store / Петр Зайцев (Percona)Ontico
 
MySQL® и MongoDB® - когда что лучше использовать? / Петр Зайцев (Percona)
MySQL® и MongoDB® - когда что лучше использовать? / Петр Зайцев (Percona)MySQL® и MongoDB® - когда что лучше использовать? / Петр Зайцев (Percona)
MySQL® и MongoDB® - когда что лучше использовать? / Петр Зайцев (Percona)Ontico
 
Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!Trygve Vea
 

Destaque (7)

Оптимизация программ для современных процессоров и Linux, Александр Крижановс...
Оптимизация программ для современных процессоров и Linux, Александр Крижановс...Оптимизация программ для современных процессоров и Linux, Александр Крижановс...
Оптимизация программ для современных процессоров и Linux, Александр Крижановс...
 
Лекция 6: Словари. Хеш-таблицы
Лекция 6: Словари. Хеш-таблицыЛекция 6: Словари. Хеш-таблицы
Лекция 6: Словари. Хеш-таблицы
 
Linux Kernel Extension for Databases / Александр Крижановский (Tempesta Techn...
Linux Kernel Extension for Databases / Александр Крижановский (Tempesta Techn...Linux Kernel Extension for Databases / Александр Крижановский (Tempesta Techn...
Linux Kernel Extension for Databases / Александр Крижановский (Tempesta Techn...
 
How to monitor NGINX
How to monitor NGINXHow to monitor NGINX
How to monitor NGINX
 
MySQL 5.7 - NoSQL - JSON, Protocol X, Document Store / Петр Зайцев (Percona)
MySQL 5.7 - NoSQL - JSON, Protocol X, Document Store / Петр Зайцев (Percona)MySQL 5.7 - NoSQL - JSON, Protocol X, Document Store / Петр Зайцев (Percona)
MySQL 5.7 - NoSQL - JSON, Protocol X, Document Store / Петр Зайцев (Percona)
 
MySQL® и MongoDB® - когда что лучше использовать? / Петр Зайцев (Percona)
MySQL® и MongoDB® - когда что лучше использовать? / Петр Зайцев (Percona)MySQL® и MongoDB® - когда что лучше использовать? / Петр Зайцев (Percona)
MySQL® и MongoDB® - когда что лучше использовать? / Петр Зайцев (Percona)
 
Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!
 

Semelhante a Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona)

MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MYXPLAIN
 
PostgreSQL 9.0 & The Future
PostgreSQL 9.0 & The FuturePostgreSQL 9.0 & The Future
PostgreSQL 9.0 & The FutureAaron Thul
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performanceguest9912e5
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersJonathan Levin
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server DatabasesColdFusionConference
 
10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQLSatoshi Nagayasu
 
MYSQL Query Anti-Patterns That Can Be Moved to Sphinx
MYSQL Query Anti-Patterns That Can Be Moved to SphinxMYSQL Query Anti-Patterns That Can Be Moved to Sphinx
MYSQL Query Anti-Patterns That Can Be Moved to SphinxPythian
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksMYXPLAIN
 
Webinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuningWebinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuning晓 周
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007paulguerin
 
Geek Sync I Consolidating Indexes in SQL Server
Geek Sync I Consolidating Indexes in SQL ServerGeek Sync I Consolidating Indexes in SQL Server
Geek Sync I Consolidating Indexes in SQL ServerIDERA Software
 
Amazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and OptimizationAmazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and OptimizationAmazon Web Services
 
02 database oprimization - improving sql performance - ent-db
02  database oprimization - improving sql performance - ent-db02  database oprimization - improving sql performance - ent-db
02 database oprimization - improving sql performance - ent-dbuncleRhyme
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sIntroduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sSveta Smirnova
 
MySQL: Know more about open Source Database
MySQL: Know more about open Source DatabaseMySQL: Know more about open Source Database
MySQL: Know more about open Source DatabaseMahesh Salaria
 
Geek Sync | Why Did My Clever Index Change Backfire?
Geek Sync | Why Did My Clever Index Change Backfire?Geek Sync | Why Did My Clever Index Change Backfire?
Geek Sync | Why Did My Clever Index Change Backfire?IDERA Software
 

Semelhante a Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona) (20)

MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6
 
PostgreSQL 9.0 & The Future
PostgreSQL 9.0 & The FuturePostgreSQL 9.0 & The Future
PostgreSQL 9.0 & The Future
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance
 
Statistics and Indexes Internals
Statistics and Indexes InternalsStatistics and Indexes Internals
Statistics and Indexes Internals
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for Developers
 
Tunning overview
Tunning overviewTunning overview
Tunning overview
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL
 
MYSQL Query Anti-Patterns That Can Be Moved to Sphinx
MYSQL Query Anti-Patterns That Can Be Moved to SphinxMYSQL Query Anti-Patterns That Can Be Moved to Sphinx
MYSQL Query Anti-Patterns That Can Be Moved to Sphinx
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New Tricks
 
Webinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuningWebinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuning
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007
 
Geek Sync I Consolidating Indexes in SQL Server
Geek Sync I Consolidating Indexes in SQL ServerGeek Sync I Consolidating Indexes in SQL Server
Geek Sync I Consolidating Indexes in SQL Server
 
Optimizing MySQL queries
Optimizing MySQL queriesOptimizing MySQL queries
Optimizing MySQL queries
 
MySQL Indexes
MySQL IndexesMySQL Indexes
MySQL Indexes
 
Amazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and OptimizationAmazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and Optimization
 
02 database oprimization - improving sql performance - ent-db
02  database oprimization - improving sql performance - ent-db02  database oprimization - improving sql performance - ent-db
02 database oprimization - improving sql performance - ent-db
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sIntroduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]s
 
MySQL: Know more about open Source Database
MySQL: Know more about open Source DatabaseMySQL: Know more about open Source Database
MySQL: Know more about open Source Database
 
Geek Sync | Why Did My Clever Index Change Backfire?
Geek Sync | Why Did My Clever Index Change Backfire?Geek Sync | Why Did My Clever Index Change Backfire?
Geek Sync | Why Did My Clever Index Change Backfire?
 

Mais de Ontico

One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...Ontico
 
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)Ontico
 
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)Ontico
 
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...Ontico
 
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...Ontico
 
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)Ontico
 
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...Ontico
 
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...Ontico
 
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)Ontico
 
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)Ontico
 
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...Ontico
 
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...Ontico
 
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...Ontico
 
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)Ontico
 
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)Ontico
 
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)Ontico
 
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)Ontico
 
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...Ontico
 
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...Ontico
 
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...Ontico
 

Mais de Ontico (20)

One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
 
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
 
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
 
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
 
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
 
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
 
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
 
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
 
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
 
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
 
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
 
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
 
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
 
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
 
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
 
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
 
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
 
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...100500 способов кэширования в Oracle Database или как достичь максимальной ск...
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
 
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
 
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
 

Último

Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMagic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMartaLoveguard
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Lucknow
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一Fs
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一Fs
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Excelmac1
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Dana Luther
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 

Último (20)

Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMagic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptx
 
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja VipCall Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
Call Girls Service Adil Nagar 7001305949 Need escorts Service Pooja Vip
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
定制(UAL学位证)英国伦敦艺术大学毕业证成绩单原版一比一
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 

Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona)

  • 1. MySQL Indexing Best Practices for MySQL 5.6 Peter Zaitsev CEO, Percona Highload++ 2014, Moscow, Russia Nov 1, 2014
  • 2. www.percona.com About Percona Open Source Software for MySQL Ecosystem • Percona Server • Percona XtraDB Cluster (PXC) • Percona Xtrabackup • Percona Toolkit Solutions to succeed with MySQL • Consulting • Support • Managed Services 2
  • 3. www.percona.com You’ve Made a Great Choice ! Understanding indexing is crucial both for Developers and DBAs Poor index choices are responsible for large portion of production problems Indexing is not a rocket science
  • 4. www.percona.com MySQL Indexing: Agenda Understanding Indexing Setting up best indexes for your applications Working around common MySQL limitations
  • 5. www.percona.com Indexing in the Nutshell • Speed up access in the database • Help to enforce constraints (UNIQUE, FOREIGN KEY) • Queries can be ran without any indexes • But it can take a really long time What are indexes for ?
  • 6. Types of Indexes you might heard about • Majority of indexes you deal in MySQL is this type BTREE Indexes www.percona.com RTREE Indexes • MyISAM only, for GIS HASH Indexes • MEMORY, NDB FULLTEXT Indexes • MyISAM, Innodb starting 5.6
  • 7. www.percona.com Family of BTREE like Indexes • Share same properties in what operations they can speed up • Memory vs Disk is life changer A lot of different implementations • Data stored in leaf nodes B+ Trees are typically used for Disk storage • But physically a lot different TokuDB Fractal Trees are logically similar
  • 8. www.percona.com B+Tree Example Branch/Root Node Less than 3 Data Pointers Leaf Node
  • 9. www.percona.com Indexes in MyISAM vs Innodb In MyISAM data pointers point to physical offset in the data file • All indexes are essentially equivalent In Innodb • PRIMARY KEY (Explicit or Implicit) - stores data in the leaf pages of the index, not pointer • Secondary Indexes – store primary key as data pointer
  • 10. What Operations can BTREE Index do ? Find all rows with KEY=5 (point lookup) www.percona.com Find all rows with KEY>5 (open range) Find all rows with 5<KEY<10 (closed range) NOT find all rows with last digit of the KEY is Zero • This can’t be defined as a “range” operation
  • 11. www.percona.com String Indexes • Sort order is defined for strings (collation) • “AAAA” < “AAAB” There is no difference… really • LIKE “ABC%” means • “ABC[LOWEST]”<KEY<“ABC[HIGHEST]” • LIKE “%ABC” can’t be optimized by use of the index Prefix LIKE is a special type of Range
  • 12. www.percona.com Multiple Column Indexes •KEY(col1,col2,col3) •(1,2,3) < (1,3,1) Sort Order is defined, comparing leading column, then second etc •not a separate BTREE index for each level It is still one BTREE Index
  • 13. www.percona.com Overhead of The Indexing Indexes are costly; Do not add more than you need • In most cases extending index is better than adding new one Writes - Updating indexes is often major cost of database writes Reads - Wasted space on disk and in memory; additional overhead during query optimization
  • 14. www.percona.com Indexing Innodb Tables • Pick PRIMARY KEY what suites you best • For comments – (POST_ID,COMMENT_ID) can be good PRIMARY KEY storing all comments for single post close together • Alternatively “pack” to single BIGINT Data is clustered by Primary Key • KEY (A) is really KEY (A,ID) internally • Useful for sorting, Covering Index. PRIMARY KEY is implicitly appended to all indexes
  • 15. www.percona.com How MySQL Uses Indexes Data Lookups Sorting Avoiding reading “data” Special Optimizations
  • 16. www.percona.com Using Indexes for Data Lookups • The classical use of index on (LAST_NAME) SELECT * FROM EMPLOYEES WHERE LAST_NAME=“Smith” • SELECT * FROM EMPLOYEES WHERE LAST_NAME=“Smith” AND DEPT=“Accounting” • Will use index on (DEPT,LAST_NAME) Can use Multiple column indexes
  • 17. www.percona.com It Gets Tricky With Multiple Columns Index (A,B,C) •- order of columns matters •A>5 •A=5 AND B>6 •A=5 AND B=6 AND C=7 •A=5 AND B IN (2,3) AND C>5 Will use Index for lookup (all listed keyparts) •B>5 – Leading column is not referenced •B=6 AND C=7 - Leading column is not referenced Will NOT use Index •A>5 AND B=2 - range on first column; only use this key part •A=5 AND B>6 AND C=2 - range on second column, use 2 parts Will use Part of the index
  • 18. www.percona.com The First Rule of MySQL Optimizer MySQL will stop using key parts in multi part index as soon as it met the real range (<,>, BETWEEN), it however is able to continue using key parts further to the right if IN(…) range is used
  • 19. www.percona.com Using Index for Sorting • Will use index on SCORE column • Without index MySQL will do “filesort” (external sort) which is very expensive SELECT * FROM PLAYERS ORDER BY SCORE DESC LIMIT 10 • SELECT * FROM PLAYERS WHERE COUNTRY=“US” ORDER BY SCORE DESC LIMIT 10 • Best served by Index on (COUNTRY,SCORE) Often Combined with using Index for lookup
  • 20. Multi Column indexes for efficient sorting www.percona.com • It becomes even more restricted! • KEY(A,B) • Will use Index for Sorting – ORDER BY A - sorting by leading column – A=5 ORDER BY B - EQ filtering by 1st and sorting by 2nd – ORDER BY A DESC, B DESC - Sorting by 2 columns in same order – A>5 ORDER BY A - Range on the column, sorting on the same • Will NOT use Index for Sorting – ORDER BY B - Sorting by second column in the index – A>5 ORDER BY B – Range on first column, sorting by second – A IN(1,2) ORDER BY B - In-Range on first column – ORDER BY A ASC, B DESC - Sorting in the different order
  • 21. www.percona.com MySQL Using Index for Sorting Rules You can’t sort in different order by 2 columns You can only have Equality comparison (=) for columns which are not part of ORDER BY • Not even IN() works in this case
  • 22. www.percona.com Avoiding Reading The data • Applies to index use for specific query, not type of index. “Covering Index” • Index is typically smaller than data Reading Index ONLY and not accessing the “data” • KEY(CUSTOMER_ID,STATUS) SELECT STATUS FROM ORDERS WHERE CUSTOMER_ID=123 • Access through data pointers is often quite “random” Access is a lot more sequential
  • 23. www.percona.com Min/Max Optimizations • Index help MIN()/MAX() aggregate functions – But only these • SELECT MAX(ID) FROM TBL; • SELECT MAX(SALARY) FROM EMPLOYEE GROUP BY DEPT_ID – Will benefit from (DEPT_ID,SALARY) index – “Using index for group-by”
  • 24. www.percona.com Indexes and Joins • SELECT * FROM POSTS,COMMENTS WHERE AUTHOR=“Peter” AND COMMENTS.POST_ID=POSTS.ID • Scan table POSTS finding all posts which have Peter as an Author • For every such post go to COMMENTS table to fetch all comments MySQL Performs Joins as “Nested Loops” • The index on POSTS.ID is not needed for this query performance Index is only needed on table which is being looked up • Re-Design JOIN queries which can’t be well indexed Very important to have all JOINs Indexed
  • 25. www.percona.com Using Multiple Indexes for the table • “Index Merge” MySQL Can use More than one index • Can often use Indexes on (A) and (B) separately • Index on (A,B) is much better SELECT * FROM TBL WHERE A=5 AND B=6 • 2 separate indexes is as good as it gets • Index (A,B) can’t be used for this query SELECT * FROM TBL WHERE A=5 OR B=6
  • 26. www.percona.com Prefix Indexes • ALTER TABLE TITLE ADD KEY(TITLE(20)); • Needed to index BLOB/TEXT columns • Can be significantly smaller • Can’t be used as covering index • Choosing prefix length becomes the question You can build Index on the leftmost prefix of the column
  • 27. www.percona.com Choosing Prefix Length • Prefix should be “Selective enough” – Check number of distinct prefixes vs number of total distinct values mysql> select count(distinct(title)) total, count(distinct(left(title,10))) p10, count(distinct(left(title,20))) p20 from title; +--------+--------+--------+ | total | p10 | p20 | +--------+--------+--------+ | 998335 | 624949 | 960894 | +--------+--------+--------+ 1 row in set (44.19 sec)
  • 28. Most common Titles Most Common Title Prefixes www.percona.com Choosing Prefix Length • Check for Outliers – Ensure there are not too many rows sharing the same prefix mysql> select count(*) cnt, title tl from title group by tl order by cnt desc limit 3; +-----+-----------------+ | cnt | tl | +-----+-----------------+ | 136 | The Wedding | | 129 | Lost and Found | | 112 | Horror Marathon | +-----+-----------------+ 3 rows in set (27.49 sec) mysql> select count(*) cnt, left(title,20) tl from title group by tl order by cnt desc limit 3; +-----+----------------------+ | cnt | tl | +-----+----------------------+ | 184 | Wetten, dass..? aus | | 136 | The Wedding | | 129 | Lost and Found | +-----+----------------------+ 3 rows in set (33.23 sec)
  • 29. www.percona.com What is new with MySQL 5.6 ? • Most of them will make your queries better automatically • join_buffer_size variable has whole new meaning • Values if 32MB+ can make sense Many Optimizer improvements • Most important one: ICP (Index Condition Pushdown) Focus on Index Design Practices for this presentation
  • 30. www.percona.com Understanding ICP • Think NAME LIKE “%ill%” (will not convert to range) Push where clause “Conditions” for Storage engine to filter • Plus filtering done on the engine level – efficient “Much more flexible covering Index” • All or none. All is resolved through the index or “row” is read if within range Before MySQL 5.5
  • 31. www.percona.com ICP Examples • SELECT A … WHERE B=2 AND C LIKE “%ill%’ – MySQL 5.5 and below • KEY (B) – Traditional. Using index for range only • KEY (B,C,A) - Covering. All involved columns included – MySQL 5.6 • KEY(B,C) – Range access by B; Filter clause on C only read full row if match • More cases – SELECT * …WHERE A=5 and C=6 ; KEY (A,B,C) • Will scan all index entries with A=5 not all rows
  • 32. How MySQL Picks which Index to Use ? • The constants in query texts matter a lot www.percona.com Performs dynamic picking for every query execution • by doing “dive” in the table Estimates number of rows it needs to access for given index • This is what ANALYZE TABLE updates Uses “Cardinality” statistics if impossible
  • 33. www.percona.com More on Picking the Index • Looking to minimize the “cost” not query performance Not Just minimizing number of scanned rows •PRIMARY Key is special for Innodb •Covering Index benefits •Full table scan is faster, all being equal •Can we also use index for Sorting Lots of other heuristics and hacks •Verify plan MySQL is actually using •Note it can change dynamically based on constants and data Things to know
  • 34. www.percona.com Use EXPLAIN • EXPLAIN is a great tool to see how MySQL plans to execute the query – http://dev.mysql.com/doc/refman/5.6/en/using-explain. html – Remember real execution might be different mysql> explain select max(season_nr) from title group by production_year; +----+-------------+-------+-------+---------------+-----------------+---------+------+------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+---------------+-----------------+---------+------+------+--------------------------+ | 1 | SIMPLE | title | range | NULL | production_year | 5 | NULL | 201 | Using index for group-by | +----+-------------+-------+-------+---------------+-----------------+---------+------+------+--------------------------+ 1 row in set (0.01 sec)
  • 35. www.percona.com Indexing Strategy • Look at them together not just one by one Build indexes for set of your performance critical queries • At least most selective parts are Best if all WHERE clause and JOIN clauses are using indexes for lookups • There are some exceptions Generally extend index if you can, instead of creating new indexes • Revisit Performance of All Queries! Validate performance impact as you’re doing changes
  • 36. www.percona.com MySQL 5.6 JSON EXPLAIN FORMAT mysql> EXPLAIN FORMAT=JSON SELECT * FROM t1 JOIN t2 ON t1.i = t2.i WHERE t1.j > 1 AND t2.j < 3; | { "query_block": { "select_id": 1, "nested_loop": [ { "table": { "table_name": "t1", "access_type": "ALL", "rows": 3, "filtered": 100, "attached_condition": "((`test`.`t1`.`j` > 1) and (`test`.`t1`.`i` is not null))" } /* table */ }, ….
  • 37. www.percona.com Indexing Strategy Example • SELECT * FROM TBL WHERE A=5 AND B=6 • SELECT * FROM TBL WHERE A>5 AND B=6 • KEY (B,A) Is better for such query mix Build Index order which benefits more queries • Do not start with this! All being equal put more selective key part first • Many indexes slow system down Do not add indexes for non performance critical queries
  • 38. www.percona.com Tools ? • Percona Toolkit – Pt-query-digest • Percona Cloud Tools – http://cloud.percona.com
  • 39. www.percona.com Trick #1: Enumerating Ranges • Assume we need to stick to this order KEY (A,B) • Will only use first key part of the index SELECT * FROM TBL WHERE A BETWEEN 2 AND 4 AND B=5 • Will use both key parts SELECT * FROM TBL WHERE A IN (2,3,4) AND B=5
  • 40. www.percona.com Trick #2: Adding Fake Filter KEY (GENDER,CITY) • Want to use one index only • Will not be able to use the index at all SELECT * FROM PEOPLE WHERE CITY=“NEW YORK” • Will be able to use the index SELECT * FROM PEOPLE WHERE GENDER IN (“M”,”F”) AND CITY=“NEW YORK” • Gender, Status, Boolean Types etc The trick works best with low selectivity columns.
  • 41. www.percona.com Trick #3: Unionizing Filesort KEY(A,B) • No Other key would work ether • Will not be able to use index for SORTING SELECT * FROM TBL WHERE A IN (1,2) ORDER BY B LIMIT 5; • Will use the index for Sorting. “filesort” will be needed only to sort over 10 rows. (SELECT * FROM TBL WHERE A=1 ORDER BY B LIMIT 5) UNION ALL (SELECT * FROM TBL WHERE A=2 ORDER BY B LIMIT 5) ORDER BY B LIMIT 5;
  • 42. www.percona.com Thank You ! • pz@percona.com • http://www.percona.com • @percona at Twitter • http://www.facebook.com/Percona