Auto-detect starting ID from partition range in synchronize #20
+172
−84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
--startis omitted, synchronize now uses the intermediate table'spartition range to compute the starting ID, instead of scanning the entire
source table with an unbounded
MIN(id)."no partition found" errors when source rows fall outside existing partitions.
transformIdValue,resolvePartitionContext,resolvePartitionTimeFilter) are consolidatedin
table.ts, eliminating duplication acrosssynchronizer.tsandfiller.ts.Motivation
Fill has always resolved partition settings from the destination table and
applied a time filter to its batch queries. Synchronize was the odd one out —
it did a bare
MIN(id)across the entire source table and had no time boundson batch fetches.
Callers no longer need to manually compute a starting ID based on partition
boundaries. The
--startoption still works for explicit overrides, but thedefault behavior is now partition-aware.
What changed
table.ts:transformIdValueexported (with nullable/non-nullableoverloads). New
resolvePartitionContextreturns settings, partitions, andtime filter in one call.
resolvePartitionTimeFilteris a conveniencewrapper.
partitions()signature widened toCommonQueryMethods.synchronizer.ts: Uses shared helpers.initpasses the time filterto
sourceTable.minId()when--startis omitted.#fetchBatchappliesthe time filter to batch queries.
filler.ts: Replaced inline partition resolution and localtransformIdValuewith shared imports fromtable.ts.Test plan
--startis omitted and partitions exist
PGSLICE_URL🤖 Generated with Claude Code