post(blog): PostgreSQL 인덱스 설계 — DESC 인덱스와 커버링 인덱스 (#60) - #140
Merged
Conversation
- 노션 노트의 "DESC 인덱스가 역순 스캔을 없애 더 빠르다"는 주장을 PG 18.4 + 500만 행으로 실측해 반증 - 인덱스 방향이 실제로 필요한 조건(혼합 방향 정렬, NULLS 위치)과 커버링 인덱스의 손익분기를 EXPLAIN ANALYZE로 정리 - 측정 스크립트를 본문에 포함해 재현 가능하게 작성
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #60
요약
노션 노트 PG 성능 최적화를 포스트로 옮기려다 노트의 핵심 주장이 틀렸다는 걸 발견해서, 실측으로 확인한 뒤 노트와 포스트를 함께 바로잡았습니다.
노트에 적혀 있던 주장:
docker
postgres:18에 500만 행 로그 테이블을 만들어 재보니 단일 컬럼 정렬에서는 방향이 무의미했습니다. 대신 방향이 실제로 필요한 조건이 따로 있었습니다.측정 결과
ORDER BY ts DESC LIMIT 1000(ts)— Index Scan Backward(ts DESC)— Index ScanORDER BY service ASC, ts DESC(service, ts)— Incremental Sort(service ASC, ts DESC)— Index Scan(ts DESC)— Index Scancount(*)(약 282만 행)(ts DESC)NULLS위치를 지정할 때도 마찬가지입니다.count(*)와 쓰기는 오히려 느려집니다.포스트 구성
backend시리즈, 562줄. 이슈에는 예상 시리즈가fullstack으로 적혀 있었지만 내용이 DB 쪽에 치우쳐backend로 넣었습니다.재현용 스크립트(docker 기동 + 더미 데이터 적재 + 측정)를 본문에 그대로 포함했습니다.
검증
pnpm --filter blog build통과 (132 페이지)description정상 (35개 포스트 중 빈 값 0개)pg_total_relation_size해석 등) 수정 완료노션 노트
같은 내용으로 원본 노트도 교정했습니다 — 교정 배너 추가, 1·2번 본문 교체, 측정 근거 섹션 추가, 코드 블록의 붙여넣기 흔적 정리.