Suche senden
Hochladen
New index features in MySQL 8
•
4 gefällt mir
•
566 views
E
Erik Frøseth
Folgen
An introduction to three of the new index features in MySQL 8
Weniger lesen
Mehr lesen
Software
Melden
Teilen
Melden
Teilen
1 von 30
Jetzt herunterladen
Downloaden Sie, um offline zu lesen
Empfohlen
My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2
Morgan Tocker
MySQL Performance Schema in Action
MySQL Performance Schema in Action
Sveta Smirnova
Exploring mysql cluster 7.4
Exploring mysql cluster 7.4
Ivan Ma
MySQL 5.7 + JSON
MySQL 5.7 + JSON
Morgan Tocker
What's New MySQL 8.0?
What's New MySQL 8.0?
OracleMySQL
Introduction into MySQL Query Tuning
Introduction into MySQL Query Tuning
Sveta Smirnova
Performance Schema in Action: demo
Performance Schema in Action: demo
Sveta Smirnova
Mysql nowwhat
Mysql nowwhat
sqlhjalp
Empfohlen
My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2
Morgan Tocker
MySQL Performance Schema in Action
MySQL Performance Schema in Action
Sveta Smirnova
Exploring mysql cluster 7.4
Exploring mysql cluster 7.4
Ivan Ma
MySQL 5.7 + JSON
MySQL 5.7 + JSON
Morgan Tocker
What's New MySQL 8.0?
What's New MySQL 8.0?
OracleMySQL
Introduction into MySQL Query Tuning
Introduction into MySQL Query Tuning
Sveta Smirnova
Performance Schema in Action: demo
Performance Schema in Action: demo
Sveta Smirnova
Mysql nowwhat
Mysql nowwhat
sqlhjalp
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
Dave Stokes
Mysql8 advance tuning with resource group
Mysql8 advance tuning with resource group
Marco Tusa
Optimizing MySQL
Optimizing MySQL
Morgan Tocker
MySQL For Linux Sysadmins
MySQL For Linux Sysadmins
Morgan Tocker
MySQL partitioning
MySQL partitioning
OracleMySQL
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
Alex Zaballa
MySQL Server Defaults
MySQL Server Defaults
Morgan Tocker
MySQL Query Optimization
MySQL Query Optimization
Morgan Tocker
Solving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise Monitor
OracleMySQL
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
MySQL Monitoring Mechanisms
MySQL Monitoring Mechanisms
Mark Leith
Mysql server query path
Mysql server query path
Wenjie Wu
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
Dave Stokes
MySQL NoSQL APIs
MySQL NoSQL APIs
Morgan Tocker
Oracle SQL Tuning
Oracle SQL Tuning
Alex Zaballa
MySQL Performance Best Practices
MySQL Performance Best Practices
Olivier DASINI
MySQL JSON Functions
MySQL JSON Functions
Sveta Smirnova
Performance schema and sys schema
Performance schema and sys schema
Mark Leith
Mini Session - Using GDB for Profiling
Mini Session - Using GDB for Profiling
Enkitec
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
Alex Zaballa
Five more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQL
Connor McDonald
2019 indit blackhat_honeypot your database server
2019 indit blackhat_honeypot your database server
Georgi Kodinov
Weitere ähnliche Inhalte
Was ist angesagt?
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
Dave Stokes
Mysql8 advance tuning with resource group
Mysql8 advance tuning with resource group
Marco Tusa
Optimizing MySQL
Optimizing MySQL
Morgan Tocker
MySQL For Linux Sysadmins
MySQL For Linux Sysadmins
Morgan Tocker
MySQL partitioning
MySQL partitioning
OracleMySQL
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
Alex Zaballa
MySQL Server Defaults
MySQL Server Defaults
Morgan Tocker
MySQL Query Optimization
MySQL Query Optimization
Morgan Tocker
Solving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise Monitor
OracleMySQL
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
Alex Zaballa
MySQL Monitoring Mechanisms
MySQL Monitoring Mechanisms
Mark Leith
Mysql server query path
Mysql server query path
Wenjie Wu
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
Dave Stokes
MySQL NoSQL APIs
MySQL NoSQL APIs
Morgan Tocker
Oracle SQL Tuning
Oracle SQL Tuning
Alex Zaballa
MySQL Performance Best Practices
MySQL Performance Best Practices
Olivier DASINI
MySQL JSON Functions
MySQL JSON Functions
Sveta Smirnova
Performance schema and sys schema
Performance schema and sys schema
Mark Leith
Mini Session - Using GDB for Profiling
Mini Session - Using GDB for Profiling
Enkitec
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
Alex Zaballa
Was ist angesagt?
(20)
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
Mysql8 advance tuning with resource group
Mysql8 advance tuning with resource group
Optimizing MySQL
Optimizing MySQL
MySQL For Linux Sysadmins
MySQL For Linux Sysadmins
MySQL partitioning
MySQL partitioning
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
MySQL Server Defaults
MySQL Server Defaults
MySQL Query Optimization
MySQL Query Optimization
Solving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise Monitor
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
MySQL Monitoring Mechanisms
MySQL Monitoring Mechanisms
Mysql server query path
Mysql server query path
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL 8.0 New Features -- September 27th presentation for Open Source Summit
MySQL NoSQL APIs
MySQL NoSQL APIs
Oracle SQL Tuning
Oracle SQL Tuning
MySQL Performance Best Practices
MySQL Performance Best Practices
MySQL JSON Functions
MySQL JSON Functions
Performance schema and sys schema
Performance schema and sys schema
Mini Session - Using GDB for Profiling
Mini Session - Using GDB for Profiling
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
Ähnlich wie New index features in MySQL 8
Five more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQL
Connor McDonald
2019 indit blackhat_honeypot your database server
2019 indit blackhat_honeypot your database server
Georgi Kodinov
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Guatemala User Group
Developers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman Oracle
mCloud
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
mCloud
15 protips for mysql users pfz
15 protips for mysql users pfz
Joshua Thijssen
MySQL 8.0 Released Update
MySQL 8.0 Released Update
Keith Hollman
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
Alex Zaballa
Top 10 tips for Oracle performance
Top 10 tips for Oracle performance
Guy Harrison
5 Cool Things About SQL
5 Cool Things About SQL
Connor McDonald
Windowing Functions - Little Rock Tech Fest 2019
Windowing Functions - Little Rock Tech Fest 2019
Dave Stokes
Windowing Functions - Little Rock Tech fest 2019
Windowing Functions - Little Rock Tech fest 2019
Dave Stokes
Php forum2015 tomas_final
Php forum2015 tomas_final
Bertrand Matthelie
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices I
Carlos Oliveira
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
Dave Stokes
MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
Sveta Smirnova
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Connor McDonald
My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3
Oleksii(Alexey) Porytskyi
Everything you always wanted to know about datetime types but didn’t have tim...
Everything you always wanted to know about datetime types but didn’t have tim...
MartinHanssonOracle
MySQL 8.0: Secure your replication deployment
MySQL 8.0: Secure your replication deployment
Pedro Figueiredo
Ähnlich wie New index features in MySQL 8
(20)
Five more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQL
2019 indit blackhat_honeypot your database server
2019 indit blackhat_honeypot your database server
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Developers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman Oracle
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
Developers’ mDay u Banjoj Luci - Bogdan Kecman, Oracle – MySQL Server 8.0
15 protips for mysql users pfz
15 protips for mysql users pfz
MySQL 8.0 Released Update
MySQL 8.0 Released Update
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
Top 10 tips for Oracle performance
Top 10 tips for Oracle performance
5 Cool Things About SQL
5 Cool Things About SQL
Windowing Functions - Little Rock Tech Fest 2019
Windowing Functions - Little Rock Tech Fest 2019
Windowing Functions - Little Rock Tech fest 2019
Windowing Functions - Little Rock Tech fest 2019
Php forum2015 tomas_final
Php forum2015 tomas_final
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices I
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3
Everything you always wanted to know about datetime types but didn’t have tim...
Everything you always wanted to know about datetime types but didn’t have tim...
MySQL 8.0: Secure your replication deployment
MySQL 8.0: Secure your replication deployment
Kürzlich hochgeladen
DNT_Corporate presentation know about us
DNT_Corporate presentation know about us
Dynamic Netsoft
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽❤️🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽❤️🧑🏻 89...
gurkirankumar98700
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
soniya singh
EY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
Neo4j
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
ComplianceQuest1
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
stazi3110
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
BradBedford3
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
Wave PLM
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
shikhaohhpro
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
Ortus Solutions, Corp
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
Frank van der Linden
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
VICTOR MAESTRE RAMIREZ
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio, Inc.
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
AxelRicardoTrocheRiq
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
bodapatigopi8531
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Alberto González Trastoy
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
kalichargn70th171
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
What is Binary Language? Computer Number Systems
What is Binary Language? Computer Number Systems
JheuzeDellosa
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
MyIntelliSource, Inc.
Kürzlich hochgeladen
(20)
DNT_Corporate presentation know about us
DNT_Corporate presentation know about us
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽❤️🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽❤️🧑🏻 89...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
EY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
What is Binary Language? Computer Number Systems
What is Binary Language? Computer Number Systems
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
New index features in MySQL 8
1.
Copyright © 2019
Oracle and/or its affiliates. All rights reserved. New index features in MySQL 8 Erik Frøseth Software Developer MySQL Optimizer Team February 1st, 2019
2.
2Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
3.
3Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Program Agenda Functional indexes Index skip scan Invisible indexes 1 2 3 4 5 6 7
4.
4Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Program Agenda Functional indexes Index skip scan Invisible indexes 1 2 3 4 5 6 7
5.
5Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Terminology # This creates a single index/key with two index/key parts CREATE INDEX my_index ON my_table (column_a, column_b);
6.
6Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Functional index – what is it? ● A functional index is an index where at least one of the index parts is a function instead of a column. 1) CREATE INDEX my_index ON my_table ((ABS(column_a))); 2) CREATE INDEX my_index ON my_table ((ABS(column_a)), column_b); 3) CREATE TABLE my_table ( column_a VARCHAR(255), INDEX my_index ((UPPER(column_a))) );
7.
7Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Functional index – how do you use it? ● A functional index is created, used and removed exactly like any other index. mysql> CREATE TABLE my_table ( -> column_a VARCHAR(255), -> INDEX my_index ((UPPER(column_a))) -> ); Query OK, 0 rows affected (0.04 sec) mysql> EXPLAIN SELECT * FROM my_table WHERE UPPER(column_a) = "FOOBAR"; +-------------+----------+------+----------+---------+-------+------+----------+ | select_type | table | type | key | key_len | ref | rows | filtered | +-------------+----------+------+----------+---------+-------+------+----------+ | SIMPLE | my_table | ref | my_index | 1023 | const | 1 | 100.00 | +-------------+----------+------+----------+---------+-------+------+----------+ 1 row in set, 1 warning (0.00 sec)
8.
8Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Functional index – how do you use it? mysql> CREATE TABLE my_table ( -> column_a VARCHAR(255), -> column_b INT, -> INDEX my_index ((UPPER(column_a)), column_b) -> ); Query OK, 0 rows affected (0.04 sec) mysql> EXPLAIN SELECT * FROM my_table WHERE UPPER(column_a) = "FOOBAR" AND column_b < 20; +-------------+----------+-------+---------------+----------+---------+------+----------+ | select_type | table | type | possible_keys | key | key_len | rows | filtered | +-------------+----------+-------+---------------+----------+---------+------+----------+ | SIMPLE | my_table | range | my_index | my_index | 1028 | 1 | 100.00 | +-------------+----------+-------+---------------+----------+---------+------+----------+ 1 row in set, 1 warning (0.00 sec) ● You can mix functional and non-functional index parts
9.
9Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Functional index – observability mysql> SHOW INDEX FROM t1; +-------+------------+----------+--------------+-------------+...+-------------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name |...| Expression | +-------+------------+----------+--------------+-------------+...+-------------------+ | t1 | 1 | idx | 1 | NULL |...| (`col1` + `col1`) | +-------+------------+----------+--------------+-------------+...+-------------------+ 1 row in set (0.01 sec) mysql> SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = "t1"; +...+------------+--------------+-------------+...+-------------------+ |...| INDEX_NAME | SEQ_IN_INDEX | COLUMN_NAME |...| EXPRESSION | +...+------------+--------------+-------------+...+-------------------+ |...| idx | 1 | NULL |...| (`col1` + `col1`) | +...+------------+--------------+-------------+...+-------------------+ 1 row in set (0.00 sec)
10.
10Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Functional index – observability mysql> SHOW CREATE TABLE t1; +-------+-----------------------------------------------------------+ | Table | Create Table | +-------+-----------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `col1` int(11) DEFAULT NULL, KEY `idx` (((`col1` + `col1`))) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci | +-------+----------------------------------------------------------+ 1 row in set (0.00 sec)
11.
11Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Functional index – use cases The main use case is indexing complex type such as geometries and (especially) JSON. CREATE INDEX json_extract_idx ON my_table ((CAST(data->>'$.person.id' AS CHAR(100)))); { “person”: { “first_name”: “Erik”, “last_name”: “Frøseth”, “id”: 8 } }
12.
12Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Functional index – limitations and other notes ● The primary key cannot be a functional index ● You cannot index a function that returns a BLOB or TEXT ● You can not index non-deterministic functions (RAND(), NOW(), UUID() etc...) ● Each functional index part “uses” one column ● It’s more costly to maintain a functional index than a regular index. Do not overuse it!
13.
13Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Program Agenda Functional indexes Index skip scan Invisible indexes 1 2 3 4 5 6 7
14.
14Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Index skip scan ● Based on a contribution from Facebook ● An index can only be used if the first/leading column(s) is referenced in the WHERE-condition CREATE INDEX my_index ON my_table (column1, column2); # Works! SELECT * FROM my_table WHERE column1 = 33; SELECT * FROM my_table WHERE column1 = 33 AND column2 > 3; # Does not work... SELECT * FROM my_table WHERE column2 > 3;
15.
15Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Index skip scan ● With index skip scan, the first index part can be omitted in the WHERE condition CREATE INDEX my_index ON my_table (column1, column2); # Works! SELECT * FROM my_table WHERE column1 = 33; SELECT * FROM my_table WHERE column1 = 33 AND column2 > 3; # This works too! SELECT * FROM my_table WHERE column2 > 3;
16.
16Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Index skip scan column1 column2 1 1 1 2 1 3 1 4 2 1 2 2 2 3 2 4 2 5 SELECT * FROM my_table WHERE column2 > 3; column1 = 1 AND column2 > 3 column1 = 2 AND column2 > 3
17.
17Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Index skip scan mysql> EXPLAIN SELECT * FROM my_table WHERE column2 > 3; +----------+-------+------+------+----------+----------------------------------------+ | table | type | key | rows | filtered | Extra | +----------+-------+------+------+----------+----------------------------------------+ | my_table | range | idx1 | 85 | 100.00 | Using where; Using index for skip scan | +----------+-------+------+------+----------+----------------------------------------+ 1 row in set, 1 warning (0.00 sec)
18.
18Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Index skip scan ● Usage criterias: – The query must only reference columns that exists in the in the index. – The estimated cost must be the lowest of any alternative (many distinct values in the first key part will most likely results in a high cost).
19.
19Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Index skip scan Few distinct values "skip_scan_range": { "potential_skip_scan_indexes": [{ "index": "idx2", "tree_travel_cost": 0.45, "num_groups": 12, "rows": 138, "cost": 31.817 } ] } Many distinct values "skip_scan_range": { "potential_skip_scan_indexes": [{ "index": "idx2", "tree_travel_cost": 0.5, "num_groups": 421, "rows": 832, "cost": 546.45 } ] }
20.
20Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Index skip scan ● Can be controlled by optimizer switch and query hints 1) SET optimizer_switch='skip_scan=off'; 2) SELECT /*+ SKIP_SCAN(t3) */ col1 FROM t3 WHERE col2 < 10; 3) SELECT /*+ SKIP_SCAN(t3 idx1) */ col1 FROM t3 WHERE col2 < 10; 4) SELECT /*+ NO_SKIP_SCAN(t3) */ col1 FROM t3 WHERE col2 < 10;
21.
21Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Program Agenda Functional indexes Index skip scan Invisible indexes 1 2 3 4 5 6 7
22.
22Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Invisible indexes – What is it? ● Lets you turn off any index ● Global setting ● Invisible to the optimizer, but it’s still maintained by the storage engine ● Can be turned on/off completely by setting the optimizer switch «use_invisible_indexes» ● Primary keys cannot be made invisible
23.
23Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Invisible indexes – How is it used? 1) ALTER TABLE t1 ALTER INDEX idx INVISIBLE; 2) CREATE INDEX idx ON my_table (a_column) INVISIBLE; 3) CREATE TABLE t1 ( col1 INT, INDEX idx (col1) INVISIBLE );
24.
24Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Invisible indexes - Example mysql> EXPLAIN SELECT COUNT(*) FROM lineitem WHERE l_suppkey = 7706; ...+------+---------------+-------------+---------+-------+------+----------+-------------+ ...| type | possible_keys | key | key_len | ref | rows | filtered | Extra | ...+------+---------------+-------------+---------+-------+------+----------+-------------+ ...| ref | i_l_suppkey | i_l_suppkey | 5 | const | 604 | 100.00 | Using index | ...+------+---------------+-------------+---------+-------+------+----------+-------------+ 1 row in set, 1 warning (0.00 sec) mysql> ALTER TABLE lineitem ALTER INDEX i_l_suppkey INVISIBLE; Query OK, 0 rows affected (0.18 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> EXPLAIN SELECT COUNT(*) FROM lineitem WHERE l_suppkey = 7706; ...+------+---------------+------+---------+------+---------+----------+-------------+ ...| type | possible_keys | key | key_len | ref | rows | filtered | Extra | ...+------+---------------+------+---------+------+---------+----------+-------------+ ...| ALL | NULL | NULL | NULL | NULL | 5941264 | 0.01 | Using where | ...+------+---------------+------+---------+------+---------+----------+-------------+ 1 row in set, 1 warning (0.00 sec)
25.
25Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Invisible indexes - Observability ● See the visibility using INFORMATION_SCHEMA or SHOW INDEXES mysql> SHOW INDEXES FROM my_table; +----------+------------+---------------------+...+---------+ | Table | Non_unique | Key_name |...| Visible | +----------+------------+---------------------+...+---------+ | my_table | 1 | just_to_be_safe_idx |...| NO | +----------+------------+---------------------+...+---------+ mysql> SELECT INDEX_NAME, IS_VISIBLE FROM INFORMATION_SCHEMA.STATISTICS > WHERE TABLE_NAME = "my_table"; +---------------------+------------+ | INDEX_NAME | IS_VISIBLE | +---------------------+------------+ | just_to_be_safe_idx | NO | +---------------------+------------+ 1 row in set (0.01 sec)
26.
26Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Invisible indexes - Observability mysql> SHOW CREATE TABLE t1; +-------+----------------------------------------------------------+ | Table | Create Table | +-------+----------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `col1` int(11) DEFAULT NULL, KEY `just_to_be_safe_index` (((`col1` * 2))) /*!80000 INVISIBLE */ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci | +-------+----------------------------------------------------------+
27.
27Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Invisible indexes – what you should remember ● See if you get any errors due to index hints referring to the index ● Slow query log ● Performance schema ● Application performance ● Check sys.schema_unused_indexes
28.
28Copyright © 2019
Oracle and/or its affiliates. All rights reserved.
29.
29Copyright © 2019
Oracle and/or its affiliates. All rights reserved. Safe Harbor Statement The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
Jetzt herunterladen