Varchar vs Char in MySQL : understanding trailing spaces

MySQL is not a strictly typed database. Given that and the different character types some tricky situation might arise. Especially when it comes to trailing spaces. Since this caused some head scratching hours to a colleague of mine I thought it’s worth a bit more explanation.

To understand the problem first … Continue reading

Difference between DISTINCT and GROUP BY

Today we had an interesting situation where the same query was executed significantly slower when it was written with GROUP BY instead of DISTINCT and I saw many people still had the assumption that these two types of queries are actually equivalent which is simply not true. Although DISTINCT queries … Continue reading

MySQL 5.6 mysql_install_db script problem

We’re always testing the latest versions of MySQL with most of the environments to make sure that we can find the critical issues before it goes to production. This wasn’t different with the 5.6 MySQL neither. We already started to play with this version in the summer. The first news … Continue reading

MySQL Benchmark – updates by primary vs secondary keys

(Note: when I’m talking about MySQL I usually assume InnoDB storage engine. Any other case I explicitly tell this is MyISAM or Memory etc.)

I’ve heared an interesting aproach of using Master-slave replication in MySQL.


So the theory was that since updates by primary keys are fast and by … Continue reading

Sleeping connections

Why is it so important to close connections to databases if there’s no explicit need to keep them open (which usually the case)?


  • Icinga reports high usage of allowed connections (>90%) on master MySQL server.
  • No running queries or any specific in processlist. All the connections are sleeping … Continue reading