Code Room
Code reviewMediumcr-g643
Subject Sql paginationLevel Mid–Senior~22 minCommon in Databases & SQL · Networking & APIs interviewsIndustries Software development

Question

Review this Python function that exports events to a downstream job.

The `events` table grows by ~5M rows/day and `since` is often the start of the month.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewpython
def export_events(conn, since):    cur = conn.cursor()    cur.execute(        "SELECT id, payload FROM events WHERE created_at >= %s ORDER BY created_at",        (since,),    )    rows = cur.fetchall()          # pull everything    results = []    for row in rows:        results.append(transform(row))    return results
Run or narrate your approach, then ask the coach.