'Alter distkey for a table with 22 Billions rows never ends

I have a table with 22560627453 rows, with Even diststyle. The sortkey is date

I'm trying to run

ALTER TABLE movements 
    ALTER DISTSTYLE KEY DISTKEY id;

but this never ends. In fact, the cluster is at 75% of disk usage 4,5 TB/ 6TB and when running this alter the disk usage reaches 100% and doesn't end.

I tried creating a new table with the correct distkey and sortkey and then insert from the old one to the new one, but happens the same it reaches 100% of disk usage.

The total table size is 768327 (blocks of 1mb) so its 770 GB, then I don't understand why it reaches 100%. Because despite copying the table it should be around 700 gb free.

All table statistics have been achieved using:

select *
from svv_table_info
where "table" = 'movements';

enter image description here

How can I alter the distkey without reaching 100%. Is there a trick, or a tip to do it faster?

Old developers didn't care about distkeys and big part of the is using EVEN...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source