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

Drop chunks of specific a space partition #545

Closed
mbande opened this issue May 22, 2018 · 7 comments
Closed

Drop chunks of specific a space partition #545

mbande opened this issue May 22, 2018 · 7 comments
Labels
core feature-request Feature proposal

Comments

@mbande
Copy link

mbande commented May 22, 2018

is it possible to drop chunks if a specific space partition, e.g. to remove chunks belonging to "partition id 1 older that 1 days"

@mbande mbande changed the title Drop chunks of specific space partition Drop chunks of specific a space partition May 22, 2018
@LeeHampton
Copy link
Contributor

Our drop_chunks()command currently only supports dropping chunks within a specified time interval. You'll likely need to take a look at your chunk metadata to determine which chunks need to be deleted, then just drop them.

@RobAtticus
Copy link
Member

Just a word of warning, be careful when doing this. We use hash partitioning for space dimensions, so it is usually not the case that each partition corresponds 1-to-1 with a value in the dimension. For example, if you have 1000 device ids and only 10 partitions, on average you'll have 100 different device ids per partition, so by dropping a partition you may be deleting more information than you intend.

@andriyfomenko
Copy link

andriyfomenko commented Sep 11, 2019

Given that similar functionality is getting discussed under issue #563 since 2018 with no movements, it looks like "manual chunk drop" may be a stop-gap measure, but it raises much bigger question:

Is it SAFE to tinker with chunks?

In our use-case, we are totally in control of our space partitioning, so we can clearly see which chunks are to be dropped, but would it create some kind of metadata out-of-sync condition for TimeScale ?

@svenklemm
Copy link
Member

svenklemm commented Jul 23, 2022

You can run DROP TABLE <chunk>; on an individual chunk. You can identify the chunk like so:

SELECT tableoid::regclass FROM <hypertable> WHERE <constraints> GROUP BY tableoid;

@muntdan
Copy link

muntdan commented Aug 12, 2022

You can run DROP TABLE <chunk>; on an individual chunk. You can identify the chunk like so:

SELECT tableoid::regclass FROM <hypertable> GROUP BY tableoid WHERE <constraints>;

Where is actually before Group By.

Or you can write directly:
SELECT tableoid::regclass as chunk, datetime_col__cast_as_interval, dimension_location_column FROM <hypertable> GROUP BY tableoid, datetime_col__cast_as_interval,dimension_location_column;
DROP TABLE <chunk>;

@Arcturuss
Copy link

shouldn't this issue be reopened? function drop_chunks still don't accept space partition as parameter.

@yazeed
Copy link

yazeed commented Jun 27, 2023

shouldn't this issue be reopened? function drop_chunks still don't accept space partition as parameter.

Agree, this feature alongside other space partition features like #563 should be kept open if the space partitioning implementation is planned to be expanded upon in Timescale in the future.

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

No branches or pull requests