23 Apr

Dedicated table for counters

There are a few ways to implement counters. Even though it's not a complex feature, often I see people having problems around it. This post describes how bad implementation can impact both application and MySQL performance and how to improve it. A customer asked me for help with performance problem they were facing. I logged into their database and found many client connections waiting for table locks. Almost all threads were stuck on one, small table called hits. What was the reason?

Read More
17 Apr

Why a statement can be unsafe when it uses LIMIT clause?

MySQL 5.1 or newer can sometimes start throwing a strange message into an error log. The message states that a query was unsafe for binary logging along with some additional information. What does it mean? Is it a problem?

Read More
02 Apr

Can COUNT(*) be used in MySQL on InnoDB tables?

COUNT() function returns a number of rows returned by a query. In a popular opinion COUNT(*) should not be used on InnoDB tables, but this is only half true.

Read More
31 Mar

MySQL queries with REGEXP

Official MySQL documentation provides information that using regular expressions is "powerful way of specifying a pattern for a complex search". Is it really such a powerful way of filtering and should be used, or is it a solution that should be avoided? As it usually happens in real life, there are many opinions and no universal answer. Unfortunately, it often turns out that the truth lies somewhere in the middle.

Read More