3 ms·
Assuming good indexing with non-enormous tables, he could use subqueries to get the COUNT() data at the same time that he pulls the records themselves. And, as
by carbocation 16y ago
Assuming good indexing with non-enormous tables, he could use subqueries to get the COUNT() data at the same time that he pulls the records themselves. And, as he notes, he could have a count field in MySQL, caching at that level instead of in Redis.