Skip to content

Skip the shuffle when the position doesn't actually change - #81

Open
brendon wants to merge 3 commits into
mainfrom
perf/skip-unchanged-positions
Open

brendon wants to merge 3 commits into
mainfrom
perf/skip-unchanged-positions

Conversation

@brendon

@brendon brendon commented Oct 16, 2026

Copy link
Copy Markdown
Owner

The column writer marks the position as changed on every assignment, and forms resubmit position on every save. When the solidified position is the one the record already has (in the same scope), we still locked the scope, moved the record to 0, ran a contract that touched nothing and wrote the position back. On main that's 4 UPDATEs for a save that changes nothing, plus updated_at is bumped and saved_change_to_position? is true.

Fix

After solidifying, if the scope is unchanged and the position equals the one in the database, drop the change and return. A save with no other changes now doesn't touch the row at all. Scope changes are unaffected, so the 0.1.2 behaviour (the same position number in a new scope is still an explicit position) is kept.

One behaviour change to flag: assigning the current position no longer bumps updated_at or reports saved_change_to_position?. I think that's correct, since nothing moved, but it's worth knowing in case anything relies on it.

Tests

Assigning 2, {after: first} and {before: third} to the second item issues no UPDATEs, in all three TestPositioning variants (including both composite key ones).

Changelog: Don't write anything when an assigned position doesn't change.

🤖 Generated with Claude Code

brendon and others added 3 commits October 16, 2026 12:53
The column writer marks the position as changed on every assignment,
which forms do on every save. When the solidified position is the one
the record already has (in the same scope), we still locked the scope,
moved the record out of the way, ran both halves of a contract that
touched nothing, and wrote the position back. That bumped `updated_at`
and reported `saved_change_to_position?` even though nothing moved.

Return early in that case and drop the change, so a save with no other
changes doesn't touch the row at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant