3 ms·
It's true that RPC latency doesn't exist, and that opens up other possibilities that are worth considering. But if you do a ton of small queries instead of one
by adrianmonk 2y ago
It's true that RPC latency doesn't exist, and that opens up other possibilities that are worth considering.
But if you do a ton of small queries instead of one big one, you could be depriving the database of the opportunity to choose an efficient execution plan.
For example, if you do a join by querying one table for a bunch of IDs and then looking up each key with an individual select, you're forcing the database into doing a nested loop join. Maybe a merge join or hash join would have been faster.
Or maybe not. Sometimes the way you write the queries corresponds to what the database would have done anyway. Just not necessarily, so it's something to keep in mind.