perf(765-2): 벌 꺼내 끼우기 자식 행을 표마다 한 번에 넣음 — 칩 5.5~8 s → 약 2 s

- 검증_sub5 실측: _load_db 3.1~5.2 s(원격 DB 에 횡단 · 정점 줄마다 INSERT) → 0.5 s
- test_637_lidar 줄 길이 맞춤

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-03 16:06:23 +09:00
co-authored by Claude Opus 5.5
parent fe6f67d123
commit 8a50a155ab
2 changed files with 18 additions and 2 deletions
+16 -1
View File
@@ -246,6 +246,19 @@ async def _insert(cursor: Any, table: str, row: dict[str, Any]) -> int:
return int(cursor.lastrowid)
async def _insert_many(cursor: Any, table: str, rows: list[dict[str, Any]]) -> None:
"""한 표 여러 줄을 한 번에(원격 DB 왕복 줄 · 줄마다 넣으면 칩 5 s)."""
if not rows:
return
columns = list(rows[0])
names = ", ".join(f"`{name}`" for name in columns)
marks = ", ".join(["%s"] * len(columns))
await cursor.executemany(
f"INSERT INTO {table} ({names}) VALUES ({marks})",
[tuple(row.get(name) for name in columns) for row in rows],
)
async def _load_db(
connection: aiomysql.Connection, project_id: str, dump: dict[str, Any]
) -> dict[int, int]:
@@ -259,13 +272,15 @@ async def _load_db(
old = int(row.pop("id"))
route_map[old] = await _insert(cursor, "routes", row)
for table in _ROUTE_CHILDREN:
rows = []
for child in dump.get(table, []):
row = dict(child)
row.pop("id", None)
row["route_id"] = route_map[int(row["route_id"])]
if "project_id" in row:
row["project_id"] = project_id
await _insert(cursor, table, row)
rows.append(row)
await _insert_many(cursor, table, rows)
for stage in dump.get("stages", []):
sets = ", ".join(f"`{name}`=%s" for name in _STAGE_COLUMNS)
await cursor.execute(
+2 -1
View File
@@ -265,7 +265,8 @@ def test_B_뿌리_짓기_수치지형도_그대로_덮임(tmp_path: Path, monkey
# 갈음 = 안 지은 필터(앞서 자동으로 지은 다듬기 필터 · 766 기본)는 옛 LAS 것 → 지움 ·
# 수치지형도 그대로(637-3)
assert "B04_PreProcess/models/dtm_ptd_refine.npz" in kept["dropped"]
assert not list((tmp_path / b05.MODELS).glob("*_refine*.npz")) and sheet.read_bytes() == b"sheet"
assert not list((tmp_path / b05.MODELS).glob("*_refine*.npz"))
assert sheet.read_bytes() == b"sheet"
def test_옛_필터_지우기는_긴_이름_지은_필터를_안_건드림(tmp_path: Path) -> None: