Paul Lambert <paul.lambert@autoledgers.com.au> writes:
> Is there any point to vacuuming a table if it has been bulk-populated by
> data after a truncate?
> I.e. If I do this:
> TRUNCATE TABLE vehicles;
> INSERT INTO vehicles (SELECT DISTINCT ON (dealer_id,vehicle_address) *
> FROM vehicles_temp_load WHERE (dealer_id,vehicle_address) is not null);
> Is there any point in vacuuming?
The only thing a vacuum would do for you there is set the commit hint
bits on the newly-inserted rows. Which might be worth doing if you want
to get the table into a totally "clean" state, but it's probably a bit
excessive. SELECTs on the table will set the hint bits anyway as
they visit not-yet-hinted rows, so it's really a matter of do you want
to pay that overhead all at once or spread-out.
What you *do* want to do in this situation is an ANALYZE.
regards, tom lane