-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use segmentwise recompression in compress policy
Change compression policy to use segmentwise recompression when possible to increase performance. Segmentwise recompression decompresses rows into memory, thus reducing IO load when recompressing, making it much faster for bigger chunks.
- Loading branch information
1 parent
8b3227a
commit 520d453
Showing
8 changed files
with
100 additions
and
80 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,2 @@ | ||
Implements: #6343 Enable segmentwise recompression in compression policy | ||
Thanks @fetchezar for reporting the issue |
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 |
---|---|---|
|
@@ -123,26 +123,19 @@ BEGIN | |
) | ||
) AND recompress_enabled IS TRUE THEN | ||
BEGIN | ||
PERFORM @[email protected]_chunk(chunk_rec.oid, if_compressed => true); | ||
-- first check if there's an index. Might have to use a heuristic to determine if index usage would be efficient, | ||
-- or if we'd better fall back to decompressing & recompressing entire chunk | ||
IF _timescaledb_functions.get_compressed_chunk_index_for_recompression(chunk_rec.oid) IS NOT NULL THEN | ||
PERFORM _timescaledb_functions.recompress_chunk_segmentwise(chunk_rec.oid); | ||
ELSE | ||
PERFORM @[email protected]_chunk(chunk_rec.oid, if_compressed => true); | ||
PERFORM @[email protected]_chunk(chunk_rec.oid); | ||
END IF; | ||
EXCEPTION WHEN OTHERS THEN | ||
GET STACKED DIAGNOSTICS | ||
_message = MESSAGE_TEXT, | ||
_detail = PG_EXCEPTION_DETAIL; | ||
RAISE WARNING 'decompressing chunk "%" failed when compression policy is executed', chunk_rec.oid::regclass::text | ||
USING DETAIL = format('Message: (%s), Detail: (%s).', _message, _detail), | ||
ERRCODE = sqlstate; | ||
END; | ||
-- SET LOCAL is only active until end of transaction. | ||
-- While we could use SET at the start of the function we do not | ||
-- want to bleed out search_path to caller, so we do SET LOCAL | ||
-- again after COMMIT | ||
BEGIN | ||
PERFORM @[email protected]_chunk(chunk_rec.oid); | ||
EXCEPTION WHEN OTHERS THEN | ||
GET STACKED DIAGNOSTICS | ||
_message = MESSAGE_TEXT, | ||
_detail = PG_EXCEPTION_DETAIL; | ||
RAISE WARNING 'compressing chunk "%" failed when compression policy is executed', chunk_rec.oid::regclass::text | ||
RAISE WARNING 'recompressing chunk "%" failed when compression policy is executed', chunk_rec.oid::regclass::text | ||
USING DETAIL = format('Message: (%s), Detail: (%s).', _message, _detail), | ||
ERRCODE = sqlstate; | ||
END; | ||
|
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