I experienced some odd behavior after running TRUNCATE TABLE on a table that has a hyper table. I didn't have time to investigate at the time and re-created the table.
Hi, thanks for reporting this. When I truncate an hypertable, the existing chunks are not removed although they are empty. Is this the behavior that you saw and found odd ? I think removing the empty chunks on truncate would be a better behavior and will look into fixing it.
Hi @abrkn thanks for this feedback.
We'll look into more expected behavior for TRUNCATE in the future (i.e., delete the existing chunks), but for now, you can turn to our drop_chunks interface for the expected behavior:
SELECT drop_chunks(NOW() + interval ‘1 year’, tablename)
drop_chunks deletes all chunks if all of their data are beyond the cut-off point (based on chunk constraints). Here I'm just pushing out the leading edge by 1 year to just mean something "way in the future". Not the prettiest interface, but can give you the functionality you want for now.
Also, my testing confirms the same as @olofr : after TRUNCATE, all the data is deleted, just that the existing chunks remain (but now are empty).
Just a head's up: PR currently being reviewed: https://github.com/timescale/timescaledb/pull/131
Fixed as part of 0.3.0 release (by @olofr).
Hi @abrkn thanks for this feedback.
We'll look into more expected behavior for TRUNCATE in the future (i.e., delete the existing chunks), but for now, you can turn to our drop_chunks interface for the expected behavior:
SELECT drop_chunks(NOW() + interval ‘1 year’, tablename)drop_chunks deletes all chunks if all of their data are beyond the cut-off point (based on chunk constraints). Here I'm just pushing out the leading edge by 1 year to just mean something "way in the future". Not the prettiest interface, but can give you the functionality you want for now.
This deletes all chunks ... I guess the drop_chunks() function has evolved since you wrote this, and the behaviour has changed
Just an update truncate table cascade fails with default config it is asking to increase the shared memory limit..
Most helpful comment
Just a head's up: PR currently being reviewed: https://github.com/timescale/timescaledb/pull/131