TiDB Slow Log Memory Usage

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

Original topic: tidb 慢日志 内存使用

| username: 等一分钟

Consult about memory usage information for slow SQL.

| username: 等一分钟 | Original post link

| username: 等一分钟 | Original post link

Is the maximum memory here the memory used by the instance?

| username: cheng | Original post link

The page states that it is the memory space occupied by the current SQL query.

| username: 等一分钟 | Original post link

Wrote the maximum memory, a bit confused.

| username: h5n1 | Original post link

Yesterday this SQL might have returned 1000 rows of data, but this year it might return 3000 rows of data.

| username: 等一分钟 | Original post link

The SQL executed yesterday and the SQL executed today are not shown as the same in the slow log.

| username: 等一分钟 | Original post link

I am looking at each one accurately. The memory usage should ideally just write the memory occupied by SQL execution, which is easier to understand.

| username: h5n1 | Original post link

Check the memory recorded for this SQL in tidb.log or cluster_slow_query.

| username: 等一分钟 | Original post link

Well, I just want to know if this maximum memory is the actual memory used.

| username: h5n1 | Original post link

The largest memory ever used.

| username: 等一分钟 | Original post link

Once? Wasn’t this SQL used? A single SQL should only be displayed once in the dashboard, right?

| username: h5n1 | Original post link

The maximum memory used by this SQL.

| username: 箱子NvN | Original post link

Memory usage resembles a wavy line, reflecting the peak usage at its highest point.

| username: 等一分钟 | Original post link

During the execution of an SQL statement, multiple nodes will use memory. Does this show the maximum memory of a single node, or the total memory used by all nodes?

| username: Min_Chen | Original post link

Hello, the maximum memory here refers to the memory of the operator that uses the most memory among all operators, corresponding to the memory field in the execution plan above.

| username: MyronWang | Original post link

Hello, according to your explanation, how should the total memory occupied by this SQL be calculated when it is executed? Should we sum up the memory usage of all operators? After all, a SQL statement usually uses multiple operators.

| username: Min_Chen | Original post link

This cannot be calculated precisely, only an approximate value can be estimated. You can calculate it by summing up the memory fields, but it is not possible to trace the memory usage of some types of operators.

| username: MyronWang | Original post link

Sure, thank you for the explanation.
By identifying the operator that uses the most memory, we can further analyze and optimize the SQL.

| username: system | Original post link

This topic will be automatically closed 60 days after the last reply. No new replies are allowed.