SQL property graph queries

SQL 속성 그래프 질의

PostgreSQL 19 beta supports SQL/PGQ path queries over relationships stored in tables.

···
html
<div class="demo"><div class="head"><b>SQL/PGQ PATH</b><span>MATCH (A)-[]->(next)</span></div><div class="stage pgq"><div class="vertex" id="graphA">A</div><div class="edge" id="edgeAB">→</div><div class="vertex" id="graphB">B</div><div class="edge" id="edgeBC">→</div><div class="vertex" id="graphC">C</div></div><div class="foot"><span id="graphstatus">start at A</span><span>1 · 2 hops</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)}.pgq{gap:clamp(4px,2vmin,18px)}.vertex{width:clamp(34px,13vmin,64px);aspect-ratio:1;border:2px solid var(--line);border-radius:50%;display:grid;place-items:center;background:var(--bg);font:700 clamp(17px,5vmin,26px) ui-monospace,monospace;transition:.3s}.vertex.on{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 20%,var(--surface))}.edge{font-size:clamp(16px,5vmin,26px);color:var(--line);transition:.3s}.edge.on{color:var(--accent)}
js
let n=0;function tick(){['graphA','graphB','graphC'].forEach((id,i)=>document.getElementById(id).classList.toggle('on',i<=n));['edgeAB','edgeBC'].forEach((id,i)=>document.getElementById(id).classList.toggle('on',i<n));document.getElementById('graphstatus').textContent=['start at A','A → B: 1 hop','A → B → C: 2 hops'][n];n=(n+1)%3}tick();const t=setInterval(tick,900);document.querySelector('.demo').onclick=()=>{clearInterval(t);tick()}

SQL/PGQ is a standard SQL feature for querying property graphs made of vertices and edges. PostgreSQL 19 beta supports path patterns that traverse those relationships.

The demo follows connections from A one hop at a time. Graph queries do not replace every join; specify direction and repetition bounds to get the intended paths. Syntax and behavior can change before the stable release.

When to use

Evaluate it for multihop relationships among people, products, or accounts in SQL.

Open as page ↗