Check SQL OOM

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: check sql oom

| username: TiDBer_u9sO1XTU

[TiDB Usage Environment] Production Environment / Testing / Poc
[TiDB Version]
[Reproduction Path] What operations were performed that led to the issue
[Encountered Issue: Problem Phenomenon and Impact] How to predict in advance that a query’s SQL will cause OOM
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachment: Screenshot/Logs/Monitoring]

| username: 像风一样的男子 | Original post link

It is not possible to predict the memory usage of SQL in advance. You can set a memory usage limit for a single session using tidb_mem_quota_query.

| username: TiDBer_u9sO1XTU | Original post link

If this value is exceeded, will the query process be automatically killed, thus preventing the system from running out of memory (OOM)?

| username: caiyfc | Original post link

It is not possible to predict how much memory a specific SQL will use.
First, you can set the tidb_mem_quota_query to a smaller value to reduce the likelihood of the TiDB instance running out of memory (OOM).
Then, for SQL-level OOM adjustments, you can optimize the SQL, allow a specific SQL to use more memory, or use disk spilling to solve the OOM issue.

| username: zhanggame1 | Original post link

Although it is not possible to judge in advance, it is possible to make a rough judgment based on the amount of data returned or changed by TiDB, such as updating a large amount of data or joining a large amount of data.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.