# [known issues] Prepared 的 analyze table 语句未达到内存限制阈值确被 cancel 掉

## Key Words

prepared analyze table, tidb_mem_quota_query, tidb_mem_quota_analyze, v6.5

## Description

v6.5 以上版本  
`tidb_mem_quota_analyze = 10G`  
`tidb_mem_quota_query = 1G`  
使用 prepared 的 analyze 语句，内存使用未达到 tidb_mem_quota_analyze 限定的 10G，却被异常 cancel 掉。  

```
MySQL > prepare stmt from 'analyze table t1';
MySQL > execute stmt;
ERROR 1105 (HY000): Out of memory quota![conn_id=xxxxxxx]%!(EXTRA *errors.fundamental=analyze panic due to memory quota exceeds, please try with smaller samplerate(refer to 11000s/count))
```

## Root Cause

v6.5 以后版本，prepare 中的 analyze table 语句，内存未受 tidb_mem_quota_analyze 参数限制，还是由 tidb_mem_quota_query 限制。  
GitHub issue: [https://github.com/pingcap/tidb/issues/44320](https://github.com/pingcap/tidb/issues/44320)

## Diagnostic Steps

检查 tidb_mem_quota_query 和 tidb_mem_quota_analyze 参数设置

## Resolution

修复 PR: [https://github.com/pingcap/tidb/pull/44367](https://github.com/pingcap/tidb/pull/44367)

## Workaround

直接执行 analyze ，不用 prepare

## Affects

v6.5.0~v6.5.2
