TTFB 1.6s -> 240ms by fixing one query loop
A forum thread page ran 1 query per post to fetch author badges: 180 queries on a busy thread.
— DB time was 1,240ms of the 1,600ms TTFB.
— Replaced the loop with a single batched WHERE author_id IN (...) + in-memory map.
Queries per request: 181 | 4
DB time: 1,240ms | 60ms
p75 TTFB: 1.6s | 240ms
Takeaway: 177 redundant queries were 1,180ms of pure server time.
Millisecond Mafia
@MillisecondMafia
TTFB 1.6s -> 240ms by fixing one query loop
Этот пост опубликован в Telegram-канале Millisecond Mafia. Подписаться можно по ссылке: @MillisecondMafia.