-
Notifications
You must be signed in to change notification settings - Fork 939
Update compression stats when merging chunks #7909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Update compression stats when merging chunks #7909
Conversation
eb21756
to
f33b3c9
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7909 +/- ##
==========================================
+ Coverage 80.06% 81.88% +1.81%
==========================================
Files 190 249 +59
Lines 37181 46177 +8996
Branches 9450 11575 +2125
==========================================
+ Hits 29770 37813 +8043
- Misses 2997 3801 +804
- Partials 4414 4563 +149 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f33b3c9
to
13a19e7
Compare
Merge compression chunk size stats when merging chunks. The merged chunk's stats is simply the sum of the stats of all compressed chunks that are merged. This ensures that the aggregate stats do not change due to the merge. Still, the stats might not accurately represent the merged chunk since merging both compressed and non-compressed chunks will leave some data uncompressed and this data won't be reflected in the stats of the merged chunk.
13a19e7
to
1c375af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patch looks fine. It's a little hard to follow and verify the stats, so you might want to have tests that actually save away the data before the merge and then do the computations in SQL to verify that they are what is expected after the merge.
TupleInfo *ti = ts_scan_iterator_tuple_info(&iterator); | ||
bool should_free; | ||
HeapTuple tuple = ts_scanner_fetch_heap_tuple(ti, false, &should_free); | ||
memcpy(form, GETSTRUCT(tuple), sizeof(FormData_compression_chunk_size)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Will avoid problems if the type of form
changes.
memcpy(form, GETSTRUCT(tuple), sizeof(FormData_compression_chunk_size)); | |
memcpy(form, GETSTRUCT(tuple), sizeof(*form)); |
select * from _timescaledb_catalog.compression_chunk_size order by chunk_id; | ||
chunk_id | compressed_chunk_id | uncompressed_heap_size | uncompressed_toast_size | uncompressed_index_size | compressed_heap_size | compressed_toast_size | compressed_index_size | numrows_pre_compression | numrows_post_compression | numrows_frozen_immediately | ||
----------+---------------------+------------------------+-------------------------+-------------------------+----------------------+-----------------------+-----------------------+-------------------------+--------------------------+---------------------------- | ||
1 | 6 | 8192 | 0 | 32768 | 16384 | 8192 | 16384 | 1 | 1 | 1 | ||
3 | 7 | 8192 | 0 | 32768 | 16384 | 8192 | 16384 | 1 | 1 | 1 | ||
(2 rows) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use \x on
for these.
Merge compression chunk size stats when merging chunks. The merged chunk's stats is simply the sum of the stats of all compressed chunks that are merged. This ensures that the aggregate stats do not change due to the merge. Still, the stats might not accurately represent the merged chunk since merging both compressed and non-compressed chunks will leave some data uncompressed and this data won't be reflected in the stats of the merged chunk.