# TiDB Server Cache

+ TiDB server cache
  + SQL results
  + Thread memory
  + Metadata, statistics
+ TiDB server cache management system variables
  + **`tidb_mem_quota_query`** (default value: 1 GB)
  + **`tidb_mem_oom_action`** (default value: 'CANCEL')

------------------------------------------------------------
TiDB server cache holds:
- SQL working area: Large complex SQL queries need to store temporary data in TiDB server cache before it can be return to the user. `UPDATE` and `DELETE` operations involve a large amount of data also consumes TiDB server cache memory.
- Memory spaces for threads.
- Tables metadata, information schema, user authentication and authorization data, and statistics.

TiDB server cache management
- System variable `tidb-mem-quota-query` is used to set the threshold value of memory quota for a query.
- System variable `tidb_mem_oom_action` specifies what operation TiDB performs when a single SQL statement exceeds the memory quota specified by `tidb_mem_quota_query` and cannot be spilled over to disk. The valid values are `CANCEL` and `LOG`.