Table partitioning

테이블 파티셔닝

Split a large table by range or another key so queries can read only matching partitions.

···
html
<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>
css
*{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}
js
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()}

Partitioning divides one logical table into physical partitions by a date range or another key. When a filter matches the partition key, the plan can prune partitions it does not need.

The demo routes a September order query to only the September partition. It does not speed up every query; key choice, partition count, and old-partition maintenance matter.

When to use

Consider it for large time-based data with range queries and retention needs.

Open as page ↗