Just for the sake of logging things done, this is how pruning the PROD db was done - it is conceptually the same as what was done for STG, so I'm not adding the comments.
$ pg_dump -Fc resultsdb > resultsdb.dump $ createdb -T template0 resultsdb_archive $ pg_restore -d resultsdb_archive resultsdb.dump $ psql resultsdb_archive =# select id, job_id from result where submit_time<'2017-01-10' order by submit_time desc limit 1; id | job_id ----------+-------- 11604818 | 387701
=# select id, job_id from result where job_id > 387701 order by id limit 1; id | job_id ----------+-------- 11604819 | 387702
=# delete from result_data where result_id >= 11604819; =# delete from result where id >= 11604819; =# delete from job where id >= 387702;
$ psql resultsdb
=# delete from result_data where result_id < 11604819; =# delete from result where id < 11604819; =# delete from job where id < 387702;