Keeping a SQL budget

Ben Schwarz
Calibre Blog
Published in
1 min readOct 22, 2015

Because Calibre is all about the storage and retrieval of metrics at scale, its super important that we’re on top of, and aware of SQL performance at all times.

We thought we’d share a simple technique that we’ve been using that makes sure that Calibre is snappy to use.

Any database query that is more than 150ms will be written to the slow query log. That log is automagically transported (thanks to remote_syslog2) to papertrail — as soon as our search is matched, we’ll receive an email that contains the log line showing the offending query.

Deploying a slow query can bomb your inbox. Tweak the frequency for how noisy you’d like it to be.

Simple logging and alerting can go a long way. Queries under 150ms might seem like a behemoth of a job on some applications, but we’ve been tracking against this budget on Calibre ever since it hit production.

Constant analysis of metrics means that anything major is caught immediately. 👀

Originally published at calibreapp.tumblr.com.

--

--