Reader small image

You're reading from  Advanced MySQL 8

Product typeBook
Published inJan 2019
Reading LevelIntermediate
Publisher
ISBN-139781788834445
Edition1st Edition
Languages
Tools
Right arrow
Authors (3):
Eric Vanier
Eric Vanier
author image
Eric Vanier

Eric Vanier is one of the few DBAs worldwide specializing in MySQL performance, and is an expert with large architectures such as those for Air Miles, Cogeco, McGill University, Bombardier Aerospace, and many more. As a senior DBA and instructor for 18 years, he has a track record in performance and troubleshooting on dozens of high-profile MySQL systems, including complex cluster environments.
Read more about Eric Vanier

Birju Shah
Birju Shah
author image
Birju Shah

Birju Shah is the principal architect for Endurance International Group. He has a bachelor's degree in computer engineering from Gujarat University. He has the experience and expertise to build scalable products for hosting domains. He is passionate about the latest architectural patterns, tools, and technologies, and he helps organizations to follow best practices. He is also passionate about technical training and sessions.
Read more about Birju Shah

Tejaswi Malepati
Tejaswi Malepati
author image
Tejaswi Malepati

Tejaswi Malepati is the Cassandra Tech Lead for Target. He has been instrumental in designing and building custom Cassandra integrations, including a web-based SQL interface and data validation frameworks between Oracle and Cassandra. Tejaswi earned a master's degree in computer science from the University of New Mexico, and a bachelor's degree in electronics and communication from Jawaharlal Nehru Technological University in India. He is passionate about identifying and analyzing data patterns in datasets using R, Python, Spark, Cassandra, and MySQL.
Read more about Tejaswi Malepati

View More author details
Right arrow

Advanced MySQL Performance Tips and Techniques

This chapter will cover some important tips/best practices to keep your critical data-reach to its full potential, and through our techniques section, we will answer questions that people often ask regarding large data performance with optimizations, along with the efficient resource utilization of MySQL database. Specifically, this chapter will cover the following topics:

  • Tips/best practices
  • Techniques

By the end of this chapter, you will understand what patterns and anti-pattern use cases that are used for MySQL are, as well as different ways to enhance and optimize the performance of a database, followed by solutions to commonly asked questions.

Tips/best practices

There are several features of the MySQL database that can be misinterpreted easily. To avoid this, next, we will cover a few of the tips/best practices recommended for building an efficient and optimized MySQL database as a source of truth. The assumption for this entire chapter is that you have access to a local or remote MySQL database.

Optimizing your queries for the query cache

Any database converts raw SQL query statement into an internal structure through which it will process and acknowledge clients accordingly; similarly, MySQL also converts any statement (SQL/stored procedures/functions/triggers/events) into an understandable structure by MySQL's engine. The majority of the queries by an application...

Techniques

Apart from using features in the right way, there are certain parameters that can be tweaked based on use cases being solved by MySQL. These will be discussed in further sections, along with common reasoning for deteriorating performance for a large or small database.

Can MySQL perform queries on billions of rows?

MySQL can perform queries on many, many rows, but it also depends on the kind of query being executed. For example, if a read query contains filtering of only the primary key being equated, then that is a kind of golden query and, yes, it will perform well, but, at the same time, if it is a range/like/regex query for a primary key, then it will perform not quite as well as the previous query.

But if a...

Summary

There are several SQL databases, among which MySQL is one; it has a number of unique features that are better than those of other databases due to its ease of implementation for enhancing efficiency and optimizing it. But due to this ease, many implementations land in an anti-pattern side, which results in the deterioration of performance.

This chapter provides different tips/best practices and techniques that help in overcoming these situations. We started with caching queries as shock absorbers for same query repetition, optimizing queries based on an execution plan using EXPLAIN, limiting the result set size with LIMIT, indexing search fields, the disadvantages of using SELECT */COUNT *, the recommended way of having an ID field along with other columns, optimization using prepared statements, splitting big DELETE/INSERT statements to avoid a deadlock state, and the...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Advanced MySQL 8
Published in: Jan 2019Publisher: ISBN-13: 9781788834445
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.
undefined
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 $15.99/month. Cancel anytime

Authors (3)

author image
Eric Vanier

Eric Vanier is one of the few DBAs worldwide specializing in MySQL performance, and is an expert with large architectures such as those for Air Miles, Cogeco, McGill University, Bombardier Aerospace, and many more. As a senior DBA and instructor for 18 years, he has a track record in performance and troubleshooting on dozens of high-profile MySQL systems, including complex cluster environments.
Read more about Eric Vanier

author image
Birju Shah

Birju Shah is the principal architect for Endurance International Group. He has a bachelor's degree in computer engineering from Gujarat University. He has the experience and expertise to build scalable products for hosting domains. He is passionate about the latest architectural patterns, tools, and technologies, and he helps organizations to follow best practices. He is also passionate about technical training and sessions.
Read more about Birju Shah

author image
Tejaswi Malepati

Tejaswi Malepati is the Cassandra Tech Lead for Target. He has been instrumental in designing and building custom Cassandra integrations, including a web-based SQL interface and data validation frameworks between Oracle and Cassandra. Tejaswi earned a master's degree in computer science from the University of New Mexico, and a bachelor's degree in electronics and communication from Jawaharlal Nehru Technological University in India. He is passionate about identifying and analyzing data patterns in datasets using R, Python, Spark, Cassandra, and MySQL.
Read more about Tejaswi Malepati