Google Cloud SQL MySQL: how to convert JSON to slow log

Nowadays data volumes are growing very quickly. Today Hundreds of gigabytes database is not even being considered as a huge one. Naturally cloud services like Amazon Relational Database Service (RDS) or Google Cloud SQL services can be successfully used for such cases. This is very handy, you don’t even need to spend your time tuning server side settings, but when with volumes growth the performance usually start to degrade. At this point one needs to start optimizing databases and techniques of working with it.

We’ve been using Google Cloud SQL for MySQL quite a lot recently and indeed it’s a powerful MySQL solution. One of the most common ways to start analyzing is a slow queries log. The thing is Google uses JSON with timestamps to store them. And JSON is convenient for robots, not for humans. This is why we wrote a simple Python3 script to parse JSON files.

You just need to grab the logs to some Linux box:

And concatenate all files into on big log:

To get classic and familiar format run:

And run


References: (Cross post)