Skip to content

Eliminate audits.last query when filtering touch changes#774

Open
reid-rigo wants to merge 2 commits into
collectiveidea:mainfrom
reid-rigo:reid-rigo/eliminate-query-when-touching
Open

Eliminate audits.last query when filtering touch changes#774
reid-rigo wants to merge 2 commits into
collectiveidea:mainfrom
reid-rigo:reid-rigo/eliminate-query-when-touching

Conversation

@reid-rigo

@reid-rigo reid-rigo commented May 4, 2026

Copy link
Copy Markdown
Contributor

This change is an optimization for the fix introduced in #660

Cache the last audit changes on the instance to remove the audits.last query when filtering changes in audited_changes.

reid-rigo and others added 2 commits May 4, 2026 14:23
Cache the last-written audit's audited_changes on the instance so that
the dedupe path in audit_touch can use it directly instead of issuing
an extra SELECT for audits.last on every touch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@reid-rigo reid-rigo marked this pull request as ready for review May 4, 2026 18:57
@akostadinov

Copy link
Copy Markdown
Contributor

How is this supposed to work for multiple processes working simultaneously? Can a few tests be added to demonstrate the desired behavior when memoized changes are present/not present/outdated by another process?

@reid-rigo

Copy link
Copy Markdown
Contributor Author

@akostadinov, this change is an optimization for the fix in #660 (added to PR description)

In main the code assumes that audits.last is the audit created within the current thread of execution, which won't be true in concurrent scenarios. This change should fix that by saving "these are the changes I just saved" in memory.

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.

2 participants