파티셔닝은 하나의 논리 테이블을 날짜 범위나 키 값에 따라 여러 물리 파티션으로 나눕니다. 조건이 파티션 키와 맞으면 쿼리 계획에서 읽지 않을 파티션을 제외할 수 있습니다.
데모는 9월 주문 조회가 세 월별 파티션 중 9월만 선택하는 모습을 보여줍니다. 모든 쿼리가 빨라지는 것은 아니며, 키 선택과 파티션 개수, 오래된 파티션 관리 방식이 중요합니다.
언제 쓰나
날짜별 대용량 데이터에서 범위 조회와 보관 기간 관리가 중요할 때 검토합니다.
큰 테이블을 범위 등으로 나눠 조건에 맞는 파티션만 읽게 합니다.
<div class="demo"><div class="head"><b>PARTITION PRUNING</b><span id="filterMonth">WHERE month = Sep</span></div><div class="stage partitions"><div class="queryline">orders →</div><div class="months"><div class="cell">Aug</div><div class="cell">Sep</div><div class="cell">Oct</div></div></div><div class="foot"><span id="partitionstatus">read Sep · skip 2</span><span>one logical table</span></div></div>*{box-sizing:border-box}.demo{width:min(96vw,820px);height:min(94vh,350px);padding:clamp(8px,2vmin,18px);border:1px solid var(--line);border-radius:14px;background:var(--surface);color:var(--fg);display:flex;flex-direction:column;gap:clamp(5px,1.5vmin,12px);font:600 clamp(12px,3.5vmin,15px)/1.25 var(--font-sans),sans-serif;overflow:hidden}.head,.foot,.row{display:flex;justify-content:space-between;align-items:center;gap:8px}.head b{color:var(--accent)}.head span,.foot,.muted{color:var(--muted)}.stage{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;gap:8px}.cell,.pill{border:1px solid var(--line);border-radius:8px;background:var(--bg);padding:clamp(4px,1.2vmin,9px);text-align:center}.pill{border-radius:999px}.on{border-color:var(--accent)!important;background:color-mix(in srgb,var(--accent) 17%,var(--surface))!important;color:var(--fg)!important}.bad{border-color:#e16a5d!important;background:color-mix(in srgb,#e16a5d 18%,var(--surface))!important}.foot{font-size:clamp(12px,3vmin,14px)}.partitions{justify-content:space-around}.queryline{font:700 clamp(12px,3.5vmin,16px) ui-monospace,monospace;color:var(--accent);white-space:nowrap}.months{display:flex;gap:clamp(3px,1.5vmin,9px);flex:1;max-width:70%}.months .cell{flex:1;min-width:0;opacity:.35;transition:.3s}.months .cell.on{opacity:1}let n=0;const names=['Aug','Sep','Oct'];function tick(){document.querySelectorAll('.months .cell').forEach((e,i)=>e.classList.toggle('on',i===n));document.getElementById('filterMonth').textContent='WHERE month = '+names[n];document.getElementById('partitionstatus').textContent='read '+names[n]+' · skip 2';n=(n+1)%3}tick();const t=setInterval(tick,850);document.querySelector('.demo').onclick=()=>{clearInterval(t);tick()}파티셔닝은 하나의 논리 테이블을 날짜 범위나 키 값에 따라 여러 물리 파티션으로 나눕니다. 조건이 파티션 키와 맞으면 쿼리 계획에서 읽지 않을 파티션을 제외할 수 있습니다.
데모는 9월 주문 조회가 세 월별 파티션 중 9월만 선택하는 모습을 보여줍니다. 모든 쿼리가 빨라지는 것은 아니며, 키 선택과 파티션 개수, 오래된 파티션 관리 방식이 중요합니다.
날짜별 대용량 데이터에서 범위 조회와 보관 기간 관리가 중요할 때 검토합니다.