Browsed by
Month: July 2020

MySQL Deadlocks 101

MySQL Deadlocks 101

Sometimes when dealing with MySQL you might come across this slightly frustrating error: ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction This error message covers deadlocks – this is what we will try to explore in this post. What is a Deadlock? A deadlock occurs when different transactions are unable to proceed because each of them holds a lock that the other needs. As a result, none of the transactions succeed. This picture illustrates a…

Read More Read More

Identifying Slow Queries in MySQL: Slow Query Log 101

Identifying Slow Queries in MySQL: Slow Query Log 101

When MySQL performance issues are encountered, one of the first things troubleshooting developers do is identify long running queries and optimize them. We will take a look at a MySQL feature that helps you identify long running queries – MySQL slow query log. Understanding the Slow Query Log In MySQL, the slow query log consists of SQL statements that take more time to execute than defined in the long_query_time system variable. The system variable’s minimum and default values are 0…

Read More Read More

Understanding MySQL: The Power of Indexing

Understanding MySQL: The Power of Indexing

When talking about query optimization, indexing is one of the first topics that gets covered. In this post we will cover the types of indexes, why they might be important, their benefits and cons. Although it’s almost impossible to cover everything related to indexes in one post (the entire subject deserves a book), we will try to dig deeper and figure out the differences of multiple types of indexes and where they might be used. What are Indexes? Indexes (also…

Read More Read More

Slow SQL Queries? Don’t Blame MySQL (yet)

Slow SQL Queries? Don’t Blame MySQL (yet)

SQL queries being slow is one of the main complaints directed at MySQL. Why are queries slow? What’s making SQL queries slow? How to make them faster? We will explore some suggestions which could (hopefully) point developers in the right direction – we will look at optimizing all four CRUD operations – Create, Read, Update and Delete. Understand what You’re Dealing With As far as MySQL is concerned, developers have a few choices when dealing with the RDBMS. They can…

Read More Read More