Efficient MySQL Indexing & What's New in MySQL Explain - Mydbops MyWebinar Edition 32
This session will delve into:
• Strategic indexing techniques: Learn how to optimize your MySQL database by implementing effective indexing strategies, including when to avoid fulltext indexes to prevent wasted resources.
• Demystifying the new MySQL Explain: We'll explore the latest enhancements to the MySQL Explain plan's JSON output format. Discover how to store the output in a variable for further analysis – a valuable addition introduced in MySQL 8.3. You'll also learn about the explain_json_format_version variable, which empowers you to choose between different JSON output versions for greater flexibility.
• Live Chat Engagement: We encourage you to actively participate throughout the webinar! Use the chat functionality to ask questions and share your experiences with indexing and Explain.
This webinar is perfect for:
• Database administrators (DBAs)
• Developers
• Anyone seeking to optimize MySQL performance and streamline database queries
Mydbops Managed Services specializes in taking the pain out of database management while optimizing performance. Since 2015, we have been providing top-notch support and assistance for the top three open-source databases: MySQL, MongoDB, and PostgreSQL.
Our team offers a wide range of services, including assistance, support, consulting, 24/7 operations, and expertise in all relevant technologies. We help organizations improve their database's performance, scalability, efficiency, and availability.
Contact us: info@mydbops.com
Visit: https://www.mydbops.com/
3. Agenda
❏ Index Overview
❏ Types of Indexes
❏ Increasing Indexing Efficiency
❏ Example
❏ Before Optimization
❏ Optimization
❏ After Optimization
❏ New Features
❏ Capturing EXPLAIN FORMAT=JSON Output
❏ explain_json_format_version
5. Index Overview
❏ Enhances data retrieval speed, uses extra space.
❏ Created on table columns, choosing the right index is vital.
❏ Needs regular updates to stay efficient.
❏ Index types: Includes primary, unique, composite, and full-text.
9. Increasing Index Efficiency
❏ Analysing the queries
❏ Avoid over indexing
❏ Analyze the cardinality
❏ Pick the correct columns
❏ Pick the suitable index
❏ Regular maintenance
20. explain_json_format_version variable
● Two versions available for EXPLAIN FORMAT=JSON.
● Version 2 reveals optimizer access paths.
● Ensures compatibility with upcoming MySQL Optimizer.
● Supports the JSON output format for EXPLAIN statements.
22. mysql> Explain format = JSON select ID, Name, CountryCode, District,
Population from city where Population between 127800 and 137500G
*************************** 1. row ***************************
EXPLAIN: {
"query_block": {
"select_id": 1,
"cost_info": {
"query_cost": "409.75"
},
"table": {
"table_name": "city",
"access_type": "ALL",
"rows_examined_per_scan": 4035,
"rows_produced_per_join": 448,
"filtered": "11.11",
"cost_info": {
"read_cost": "364.92",
"eval_cost": "44.83",
"prefix_cost": "409.75",
"data_read_per_join": "108K"
},
"used_columns": [
"ID", "Name","CountryCode", "District",
"Population"
],
"attached_condition": "(`world`.`city`.`Population` between 127800 and 137500)”} } }
23. Version 2
Setting the variable:
mysql> SET @@explain_json_format_version = 2;
Query OK, 0 rows affected (0.00 sec)
24. mysql> Explain format = JSON select ID, Name, CountryCode, District, Population
from city where Population between 127800 and 137500G
*************************** 1. row ***************************
EXPLAIN: {
"query": "/* select#1 */ select `world`.`city`.`ID` AS `ID`,`world`.`city`.`Name` AS
`Name`,`world`.`city`.`CountryCode` AS `CountryCode`,`world`.`city`.`District` AS
`District`,`world`.`city`.`Population` AS `Population` from `world`.`city` where (`world`.`city`.`Population`
between 127800 and 137500)",
"inputs": [
{
"operation": "Table scan on city",
"table_name": "city",
"access_type": "table",
"schema_name": "world",
"used_columns": [
"ID",
"Name",
"CountryCode",
"District",
"Population"
],
"estimated_rows": 4035.0,
"estimated_total_cost": 409.75
}
],
"condition": "(city.Population between 127800 and 137500)",
"operation": "Filter: (city.Population between 127800 and 137500)",
"access_type": "filter",
"estimated_rows": 448.28851260244846,
"estimated_total_cost": 409.75
}