# Tidb Server Cache
+ TiDB Server cache configuration
  + SQL results
  + thread cache
  + metadata, statistics
+ TiDB Server cache management
  + tidb_mem_quota_query
  + oom-action
------------------------------------------------------------
By default, the TiDB Server cache uses the entire memory of the server. First of all, let's look at the key aspects of memory usage:

- TiDB Server cache configuration
  - Complex SQL queries, for example, using hash joins, too many subquery in the execution plan, and these calculations cannot be done entirely by the operators pushed down to the TiKV node. The data must be sorted in the cache of the TIDB Server before it can be return to the user. Update&Delete involves an excessive amount of data and can also take up a lot of cache.
  - Threads are cached using TiDB Server's cache. If there are too many active threads, it will also cause heavy use of the cache.
  - The table's metadata, information schema, user authentication authorization data and statistics need to be cached. So what are the parameters to better manage the cache?

- TiDB Server cache management
  - The tidb-mem-quota-query parameter can control the default cache usage for each query. In addition, there are similar parameters, we can refer to the documentation: TiDB Memory Control Document
  - If “cancel” is used for the configuration item of oom-action, then when the memory usage of an SQL exceeds a certain threshold, TiDB will immediately interrupt the execution of the SQL and return an error to the client. The error message will detail each physical execution that takes up more memory during the execution of this SQL The memory usage of the child.
