Conversation
|
🦸 Review Hero Summary (round 1) Below consensus threshold (2 unique issues not confirmed by majority)
Local fix prompt (copy to your coding agent) |
fc382f7 to
cc5d505
Compare
cc5d505 to
d6bcdbd
Compare
| * that table, and the argument-less form rescans the whole database, so the cost is proportional | ||
| * to the tables checked rather than to the number of round trips. | ||
| */ | ||
| export const checkForeignKeys = async ( |
There was a problem hiding this comment.
[Performance] suggestion
This loop reintroduces the exact cost pattern the removed comment warned about ("far cheaper than issuing one PRAGMA per model (20-30+ awaits)"): checkForeignKeys now issues one PRAGMA foreign_key_check(table) round-trip per touched table instead of one for the whole database. The scoping only pays off when few tables are touched (typical incremental sync). But for the initial sync — the largest and most performance-sensitive pull path, in MobileSyncManager.pullInitialSync — touchedTables ends up covering nearly every synced model anyway, since the initial pull populates most tables. In that case this change replaces 1 round-trip with 20-30+ sequential awaited queries through the SQLite bridge, with no reduction in total rows scanned, just added per-call overhead. Consider keeping the single whole-DB PRAGMA + client-side filter for the initial-sync path and reserving the per-table loop for incremental syncs where the touched-table set is genuinely small.
|
🦸 Review Hero Summary (round 2) Local fix prompt (copy to your coding agent) |
…nothing to pull A zero-record incremental pull still created the snapshot table, opened the (write-locking) save transaction and ran the dependency sort and foreign key check inside it, every five minutes. Now it only advances the pull cursor. The pull count is a Postgres bigint that arrives serialised as a string, so it is coerced to a number where it enters the app; otherwise this gate (and the existing one in pullRecordsInBatches) never matches.
d6bcdbd to
e396315
Compare
Foreign keys are deferred for the whole save transaction, so the order models are saved in is irrelevant. The sort cost one PRAGMA foreign_key_list round trip per model (~53) inside the transaction on every sync.
…at received rows The argument-less PRAGMA foreign_key_check rescans every row of every table against every foreign key, on every sync. The per-table form only scans that table, so pass the tables that actually had rows saved (usually a handful, not all ~53 pull-direction tables). Error output is unchanged.
e396315 to
d15ae7e
Compare
Changes
Part 3 of 4 (TAM-7126), stacked on #11093.
The argument-less
PRAGMA foreign_key_checkrescans every row of every table against every foreign key. The existing comment argued it was cheaper than one pragma per model, which is true of round trips but not of work done:foreign_key_check("table")scans only that table. The save functions now return the set of tables that actually received rows, and the check is scoped to those (usually a handful rather than all ~53). Error output is unchanged.Stack: #11092 → #11093 → this → #11095.
Auto-Deploy
Options
Tests
Review Hero
.github/review-hero/suppressions.yml. Also runs automatically at the end of any auto-fix run.Remember to...