Code Room
Vibe codingMediumvc-g104
Subject Ai code reviewLevel Mid–Senior~15 minCommon in Algorithms & data structures interviewsIndustries Technology, Software development

Question

An AI agent wrote this Python ETL step to load a large CSV into Postgres. It works on the 10k-row sample. On the real 80M-row file it exhausts memory and, when run on a smaller file, takes hours.

python
def load(path, conn):    df = pd.read_csv(path)    cur = conn.cursor()    for _, row in df.iterrows():        cur.execute(            "INSERT INTO events (id, ts, payload) VALUES (%s, %s, %s)",            (row.id, row.ts, row.payload),        )    conn.commit()

Identify the scaling problems and how you'd rewrite this load.

What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.