Code RoomFeature flag full table scan
MediumPrep Room Coding #1932

Feature flag full table scan

Code reviewCode quality & reviewMid–Senior~18 min

Review this Go function that checks whether a feature flag is enabled for a tenant. The flags table is large and the function is called on nearly every request.

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.

0:00 of about 18 min
Mark a line and say what kind of problem it is.0 findings
1func flagEnabled(db *sql.DB, tenant, flag string) bool {
2 rows, _ := db.Query("SELECT tenant, name, enabled FROM flags")
3 defer rows.Close()
4 for rows.Next() {
5 var t, n string
6 var en bool
7 rows.Scan(&t, &n, &en)
8 if t == tenant && n == flag {
9 return en
10 }
11 }
12 return false
13}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.