-
Notifications
You must be signed in to change notification settings - Fork 897
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New procedures to `merge_chunks` are introduced that can merge an arbitrary number of chunks if the right conditions apply. Basic checks are done to ensure that the chunks can be merged from a partitioning perspective. Some more advanced cases that are potentially mergeable are not supported at this time (e.g., chunks with non-adjacent partitioning) and merging of compressed chunks. Merging compressed chunks requires additional work, although the same basic rewrite approach should work also on the internal compressed relations. Still, one needs to handle merges of a compressed chunk and a non-compressed chunk, or two compressed chunks with different compression settings, partially compressed chunks, and so forth. This is left for a future enhancement. Currently, the merge defaults to taking an AccessExclusive lock on the merged chunks to prevent deadlocks and concurrent modifications. Weaker locking is supported via an anonymous settings variable, and it is used in tests to illustrate various deadlock scenarios. Alternative locking approaches, including multi-transactional merges, can be considered in the future. The actual merging is done by rewriting all the data from multiple chunks into a (temporary) merged heap using the same approach as that implemented to support VACUUM FULL and CLUSTER. Then this new heap is swapped into one of the original relations while the rest are dropped. This approach is MVCC compliant and implements correct visibility under higher isolation levels, while also cleaning up garbage tuples.
- Loading branch information
Showing
24 changed files
with
2,494 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Implements: #7433 Add support for merging chunks |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,14 @@ CREATE OR REPLACE PROCEDURE @[email protected]_to_rowstore( | |
if_columnstore BOOLEAN = true | ||
) AS '@MODULE_PATHNAME@', 'ts_decompress_chunk' LANGUAGE C; | ||
|
||
CREATE OR REPLACE PROCEDURE @[email protected]_chunks( | ||
chunk1 REGCLASS, chunk2 REGCLASS | ||
) LANGUAGE C AS '@MODULE_PATHNAME@', 'ts_merge_two_chunks'; | ||
|
||
CREATE OR REPLACE PROCEDURE @[email protected]_chunks( | ||
chunks REGCLASS[] | ||
) LANGUAGE C AS '@MODULE_PATHNAME@', 'ts_merge_chunks'; | ||
|
||
CREATE OR REPLACE FUNCTION _timescaledb_functions.recompress_chunk_segmentwise( | ||
uncompressed_chunk REGCLASS, | ||
if_compressed BOOLEAN = true | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,3 +144,12 @@ CREATE FUNCTION @[email protected]_continuous_aggregate_policy( | |
RETURNS INTEGER | ||
AS '@MODULE_PATHNAME@', 'ts_update_placeholder' | ||
LANGUAGE C VOLATILE; | ||
|
||
-- Merge chunks | ||
CREATE PROCEDURE @[email protected]_chunks( | ||
chunk1 REGCLASS, chunk2 REGCLASS | ||
) LANGUAGE C AS '@MODULE_PATHNAME@', 'ts_update_placeholder'; | ||
|
||
CREATE PROCEDURE @[email protected]_chunks( | ||
chunks REGCLASS[] | ||
) LANGUAGE C AS '@MODULE_PATHNAME@', 'ts_update_placeholder'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,3 +87,7 @@ CREATE FUNCTION @[email protected]_continuous_aggregate_policy( | |
RETURNS INTEGER | ||
AS '@MODULE_PATHNAME@', 'ts_policy_refresh_cagg_add' | ||
LANGUAGE C VOLATILE; | ||
|
||
-- Merge chunks | ||
DROP PROCEDURE IF EXISTS @[email protected]_chunks(chunk1 REGCLASS, chunk2 REGCLASS); | ||
DROP PROCEDURE IF EXISTS @[email protected]_chunks(chunks REGCLASS[]); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.