mirror of
https://github.com/penpot/penpot.git
synced 2026-09-11 22:49:30 +00:00
Rewrite sql:file-comment-users to join comment with comment_thread and union the requesting profile id, then join the resulting small id set against profile. The previous "id IN (subquery) OR id = ?" forced a sequential scan over the whole profile table with a hashed subplan filter, taking ~1.9s on large instances. The semi-join lets the planner use profile_pkey, dropping the query to sub-millisecond time. UNION (not UNION ALL) keeps the previous dedup semantics when the requesting profile is also a commenter. AI-assisted-by: deepseek-flash