feat: 가상화 문서들 추가

This commit is contained in:
DongHyeonka
2026-09-10 08:54:05 +09:00
parent e9f6a93327
commit 43e1aadef0
695 changed files with 153404 additions and 12754 deletions
@@ -0,0 +1,25 @@
# 배치는 부모를 먼저 페이징하고 자식을 IN으로 따로 가져온다
## Alternative text
조회 코드, Hibernate 세션, feed_items, highlights 네 참여자 사이에서 부모 페이징이 먼저 일어나고 그다음 자식 IN 배치 조회가 일어나는 순서도.
## Long description
조회 코드가 부모 페이지를 요청하면 세션이 feed_items에 부모만 LIMIT으로 조회한다. 돌아온 부모에는 초기화되지 않은 컬렉션 프록시가 붙어 있다. 세션은 그 프록시를 batch fetch size만큼 모아 highlights를 WHERE fk IN 으로 조회하고, 받은 자식 행으로 컬렉션을 채워 조회 코드에 돌려준다.
## Elements and evidence
- **조회 코드** (actor): 페이지를 요청하는 애플리케이션 코드 Evidence: L1009L1010.
- **Hibernate 세션** (service): default_batch_fetch_size로 프록시를 모으는 주체 Evidence: L1010L1012.
- **feed_items** (store): 부모 테이블 Evidence: L1009L1010.
- **highlights** (store): 자식 테이블 Evidence: L1010L1011.
## Relationships
- **조회 코드 → Hibernate 세션:** 부모 페이지 요청. Evidence: L1009L1010.
- **Hibernate 세션 → feed_items:** 부모 LIMIT 페이징. Evidence: L1009L1010.
- **feed_items → Hibernate 세션:** 페이지 부모 + 미초기화 프록시. Evidence: L1010L1012.
- **Hibernate 세션 → highlights:** WHERE fk IN (?,…) 배치. Evidence: L1010L1012.
- **highlights → Hibernate 세션:** 자식 행. Evidence: L1010L1011.
- **Hibernate 세션 → 조회 코드:** 부모 + 컬렉션. Evidence: L1012L1014.
@@ -0,0 +1,21 @@
# 배치는 부모를 먼저 페이징하고 자식을 IN으로 따로 가져온다
# Question: 배치 페치는 어떤 순서로 부모 페이징과 자식 조회를 나누는가?
direction: down
n0: "조회 코드" {
shape: person
}
n1: "Hibernate 세션" {
shape: rectangle
}
n2: "feed_items" {
shape: rectangle
}
n3: "highlights" {
shape: rectangle
}
n0 -> n1: "부모 페이지 요청"
n1 -> n2: "부모 LIMIT 페이징"
n2 -> n1: "페이지 부모 + 미초기화 프록시"
n1 -> n3: "WHERE fk IN (?,…) 배치"
n3 -> n1: "자식 행"
n1 -> n0: "부모 + 컬렉션"
@@ -0,0 +1,15 @@
digraph techviz {
graph [rankdir=TB, splines=ortho, nodesep=0.55, ranksep=0.85];
node [fontname=Helvetica, fontsize=11, margin="0.18,0.12", style="rounded,filled", fillcolor=white, color="#2d4357", penwidth=1.5];
edge [fontname=Helvetica, fontsize=10, color="#364b5f", penwidth=1.4, arrowsize=0.75];
n0 [label="조회 코드", shape=box, style="rounded,dashed,filled"];
n1 [label="Hibernate 세션", shape=box, style="rounded,filled"];
n2 [label="feed_items", shape=box, style="rounded,filled"];
n3 [label="highlights", shape=box, style="rounded,filled"];
n0 -> n1 [label="부모 페이지 요청", style=solid];
n1 -> n2 [label="부모 LIMIT 페이징", style=solid];
n2 -> n1 [label="페이지 부모 + 미초기화 프록시", style=solid];
n1 -> n3 [label="WHERE fk IN (?,…) 배치", style=solid];
n3 -> n1 [label="자식 행", style=solid];
n1 -> n0 [label="부모 + 컬렉션", style=solid];
}
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="app.diagrams.net" modified="2026-07-23T00:00:00.000Z" agent="techviz-harness" version="24.7.17" type="device">
<diagram id="batch-fetch-in-clause" name="배치는 부모를 먼저 페이징하고 자식을 IN으로 따로 가져온다">
<mxGraphModel dx="870" dy="542" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="870" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="n_loader" value="조회 코드" tooltip="페이지를 요청하는 애플리케이션 코드 | Evidence: L1009-L1010" style="whiteSpace=wrap;html=1;rounded=1;strokeWidth=2;fontSize=14;fontStyle=1;fillColor=#ffffff;strokeColor=#2d4357;verticalAlign=middle;dashed=1;fillColor=#f5f7fa;" vertex="1" parent="1">
<mxGeometry x="45.0" y="35.0" width="150.0" height="78.0" as="geometry"/>
</mxCell>
<mxCell id="n_session" value="Hibernate 세션" tooltip="default_batch_fetch_size로 프록시를 모으는 주체 | Evidence: L1010-L1012" style="whiteSpace=wrap;html=1;rounded=1;strokeWidth=2;fontSize=14;fontStyle=1;fillColor=#ffffff;strokeColor=#2d4357;verticalAlign=middle;" vertex="1" parent="1">
<mxGeometry x="255.0" y="35.0" width="150.0" height="64.0" as="geometry"/>
</mxCell>
<mxCell id="n_feed-items" value="feed_items" tooltip="부모 테이블 | Evidence: L1009-L1010" style="whiteSpace=wrap;html=1;rounded=1;strokeWidth=2;fontSize=14;fontStyle=1;fillColor=#ffffff;strokeColor=#2d4357;verticalAlign=middle;shape=cylinder3;boundedLbl=1;backgroundOutline=1;fillColor=#eef6fb;" vertex="1" parent="1">
<mxGeometry x="465.0" y="35.0" width="150.0" height="78.0" as="geometry"/>
</mxCell>
<mxCell id="n_highlights" value="highlights" tooltip="자식 테이블 | Evidence: L1010-L1011" style="whiteSpace=wrap;html=1;rounded=1;strokeWidth=2;fontSize=14;fontStyle=1;fillColor=#ffffff;strokeColor=#2d4357;verticalAlign=middle;shape=cylinder3;boundedLbl=1;backgroundOutline=1;fillColor=#eef6fb;" vertex="1" parent="1">
<mxGeometry x="675.0" y="35.0" width="150.0" height="78.0" as="geometry"/>
</mxCell>
<mxCell id="e_m1" value="부모 페이지 요청" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;endArrow=block;endFill=1;" edge="1" parent="1" source="n_loader" target="n_session">
<mxGeometry relative="1" as="geometry">
<mxPoint x="225.0" y="128.0" as="offset"/>
</mxGeometry>
</mxCell>
<mxCell id="e_m2" value="부모 LIMIT 페이징" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;endArrow=block;endFill=1;" edge="1" parent="1" source="n_session" target="n_feed-items">
<mxGeometry relative="1" as="geometry">
<mxPoint x="435.0" y="190.0" as="offset"/>
</mxGeometry>
</mxCell>
<mxCell id="e_m3" value="페이지 부모 + 미초기화 프록시" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;endArrow=block;endFill=1;" edge="1" parent="1" source="n_feed-items" target="n_session">
<mxGeometry relative="1" as="geometry">
<mxPoint x="435.0" y="252.0" as="offset"/>
</mxGeometry>
</mxCell>
<mxCell id="e_m4" value="WHERE fk IN (?,…) 배치" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;endArrow=block;endFill=1;" edge="1" parent="1" source="n_session" target="n_highlights">
<mxGeometry relative="1" as="geometry">
<mxPoint x="540.0" y="314.0" as="offset"/>
</mxGeometry>
</mxCell>
<mxCell id="e_m5" value="자식 행" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;endArrow=block;endFill=1;" edge="1" parent="1" source="n_highlights" target="n_session">
<mxGeometry relative="1" as="geometry">
<mxPoint x="540.0" y="376.0" as="offset"/>
</mxGeometry>
</mxCell>
<mxCell id="e_m6" value="부모 + 컬렉션" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;endArrow=block;endFill=1;" edge="1" parent="1" source="n_session" target="n_loader">
<mxGeometry relative="1" as="geometry">
<mxPoint x="225.0" y="438.0" as="offset"/>
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
@@ -0,0 +1,835 @@
{
"type": "excalidraw",
"version": 2,
"source": "techviz-harness",
"elements": [
{
"id": "edge-m1",
"type": "arrow",
"x": 120.0,
"y": 140.0,
"width": 210.0,
"height": 0.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": null,
"seed": 1391175952,
"version": 1,
"versionNonce": 1697606636,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"points": [
[
0.0,
0.0
],
[
210.0,
0.0
]
],
"lastCommittedPoint": null,
"startBinding": {
"elementId": "node-loader",
"focus": 0,
"gap": 4
},
"endBinding": {
"elementId": "node-session",
"focus": 0,
"gap": 4
},
"startArrowhead": null,
"endArrowhead": "arrow",
"elbowed": true
},
{
"id": "edge-label-m1",
"type": "text",
"x": 180.0,
"y": 116.0,
"width": 90,
"height": 24,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 205439938,
"version": 1,
"versionNonce": 479762556,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"fontSize": 13,
"fontFamily": 5,
"text": "부모 페이지 요청",
"textAlign": "center",
"verticalAlign": "middle",
"containerId": null,
"originalText": "부모 페이지 요청",
"autoResize": true,
"lineHeight": 1.25
},
{
"id": "edge-m2",
"type": "arrow",
"x": 330.0,
"y": 202.0,
"width": 210.0,
"height": 0.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": null,
"seed": 1592612909,
"version": 1,
"versionNonce": 300451842,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"points": [
[
0.0,
0.0
],
[
210.0,
0.0
]
],
"lastCommittedPoint": null,
"startBinding": {
"elementId": "node-session",
"focus": 0,
"gap": 4
},
"endBinding": {
"elementId": "node-feed-items",
"focus": 0,
"gap": 4
},
"startArrowhead": null,
"endArrowhead": "arrow",
"elbowed": true
},
{
"id": "edge-label-m2",
"type": "text",
"x": 387.0,
"y": 178.0,
"width": 96,
"height": 24,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 774335790,
"version": 1,
"versionNonce": 203462744,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"fontSize": 13,
"fontFamily": 5,
"text": "부모 LIMIT 페이징",
"textAlign": "center",
"verticalAlign": "middle",
"containerId": null,
"originalText": "부모 LIMIT 페이징",
"autoResize": true,
"lineHeight": 1.25
},
{
"id": "edge-m3",
"type": "arrow",
"x": 330.0,
"y": 264.0,
"width": 210.0,
"height": 0.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": null,
"seed": 986781738,
"version": 1,
"versionNonce": 1446276182,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"points": [
[
210.0,
0.0
],
[
0.0,
0.0
]
],
"lastCommittedPoint": null,
"startBinding": {
"elementId": "node-feed-items",
"focus": 0,
"gap": 4
},
"endBinding": {
"elementId": "node-session",
"focus": 0,
"gap": 4
},
"startArrowhead": null,
"endArrowhead": "arrow",
"elbowed": true
},
{
"id": "edge-label-m3",
"type": "text",
"x": 367.0,
"y": 240.0,
"width": 136,
"height": 24,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 79282802,
"version": 1,
"versionNonce": 1904842631,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"fontSize": 13,
"fontFamily": 5,
"text": "페이지 부모 + 미초기화 프록시",
"textAlign": "center",
"verticalAlign": "middle",
"containerId": null,
"originalText": "페이지 부모 + 미초기화 프록시",
"autoResize": true,
"lineHeight": 1.25
},
{
"id": "edge-m4",
"type": "arrow",
"x": 330.0,
"y": 326.0,
"width": 420.0,
"height": 0.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": null,
"seed": 522855009,
"version": 1,
"versionNonce": 870155517,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"points": [
[
0.0,
0.0
],
[
420.0,
0.0
]
],
"lastCommittedPoint": null,
"startBinding": {
"elementId": "node-session",
"focus": 0,
"gap": 4
},
"endBinding": {
"elementId": "node-highlights",
"focus": 0,
"gap": 4
},
"startArrowhead": null,
"endArrowhead": "arrow",
"elbowed": true
},
{
"id": "edge-label-m4",
"type": "text",
"x": 460.0,
"y": 302.0,
"width": 160,
"height": 24,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 1255410992,
"version": 1,
"versionNonce": 1365345158,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"fontSize": 13,
"fontFamily": 5,
"text": "WHERE fk IN (?,…) 배치",
"textAlign": "center",
"verticalAlign": "middle",
"containerId": null,
"originalText": "WHERE fk IN (?,…) 배치",
"autoResize": true,
"lineHeight": 1.25
},
{
"id": "edge-m5",
"type": "arrow",
"x": 330.0,
"y": 388.0,
"width": 420.0,
"height": 0.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": null,
"seed": 1867262898,
"version": 1,
"versionNonce": 135793406,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"points": [
[
420.0,
0.0
],
[
0.0,
0.0
]
],
"lastCommittedPoint": null,
"startBinding": {
"elementId": "node-highlights",
"focus": 0,
"gap": 4
},
"endBinding": {
"elementId": "node-session",
"focus": 0,
"gap": 4
},
"startArrowhead": null,
"endArrowhead": "arrow",
"elbowed": true
},
{
"id": "edge-label-m5",
"type": "text",
"x": 495.0,
"y": 364.0,
"width": 90,
"height": 24,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 1226396936,
"version": 1,
"versionNonce": 1389084094,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"fontSize": 13,
"fontFamily": 5,
"text": "자식 행",
"textAlign": "center",
"verticalAlign": "middle",
"containerId": null,
"originalText": "자식 행",
"autoResize": true,
"lineHeight": 1.25
},
{
"id": "edge-m6",
"type": "arrow",
"x": 120.0,
"y": 450.0,
"width": 210.0,
"height": 0.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": null,
"seed": 70953370,
"version": 1,
"versionNonce": 201368227,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"points": [
[
210.0,
0.0
],
[
0.0,
0.0
]
],
"lastCommittedPoint": null,
"startBinding": {
"elementId": "node-session",
"focus": 0,
"gap": 4
},
"endBinding": {
"elementId": "node-loader",
"focus": 0,
"gap": 4
},
"startArrowhead": null,
"endArrowhead": "arrow",
"elbowed": true
},
{
"id": "edge-label-m6",
"type": "text",
"x": 180.0,
"y": 426.0,
"width": 90,
"height": 24,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 74056664,
"version": 1,
"versionNonce": 1569763366,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"fontSize": 13,
"fontFamily": 5,
"text": "부모 + 컬렉션",
"textAlign": "center",
"verticalAlign": "middle",
"containerId": null,
"originalText": "부모 + 컬렉션",
"autoResize": true,
"lineHeight": 1.25
},
{
"id": "node-loader",
"type": "rectangle",
"x": 45.0,
"y": 35.0,
"width": 150.0,
"height": 78.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "#ffffff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "dashed",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 1218388377,
"version": 1,
"versionNonce": 115862452,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false
},
{
"id": "node-label-loader",
"type": "text",
"x": 55.0,
"y": 45.0,
"width": 130.0,
"height": 58.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 1574424730,
"version": 1,
"versionNonce": 1971124067,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"fontSize": 15,
"fontFamily": 5,
"text": "조회 코드",
"textAlign": "center",
"verticalAlign": "middle",
"containerId": null,
"originalText": "조회 코드",
"autoResize": true,
"lineHeight": 1.25
},
{
"id": "node-session",
"type": "rectangle",
"x": 255.0,
"y": 35.0,
"width": 150.0,
"height": 64.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "#ffffff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 112382159,
"version": 1,
"versionNonce": 1956470051,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false
},
{
"id": "node-label-session",
"type": "text",
"x": 265.0,
"y": 45.0,
"width": 130.0,
"height": 44.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 648629018,
"version": 1,
"versionNonce": 1505062559,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"fontSize": 15,
"fontFamily": 5,
"text": "Hibernate 세션",
"textAlign": "center",
"verticalAlign": "middle",
"containerId": null,
"originalText": "Hibernate 세션",
"autoResize": true,
"lineHeight": 1.25
},
{
"id": "node-feed-items",
"type": "rectangle",
"x": 465.0,
"y": 35.0,
"width": 150.0,
"height": 78.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "#ffffff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 1553680117,
"version": 1,
"versionNonce": 1528008093,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false
},
{
"id": "node-label-feed-items",
"type": "text",
"x": 475.0,
"y": 45.0,
"width": 130.0,
"height": 58.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 1561637253,
"version": 1,
"versionNonce": 189981097,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"fontSize": 15,
"fontFamily": 5,
"text": "feed_items",
"textAlign": "center",
"verticalAlign": "middle",
"containerId": null,
"originalText": "feed_items",
"autoResize": true,
"lineHeight": 1.25
},
{
"id": "node-highlights",
"type": "rectangle",
"x": 675.0,
"y": 35.0,
"width": 150.0,
"height": 78.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "#ffffff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 281310605,
"version": 1,
"versionNonce": 933280984,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false
},
{
"id": "node-label-highlights",
"type": "text",
"x": 685.0,
"y": 45.0,
"width": 130.0,
"height": 58.0,
"angle": 0,
"strokeColor": "#1e1e1e",
"backgroundColor": "transparent",
"fillStyle": "solid",
"strokeWidth": 1,
"strokeStyle": "solid",
"roughness": 0,
"opacity": 100,
"groupIds": [],
"frameId": null,
"index": null,
"roundness": {
"type": 3
},
"seed": 1591294741,
"version": 1,
"versionNonce": 457414640,
"isDeleted": false,
"boundElements": [],
"updated": 0,
"link": null,
"locked": false,
"fontSize": 15,
"fontFamily": 5,
"text": "highlights",
"textAlign": "center",
"verticalAlign": "middle",
"containerId": null,
"originalText": "highlights",
"autoResize": true,
"lineHeight": 1.25
}
],
"appState": {
"gridSize": 10,
"viewBackgroundColor": "#ffffff",
"currentItemFontFamily": 5
},
"files": {}
}
@@ -0,0 +1,32 @@
{
"harness_version": "0.2.0",
"spec_id": "batch-fetch-in-clause",
"spec_version": "1.1",
"spec_sha256": "57f3a3e4984bdd31ec2458d19757d8ed3d34209ece4c649ab6fe1dd993198161",
"source_context": {
"document": "docs/n+1liner/final/document.md",
"document_sha256": "385ca44db5bf763cb1ff28a67d531d68876402b35d21dc54f2bc702e8bda0053",
"anchor": {
"kind": "heading",
"value": "11.5 배치가 N+1과 페이징을 함께 해결하는 이유",
"line": 1007
}
},
"outputs": [
"batch-fetch-in-clause.svg",
"batch-fetch-in-clause.drawio",
"batch-fetch-in-clause.mmd",
"batch-fetch-in-clause.d2",
"batch-fetch-in-clause.dot",
"batch-fetch-in-clause.excalidraw",
"batch-fetch-in-clause.alt.md"
],
"lint_issue_count": 0,
"assumption_count": 0,
"assumptions_allowed": false,
"composition_profile": "sequence",
"reference_ids": [
"payment-approval-sequence"
],
"diagram_only": true
}
@@ -0,0 +1,13 @@
%% 배치는 부모를 먼저 페이징하고 자식을 IN으로 따로 가져온다
%% question: 배치 페치는 어떤 순서로 부모 페이징과 자식 조회를 나누는가?
sequenceDiagram
participant n0 as 조회 코드
participant n1 as Hibernate 세션
participant n2 as feed_items
participant n3 as highlights
n0->>n1: 부모 페이지 요청
n1->>n2: 부모 LIMIT 페이징
n2->>n1: 페이지 부모 + 미초기화 프록시
n1->>n3: WHERE fk IN (?,…) 배치
n3->>n1: 자식 행
n1->>n0: 부모 + 컬렉션
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="870" height="542" viewBox="0 0 870 542" role="img" aria-labelledby="diagram-title diagram-description">
<title id="diagram-title">배치는 부모를 먼저 페이징하고 자식을 IN으로 따로 가져온다</title>
<desc id="diagram-description">조회 코드가 부모 페이지를 요청하면 세션이 feed_items에 부모만 LIMIT으로 조회한다. 돌아온 부모에는 초기화되지 않은 컬렉션 프록시가 붙어 있다. 세션은 그 프록시를 batch fetch size만큼 모아 highlights를 WHERE fk IN 으로 조회하고, 받은 자식 행으로 컬렉션을 채워 조회 코드에 돌려준다.</desc>
<metadata>{&quot;techviz&quot;:{&quot;spec_version&quot;:&quot;1.1&quot;,&quot;id&quot;:&quot;batch-fetch-in-clause&quot;,&quot;profile&quot;:&quot;sequence&quot;},&quot;source_context&quot;:{&quot;document&quot;:&quot;docs/n+1liner/final/document.md&quot;,&quot;document_sha256&quot;:&quot;385ca44db5bf763cb1ff28a67d531d68876402b35d21dc54f2bc702e8bda0053&quot;,&quot;anchor&quot;:{&quot;kind&quot;:&quot;heading&quot;,&quot;value&quot;:&quot;11.5 배치가 N+1과 페이징을 함께 해결하는 이유&quot;,&quot;line&quot;:1007}},&quot;evidence_policy&quot;:&quot;Each factual element cites source lines or is marked assumption.&quot;,&quot;diagram_only&quot;:true}</metadata>
<defs>
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M 0 0 L 10 5 L 0 10 z" />
</marker>
<style>
:root { color-scheme: light; }
text { font-family: Inter, Pretendard, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; fill: #111827; }
.canvas { fill: #ffffff; }
.group-box { fill: #ffffff; stroke: #9ca3af; stroke-width: 1.4; stroke-dasharray: 7 5; }
.group-label-bg { fill: #ffffff; }
.group-label { font-size: 13px; font-weight: 650; fill: #374151; }
.edge { fill: none; stroke: #374151; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; marker-end: url(#arrow); }
.edge.style-dashed, .edge.semantic-dashed, .edge.assumption { stroke-dasharray: 7 5; }
.edge.style-dotted { stroke-dasharray: 2 5; }
.edge.emphasis-primary { stroke: #2563eb; stroke-width: 2.2; }
.edge.emphasis-muted { stroke: #9ca3af; }
.edge.emphasis-warning, .edge.kind-failure, .edge.kind-error { stroke: #dc2626; stroke-width: 2.2; }
.edge-label-bg { fill: #ffffff; }
.edge-label { font-size: 12px; font-weight: 560; text-anchor: middle; }
.node-shape { fill: #ffffff; stroke: #4b5563; stroke-width: 1.7; }
.node-shape.emphasis-primary { stroke: #2563eb; stroke-width: 2.2; }
.node-shape.emphasis-muted { stroke: #9ca3af; fill: #f9fafb; }
.node-shape.emphasis-warning { stroke: #d97706; stroke-width: 2; fill: #fffdf5; }
.node-shape.kind-database, .node-shape.kind-datastore, .node-shape.kind-storage { fill: #f8fafc; }
.node-shape.kind-queue, .node-shape.kind-event, .node-shape.kind-topic { fill: #fafafa; }
.node-shape.assumption { stroke-dasharray: 4 4; }
.storage-bottom, .controller-divider { fill: none; stroke: #4b5563; stroke-width: 1.4; }
.controller-led { fill: #4b5563; }
.actor-symbol { fill: none; stroke: #4b5563; stroke-width: 1.8; stroke-linecap: round; }
.actor-symbol.emphasis-primary { stroke: #2563eb; stroke-width: 2.2; }
.node-label { font-size: 14px; font-weight: 650; text-anchor: middle; }
.node-role { font-size: 10px; letter-spacing: 0.04em; text-anchor: middle; fill: #6b7280; }
.node-detail-divider { stroke: #d1d5db; stroke-width: 1; }
.node-detail { font-size: 11px; fill: #374151; }
.assumption-badge { font-size: 9px; font-weight: 700; fill: #92400e; }
.failure-mark { stroke: #dc2626; stroke-width: 4; stroke-linecap: round; }
.lifeline { stroke: #9ca3af; stroke-width: 1.2; stroke-dasharray: 5 5; }
.timeline-axis { stroke: #374151; stroke-width: 1.8; marker-end: url(#arrow); }
.timeline-stem { stroke: #6b7280; stroke-width: 1.3; }
.timeline-marker { fill: #ffffff; stroke: #374151; stroke-width: 1.7; }
.timeline-marker.primary { fill: #2563eb; stroke: #2563eb; }
.timeline-marker.warning { fill: #dc2626; stroke: #dc2626; }
.timeline-label { font-size: 13px; font-weight: 650; text-anchor: middle; }
.timeline-detail { font-size: 11px; fill: #4b5563; text-anchor: middle; }
</style>
</defs>
<rect class="canvas" width="870" height="542" />
<g class="actor-symbol emphasis-normal" data-evidence="1009-1010"><circle cx="120.0" cy="55.0" r="11.0" /><line x1="120.0" y1="71.0" x2="120.0" y2="74.0" /><line x1="102.0" y1="81.0" x2="138.0" y2="81.0" /><line x1="120.0" y1="74.0" x2="105.0" y2="91.0" /><line x1="120.0" y1="74.0" x2="135.0" y2="91.0" /></g>
<text class="node-label" x="120.0" y="106.0">조회 코드</text>
<line class="lifeline" x1="120.0" y1="113.0" x2="120.0" y2="512.0" />
<rect class="node-shape kind-service emphasis-normal role-participant" data-evidence="1010-1012" x="255.0" y="35.0" width="150.0" height="64.0" rx="7" />
<text class="node-label" x="330.0" y="65.0">Hibernate 세션</text>
<line class="lifeline" x1="330.0" y1="99.0" x2="330.0" y2="512.0" />
<rect class="node-shape kind-store emphasis-normal role-participant" data-evidence="1009-1010" x="465.0" y="48.0" width="150.0" height="52.0" /><ellipse class="node-shape kind-store emphasis-normal role-participant" cx="540.0" cy="48.0" rx="75.0" ry="13.0" /><path class="storage-bottom" d="M 465.0 100.0 A 75.0 13.0 0 0 0 615.0 100.0" />
<text class="node-label" x="540.0" y="75.0">feed_items</text>
<line class="lifeline" x1="540.0" y1="113.0" x2="540.0" y2="512.0" />
<rect class="node-shape kind-store emphasis-normal role-participant" data-evidence="1010-1011" x="675.0" y="48.0" width="150.0" height="52.0" /><ellipse class="node-shape kind-store emphasis-normal role-participant" cx="750.0" cy="48.0" rx="75.0" ry="13.0" /><path class="storage-bottom" d="M 675.0 100.0 A 75.0 13.0 0 0 0 825.0 100.0" />
<text class="node-label" x="750.0" y="75.0">highlights</text>
<line class="lifeline" x1="750.0" y1="113.0" x2="750.0" y2="512.0" />
<polyline class="edge kind-request style-solid emphasis-normal" points="120.0,140.0 330.0,140.0" data-evidence="1009-1010" />
<rect class="edge-label-bg" x="175.8" y="114.0" width="98.4" height="22" rx="3" />
<text class="edge-label" x="225.0" y="129.0">1. 부모 페이지 요청</text>
<polyline class="edge kind-query style-solid emphasis-normal" points="330.0,202.0 540.0,202.0" data-evidence="1009-1010" />
<rect class="edge-label-bg" x="375.8" y="176.0" width="118.5" height="22" rx="3" />
<text class="edge-label" x="435.0" y="191.0">2. 부모 LIMIT 페이징</text>
<polyline class="edge kind-response style-dashed emphasis-normal semantic-dashed" points="540.0,264.0 330.0,264.0" data-evidence="1010-1012" />
<rect class="edge-label-bg" x="359.0" y="238.0" width="152.0" height="22" rx="3" />
<text class="edge-label" x="435.0" y="253.0">3. 페이지 부모 + 미초기화 프록시</text>
<polyline class="edge kind-query style-solid emphasis-normal" points="330.0,326.0 750.0,326.0" data-evidence="1010-1012" />
<rect class="edge-label-bg" x="453.9" y="300.0" width="172.1" height="22" rx="3" />
<text class="edge-label" x="540.0" y="315.0">4. WHERE fk IN (?,…) 배치</text>
<polyline class="edge kind-response style-dashed emphasis-normal semantic-dashed" points="750.0,388.0 330.0,388.0" data-evidence="1010-1011" />
<rect class="edge-label-bg" x="507.6" y="362.0" width="64.9" height="22" rx="3" />
<text class="edge-label" x="540.0" y="377.0">5. 자식 행</text>
<polyline class="edge kind-response style-dashed emphasis-normal semantic-dashed" points="330.0,450.0 120.0,450.0" data-evidence="1012-1014" />
<rect class="edge-label-bg" x="179.2" y="424.0" width="91.7" height="22" rx="3" />
<text class="edge-label" x="225.0" y="439.0">6. 부모 + 컬렉션</text>
</svg>

After

Width:  |  Height:  |  Size: 7.8 KiB