Skip to content
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

[Feature]: Drop a chunk by name #7216

Open
lmandras-iura opened this issue Aug 27, 2024 · 4 comments
Open

[Feature]: Drop a chunk by name #7216

lmandras-iura opened this issue Aug 27, 2024 · 4 comments
Labels
feature-request Feature proposal

Comments

@lmandras-iura
Copy link

lmandras-iura commented Aug 27, 2024

What problem does the new feature solve?

I need to deleted data based on the segment_by column (eg: device ID). Given i have a device ID, delete all chunks (including compressed) that belong to that device ID.

The point being to not use a regular DELETE sql statement that will have to decompress those chunks first and then run the delete. For GDPR purposes if i want to erase all data related to a device ID i want to do it as fast and simple as possible.

What does the feature do?

Drop/delete a chunk (including compressed) based on the chunk name (there is a query to get all chunks for a certain segment by value)

Implementation challenges

No response

@lmandras-iura lmandras-iura added the feature-request Feature proposal label Aug 27, 2024
@svenklemm
Copy link
Member

With 2.17 you will be able to delete along segmentby columns without decompression.
This was added in #6882

@svenklemm svenklemm modified the milestone: TimescaleDB 2.17.0 Sep 4, 2024
@svenklemm
Copy link
Member

As a workaround you can run manual DROP TABLE on those chunks. You can get a list of chunks matching arbitrary constraints like so:

                tableoid                
----------------------------------------
 _timescaledb_internal._hyper_1_2_chunk
(1 row)

@brasic
Copy link

brasic commented Sep 19, 2024

It's not documented as far as I can see but _timescaledb_functions.drop_chunk() works for my use case. It takes a schema-qualified chunk name like

SELECT _timescaledb_functions.drop_chunk('_timescaledb_internal _hyper_3_230_chunk')

@svenklemm
Copy link
Member

You can also do DROP TABLE _timescaledb_internal _hyper_3_230_chunk;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Feature proposal
Projects
None yet
Development

No branches or pull requests

3 participants