Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Advanced MySQL 8

You're reading from  Advanced MySQL 8

Product type Book
Published in Jan 2019
Publisher
ISBN-13 9781788834445
Pages 286 pages
Edition 1st Edition
Languages
Authors (3):
Eric Vanier Eric Vanier
Profile icon Eric Vanier
Birju Shah Birju Shah
Profile icon Birju Shah
Tejaswi Malepati Tejaswi Malepati
Profile icon Tejaswi Malepati
View More author details
Toc

Table of Contents (13) Chapters close

Preface 1. Introduction 2. MySQL 8's New Features 3. Indexing Your Data for High Performance 4. Advanced Data Techniques for Large Queries 5. MySQL Data Dictionary in MySQL 8.0 6. MySQL Server Settings 7. Group Replication in MySQL 8.0 8. InnoDB Cluster in MySQL 8.0 9. Monitoring Your Large Distributed Databases 10. Authentication and Security Management with MySQL 8.0 11. Advanced MySQL Performance Tips and Techniques 12. Other Books You May Enjoy

Case study 1 – an example of how to optimize a complex query

We will explore in this case study a complex step-by-step query such as the following:

  1. How to format a complex query
  2. Run and analyze an execution plan
  3. Optimize a complex query

When we have a query that runs in production and is complex, we need to format it so that we can have more clarity and can easily optimize it.

Here is our request (not formatted):

Here is our formatted query:

Here is the EXPLAIN plan:

Let's analyze the query together.

The first problem observed from the output of the execution plan is the following:

SUBQUERY DEPENDENT (NOT EXISTS ( SELECT 1 FROM employees_party WHERE fk_employees_id = employees.id AND Important_id BETWEEN 1 and 4 AND diff_value BETWEEN 1 and 3));

The solution is to rewrite the part of the SUBQUERY DEPENDENT as follows, in order to optimize our query:

SELECT E....
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}