-
Notifications
You must be signed in to change notification settings - Fork 896
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., complicated merges of chunks with multi-dimensional 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. Howver, one needs to handle merge of a compressed chunk with a non-compressed chunk, or two compressed chunks with different compression settings, 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, but this is mostly to prove in tests that these approaches can lead to deadlocks. 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 doing vacuum and leaving no garbage tuples.
- Loading branch information
Showing
23 changed files
with
2,322 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 |
---|---|---|
|
@@ -114,3 +114,12 @@ CREATE FUNCTION @[email protected]_columnstore_stats (hypertable REGCLASS) | |
STABLE STRICT | ||
AS 'SELECT * FROM @[email protected]_compression_stats($1)' | ||
SET search_path TO pg_catalog, pg_temp; | ||
|
||
-- 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 |
---|---|---|
|
@@ -58,3 +58,6 @@ DROP VIEW timescaledb_information.hypertable_columnstore_settings; | |
DROP VIEW timescaledb_information.chunk_columnstore_settings; | ||
|
||
DROP PROCEDURE IF EXISTS _timescaledb_functions.cagg_migrate_update_watermark(INTEGER); | ||
-- 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
Oops, something went wrong.