🚨 Developers, be careful with thinking "it's okay if this page in my app is slow".

Your admin dashboard might only be used by support staff, but *databases are a shared resource*. A slow dashboard can slow down your site for every other user.

Every query matters!

A thread 👇
As web developers, it's easy to think of every two requests as largely independent of one another. If one request is slow, it's unlikely to affect the other...right?

That's very much not the case with your database. It must run whatever queries are fired at it, collectively.
Your database has limits (connections, CPU, memory). It can only run so many queries at a time.

Treat your database as a limited resource, shared by all users. Every query you run is using part of this finite resource. Run too many, and it will crash.
Any queries you can make faster, or avoid entirely, will help the performance of the whole system.

Use monitoring software to determine which queries are the most expensive. Find those running the most frequently and the slowest. These are the worst offenders. Fix them first.
For example, I use @heroku, and they provide the following database metrics:

- Most time consuming
- Most frequently invoked
- Slowest execution time
- Slowest I/O

@newrelic also provides excellent database metrics.
You can follow @reinink.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: