Skip to main content
February 19, 20261.0.23v1.0.23RSS

v1.0.23 — [Performance] bulkUpdateOrder Issues N+1 UPDATE Queries in a Loop

Release Notes

The feature.bulkUpdateOrder tRPC mutation iterates over orderedIds with a for-loop, firing one UPDATE query per feature. For a project with 100+ features this becomes 100+ sequential round-trips to Postgres on every drag-and-drop reorder. This blocks the request for the full duration and hammers the DB connection pool.

Category: database File: src/lib/routers/feature.ts Recommendation: Replace the for-loop with a single SQL statement using an unnested VALUES list: UPDATE features SET sort_order = v.sort_order FROM (VALUES ...) AS v(id, sort_order) WHERE features.id = v.id AND features.project_id = $projectId. This collapses N round-trips into 1. Estimated Improvement: Reduces reorder latency from O(n) × ~5ms per round-trip to a single ~5ms query. For 100 features: 500ms → 5ms (100× faster).