Repository navigation
Conversation
Transaction.table_metadata deep-copied the whole metadata on every read, even with nothing staged, so appends slowed down as the snapshot history grew.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #4294
Rationale for this change
Transaction.table_metadatareplays the staged updates on every read:iceberg-python/pyiceberg/table/__init__.py
Lines 276 to 278 in 718c790
and
update_table_metadataalways ends in a deep copy:iceberg-python/pyiceberg/table/update/__init__.py
Line 763 in 718c790
An append reads the property about 20 times before staging anything, so every read deep copies the full snapshot history. This returns the table's metadata directly when nothing is staged, as @geruh suggested on #3302.
Table.metadataalready shares that object uncopied.The reproduction script from #4294, on
mainwith and without this change (one timed append per depth):update_table_metadatacallsAre these changes tested?
Yes. Two tests in
tests/table/test_init.pycheck that with nothing staged the property returns the table's own metadata object and that staged updates are still applied without changing the table's metadata.test_snapshot_producer_bounded_metadata_accesscountsupdate_table_metadatacalls as a stand-in for reads of the property, so it now stages an update first, otherwise every read would skip the call. It still fails if a read is added back to the snapshot producer.Are there any user-facing changes?
No.