You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 26633e7
Browse filesBrowse the repository at this point in the historyBrowse files
Reply count and the reply-avatar summary each folded the two shapes of
"child record" into one OR: (kind='post' AND root_id=?) OR (kind='reply'
AND parent_id=?). Which column applies is not known at plan time, so
SQLite dropped both records_root_idx and records_parent_idx and scanned
records end to end for every row of the outer query.
Split the branches instead: CASE r.kind for the scalar count, UNION ALL
for the summary join. Each branch is now a plain equality and reaches its
index. On 12,500 synthetic rows a 20-record page goes from 239,999
full-scan steps to 19.
The counts are unchanged, verified row-for-row over every record --
including replies with children and rows hidden by deleted_at or
moderation_state. Nothing was denormalised: a stored counter would need
re-deriving on every moderation change, and it must match the avatar list
exactly.
The site tests lock the shape rather than the result, because the OR form
answers correctly and no behavioural test can catch its return.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0 commit comments