May 15, 2026

I always thought database CPUs just chill most of the time and IO is doing all the heavy work… but I was wrong.

I always thought database CPUs just chill most of the time and IO is doing all the heavy work… but I was wrong.

Here is the reason why??

database server accepts a connection from the client, client sends SQL query bytes, they sit in kernel buffer and then get copied into user space. copyiiiiinggg ?????? boom who does it it's me again your cpuuuuu

Now the parser validates the SQL text, then builds the structured representation of that SQL, and also checks whether requested tables, columns, and things actually exist in the database. ?????? boom who does it it's me again your cpuuuuu

Then the planner comes in. It decides which indexes to use based on the WHERE clause whether it can take shortcuts using indexes or has to scan pages one by one from disk. planning things ??? boom who does it it's me again your cpuuuuu

Now execution starts. Yes IO brings pages from disk or memory, but boom after that??? who does filtering, sorting, grouping, aggregating all of that is heavy work. ?????? boom who does it it's me again your cpuuuuu

So yeah, sometimes queries are slow not only because of IO, but because the query itself is unbounded and expensive and worse, it can slow down other queries too by consuming CPU, memory, and cache pressure.

We underestimate how much work happens inside the database before and after touching disk.

#Backend #Database #CPU #PostgreSQL #MySQL #QueryPerformance