Does CockroachDB clean up on tables utilized storage space?

Hey together,

I have encountered a fairly strange behavior and am not sure if it is intended or a bug. What I am doing is quite simple. I do a “big”, about 1 MiB each, bulk UPSERT on one table with a completely identical dataset. Upsert acts as expected and does update all the columns appropriately and the final table also just contains that final data. The table however grows, and grows and grows. It is now 1GiB big, although the data it contains is just as small as 1 MiB.

The question is, does CockroachDB cleans this up at a later time, or is this just a bug?

Thanks in advance

1 Like

crdb, by default, keeps 24h worth of historical data. After that period expires, deleted data is garbage collected. This historical data allows us to do “time travel queries” and backups, but it costs space. You can change the “time to leave” setting on a per-table basis by editing the gc: ttlseconds:` setting in the zone config.

1 Like

Ok, now this makes sense. Thanks for the fast response :slight_smile:

Are there any docs how to access this historical data? Could be quite useful though.

@wzrdtales, check out this SELECT example.

1 Like

Perfect, thank you :smile: