12장. Query plan을 대표 데이터로 읽는다
실행계획은 index 사용 여부만 보는 표가 아니다. estimated와 actual rows, loop, buffer, sort spill, lock wait, parameter 분포를 본다. production과 비슷한 크기·분포의 합성 데이터로 재현한다.
explain (analyze, buffers)
select * from reservation
where tenant_id=$1 and scheduled_at between $2 and $3
order by scheduled_at limit 100;
index는 쓰기·storage·cache 비용이 있다. 개선 전후 latency뿐 아니라 읽은 block과 insert 비용, plan 안정성을 비교한다.