Parallel order preserving CREATE TABLE AS and INSERT INTO #5082
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.
This PR adds support for parallel processing of CREATE TABLE AS and INSERT INTO queries in an order preserving manner. That is to say, the order of the tuples in the table is guaranteed to be the same as the insertion order.
This method is used when order preservation is enabled (which defaults to true), and can be used as long as the source supports batch indexes (see #3700).
The
PhysicalBatchInsertworks by materializing row groups as aRowGroupCollectionper batch index, and merging them together in the correct order after the insertion is completed. If the row group collections are too small (which might happen if we have selective predicates) they will be merged together with row group collections of adjacent batch indexes. If the row group collections get large (> one row group) the row groups will be optimistically flushed to disk.There are two remaining limitations:
Both of those should be resolvable in a subsequent PR.
@lnkuiper perhaps you want to add batch index support to the
PhysicalOrderoperator, to allow for parallel materialization of ordered tables as well?