---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ytsaurus.tech/docs/en/yql/faq/temp.md
  - https://ytsaurus.tech/docs/ru/yql/faq/temp.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ytsaurus.tech/docs/en/llms.txt

# Temporary data

## Directory for temporary data

Using the `yt.TmpFolder` pragma, the user can set a directory for hosting temporary tables and files. This might be needed in the following cases:
* There is no access to the `//tmp` directory of the YTsaurus cluster.
* The query is processing tables with sensitive data. By default, temporary tables and files are saved to //tmp where any cluster user can access them. To avoid disclosure of sensitive information, protect the temporary file directory used in your queries by an ACL.

## Control of TmpFolder directory growth

When you use the `yt.TmpFolder` pragma in your query, the specified directory begins to accumulate data gradually. The following subdirectories are created in it:

* query_cache: [Query cache](https://ytsaurus.tech/docs/en/yql/syntax/pragma.md#querycache).
* tmp: Temporary tables that exist only while the query is running.
* new_cache: YTsaurus API file cache:
    * YQL executables.
    * Custom and system UDFs.
    * Files attached to the query.
    * Tables used in MapJoin (if transmitted not in a YTsaurus-native manner).

The query_cache subdirectory and its contents' time-to-live are managed by the [yt.QueryCacheMode](https://ytsaurus.tech/docs/en/yql/syntax/pragma.md#querycache) and [yt.QueryCacheTtl](https://ytsaurus.tech/docs/en/yql/syntax/pragma.md#ytquerycachettl) pragmas. For `yt.QueryCacheMode="disable"`, the query cache is fully disabled and this subdirectory isn't created or used. The `yt.QueryCacheTtl` pragma enables you to limit the tables' TTL in the query cache.

Once the query is completed, the query's temporary tables are cleared automatically from the tmp subdirectory. Exceptions are the queries with the `yt.ReleaseTempData="never"` and tables delivered in query results as "Full result". You can manage time-to-live for these tables using the [yt.TempTablesTtl](https://ytsaurus.tech/docs/en/yql/syntax/pragma.md#yttemptablesttl) pragma. You can override the path to temporary tables using the [yt.TablesTmpFolder](https://ytsaurus.tech/docs/en/yql/syntax/pragma.md#yttablestmpfolder) pragma.

For objects inside new_cache, time-to-live is managed by the [yt.FileCacheTtl](https://ytsaurus.tech/docs/en/yql/syntax/pragma.md#ytfilecachettl) pragma. To exclude executable YQL and UDF files from this directory, use the [yt.BinaryTmpFolder](https://ytsaurus.tech/docs/en/yql/syntax/pragma.md#ytbinarytmpfolder) pragma to set up a separate directory and TTL for them (see [yt.BinaryExpirationInterval](https://ytsaurus.tech/docs/en/yql/syntax/pragma.md#ytbinaryexpirationinterval)). You can also move your tables used in MapJoin to a separate directory by the [yt.TableContentTmpFolder](https://ytsaurus.tech/docs/en/yql/syntax/pragma.md#yt.tablecontenttmpfolder) pragma. Keep in mind, however, that such tables can include sensitive data.

