Will Vacuum delete previous folders of data if we z-ordered by as_of_date each day?

Kash
Contributor III

Hi there,

I've had horrible experiences Vacuuming tables in the past and losing tons of data so I wanted to confirm a few things about Vacuuming and Z-Order.

Background:

Each day we run an ETL job that appends data in a table and stores the data in S3 by date (as_of_date).

When we Optimize Z-ORDER we do so with a WHERE as_of_date=current_date. This optimizes and z-orders the data for the folder we've just written and tens to double the size of the folder.

Questions:

1. When should we Vacuums? Each day?

2 - If we vacuum will it delete previous as_of_date folders in S3 since the current version is today's as_of_date?

3 - Should we not optimize with the where clause?

Thanks in advance for your help. It doesn't look like anyone has asked this question.