Page 2 of 2

Re: Managing Disk space by deleting the older records when the disk is 60% full

Posted: Fri Aug 11, 2017 11:38 pm
by sKwa
Hi!
rishireddy.bokka wrote:
Fri Aug 11, 2017 9:23 pm
Thanks for the reply.
For nothing, you are welcome.

rishireddy.bokka wrote:
Fri Aug 11, 2017 9:23 pm
Please let me know if you need more information.
It's enough.

Ok, lets say out table name is MyTable and table is partitioned by column eventTime(just for example):

dbadmin=> select eventTime from MyTable order by eventTime desc;
         eventTime          
----------------------------
 2018-01-01 00:56:12.734092    // year 2018, newest timestamp
 ...
 2017-08-12 00:58:53.244886
 2017-08-11 00:56:12.734092
 2017-08-10 00:56:12.734092
 2017-08-09 00:56:12.734092    // year 2017, oldest timestamp
(366 rows)

so an oldest partition is:

dbadmin=> select to_char(min(eventTime), 'MMDD')::INT from MyTable;
 to_char 
---------
     809
(1 row)

P.S.
Assumption: data <= 1 year.

P. P.S.
Say me if you need a help to write a Bash or Python script.

Re: Managing Disk space by deleting the older records when the disk is 60% full

Posted: Mon Aug 14, 2017 9:51 pm
by rishireddy.bokka
Thanks alot for the help :)
This works perfectly :)