The role of the cockroach-temp directory

We found a strange problem in the recent use, the client only uses the select statement to operate, but cockroach-temp takes up a lot of space, adding a few sst files per minute, what is stored in this directory, who can tell me?

Hey @dadadani119

The cockroach-temp directory is the directory where some temporary data is stored for any ongoing SQL queries. This is explained in the documentation under the --max-disk-temp-storage flag of the cockroach start command, found here. Please take a look through, and let me know if you have any other questions.

Cheers,
Ricardo

Thank you very much.

we also found the reason, because the order by sql is not used to index, resulting in a lot of sorted data overflow to disk space.

I carefully read the documentation, the default should be 32Gb, because we did not set max-disk-temp-storage, but at the time each node’s cockroach-temp takes up 1T of disk space.

When I set max-disk-temp-storage to 500Gb, the sst file generated by sql execution caused the data overflow has reached the upper limit of 500Gb, will cockroachdb be automatically cleaned up?

Hey @dadadani119

The cockroach-temp directory should be cleaned up after some time passes. Once the queries are completed, the data that was leveraged is tombstoned, and asynchronously removed.

Let me know if there are any other questions.

Cheers,
Ricardo