相关文章推荐
刚毅的单杠
·
python爬取网易云音乐排行榜实例代码_p ...
·
1 年前
·
淡定的跑步鞋
·
windows10 - Microsoft ...
·
1 年前
·
神勇威武的楼梯
·
python 过滤特殊字符 (emoji) ...
·
1 年前
·
Code
›
系统变量 | PingCAP 文档中心
tidb
作用域
系统变量
布尔型
https://docs.pingcap.com/zh/tidb/stable/system-variables/
任性的墨镜
1 年前
</noscript><div id="___gatsby"><div style="outline:none" tabindex="-1" id="gatsby-focus-wrapper"><style data-emotion="css 6ko3zs">.css-6ko3zs{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;width:100%;box-sizing:border-box;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;position:fixed;z-index:1100;top:0;left:auto;right:0;background-color:#1976d2;color:#fff;background-color:#f9f9f9;border-bottom:1px solid #e5e5e5;box-shadow:0px 1px 6px rgba(0, 0, 0, 0.08);height:5rem;}@media print{.css-6ko3zs{}}</style><style data-emotion="css foju0o">.css-foju0o{background-color:#fff;color:rgba(0, 0, 0, 0.87);-webkit-transition:box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;box-shadow:0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;width:100%;box-sizing:border-box;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;position:fixed;z-index:1100;top:0;left:auto;right:0;background-color:#1976d2;color:#fff;background-color:#f9f9f9;border-bottom:1px solid #e5e5e5;box-shadow:0px 1px 6px rgba(0, 0, 0, 0.08);height:5rem;}@media print{.css-foju0o{}}</style><header class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation4 MuiAppBar-root MuiAppBar-colorPrimary MuiAppBar-positionFixed mui-fixed css-foju0o"><style data-emotion="css 1xw2ef0">.css-1xw2ef0{position:relative;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding-left:16px;padding-right:16px;min-height:56px;height:100%;}@media (min-width:600px){.css-1xw2ef0{padding-left:24px;padding-right:24px;}}@media (min-width:0px){@media (orientation: landscape){.css-1xw2ef0{min-height:48px;}}}@media (min-width:600px){.css-1xw2ef0{min-height:64px;}}@media (min-width:900px){.css-1xw2ef0{padding-left:2rem;padding-right:2rem;}}</style><div class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-1xw2ef0"><style data-emotion="css 16bbyrv">.css-16bbyrv{text-align:center;-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto;font-size:1.5rem;padding:8px;border-radius:50%;overflow:visible;color:rgba(0, 0, 0, 0.54);-webkit-transition:background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;}.css-16bbyrv:hover{background-color:rgba(0, 0, 0, 0.04);}@media (hover: none){.css-16bbyrv:hover{background-color:transparent;}}.css-16bbyrv.Mui-disabled{background-color:transparent;color:rgba(0, 0, 0, 0.26);}@media (min-width:1200px){.css-16bbyrv{;}}</style><style data-emotion="css iuftj9">.css-iuftj9{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;position:relative;box-sizing:border-box;-webkit-tap-highlight-color:transparent;background-color:transparent;outline:0;border:0;margin:0;border-radius:0;padding:0;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;-moz-appearance:none;-webkit-appearance:none;-webkit-text-decoration:none;text-decoration:none;color:inherit;text-align:center;-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto;font-size:1.5rem;padding:8px;border-radius:50%;overflow:visible;color:rgba(0, 0, 0, 0.54);-webkit-transition:background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;}.css-iuftj9::-moz-focus-inner{border-style:none;}.css-iuftj9.Mui-disabled{pointer-events:none;cursor:default;}@media print{.css-iuftj9{-webkit-print-color-adjust:exact;color-adjust:exact;}}.css-iuftj9:hover{background-color:rgba(0, 0, 0, 0.04);}@media (hover: none){.css-iuftj9:hover{background-color:transparent;}}.css-iuftj9.Mui-disabled{background-color:transparent;color:rgba(0, 0, 0, 0.26);}@media (min-width:1200px){.css-iuftj9{;}}</style><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-iuftj9" tabindex="0" type="button" aria-label="menu"><style data-emotion="css vubbuv">.css-vubbuv{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:1em;height:1em;display:inline-block;fill:currentColor;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;font-size:1.5rem;}</style><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="MenuIcon"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg></button><style data-emotion="css a3xyjy">.css-a3xyjy{z-index:1200;}</style><style data-emotion="css 13tqxrv">@media (min-width:0px){.css-13tqxrv{;}}@media (min-width:900px){.css-13tqxrv{display:block;}}</style><div class="MuiBox-root css-13tqxrv"><style data-emotion="css tx8jsd">.css-tx8jsd{margin:0;font-size:1rem;line-height:1.5rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:#666666;}</style><a class="MuiTypography-root MuiTypography-body1 css-tx8jsd" target="_blank" href="https://cn.pingcap.com/" style="text-decoration:none"><style data-emotion="css uz5bjn">.css-uz5bjn{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:1em;height:1em;display:inline-block;fill:currentColor;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;font-size:1.5rem;width:6.75rem;}@media (min-width:0px){.css-uz5bjn{;}}@media (min-width:600px){.css-uz5bjn{display:block;}}</style><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-uz5bjn" focusable="false" aria-hidden="true" viewbox="0 0 769.89 203.08"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path fill="#082265" d="M100.11,47.34l-88-25.1A9.5,9.5,0,0,0,0,31.38v162.2a9.51,9.51,0,0,0,9.48,9.5,9.35,9.35,0,0,0,2.22-.26l88-21h0a9.48,9.48,0,0,0,7.3-9.25V56.48A9.54,9.54,0,0,0,100.11,47.34Z"/><path fill="#00aeef" d="M160.05,41.57a9.55,9.55,0,0,0-6.88-9.11L41.16.37A9.5,9.5,0,0,0,29,9.51V132.59a9.47,9.47,0,0,0,11.72,9.23l112.14-27a9.47,9.47,0,0,0,7.28-9.26Z"/><path fill="#303eab" d="M100.11,47.34,29,27.07V132.59a9.47,9.47,0,0,0,11.72,9.23L107,125.88V56.48A9.54,9.54,0,0,0,100.11,47.34Z"/><path fill="#082265" d="M576.1,126.26h0l-.23.37a40.12,40.12,0,0,1-13.72,13.09,36.62,36.62,0,0,1-18.78,5.43c-10.94,0-20.51-4.36-28.42-13a43.82,43.82,0,0,1-11.37-31,43.09,43.09,0,0,1,11.74-29.38c7.62-8.17,16.81-12.31,27.3-12.31,14.37-.13,25.2,5.8,33.13,18.13L576,78h.22l9.33-5.77a51.65,51.65,0,0,0-15.42-16.39,48.17,48.17,0,0,0-26.73-8.09A46.85,46.85,0,0,0,507.66,63c-9.94,10.23-15,23.28-15,38.77,0,15,5,28.08,14.84,38.9,9.81,10.64,21.69,16,35.33,16h.51c17.92-.37,32.69-9.06,42.11-24.6Z"/><polygon fill="#082265" points="645.84 49.09 633.16 49.09 586.01 154.63 601.05 154.63 615.63 119.55 615.65 119.55 620.8 108.59 620.78 108.59 639.76 64.05 658.36 108.59 631.66 108.59 626.79 119.55 662.69 119.55 677.4 154.63 690.66 154.63 645.84 49.09"/><path fill="#082265" d="M759.63,58.75c-7-6.32-15.81-9.52-26.18-9.52H699.3v105.4h12.44V113.34h0V102.25h0V60.59H734a24.73,24.73,0,0,1,16.22,5.63,18.12,18.12,0,0,1,7.37,14c.39,6.62-1.77,11.88-6.61,16.07a23.43,23.43,0,0,1-16.31,6H721.77v11.09h14.91a33.34,33.34,0,0,0,23.23-8.85,29,29,0,0,0,10-21.91C770,72.89,766.58,64.87,759.63,58.75Z"/><rect fill="#082265" x="296.25" y="51.17" width="12.44" height="12.44"/><rect fill="#082265" x="296.25" y="79.04" width="12.44" height="75.74"/><path fill="#082265" d="M483.63,147.21V114.69a38.6,38.6,0,0,0-12.25-29.2c-8.22-8.22-18.1-12.27-29.35-12a39.17,39.17,0,0,0-27.82,12.54,40.08,40.08,0,0,0-11.29,28.49,41,41,0,0,0,12.24,29.59c8.19,8.18,18,12.12,29.22,11.71a38.78,38.78,0,0,0,27.48-12.33v5.17m0,0c0,6.88-2.73,12.89-8.11,17.88a27.1,27.1,0,0,1-19,7.73,27.83,27.83,0,0,1-16.93-5.64,25.92,25.92,0,0,1-9-10.54l-9.52,5.5a36.63,36.63,0,0,0,9.94,12c6.6,5.25,14.75,8.13,24.23,8.54.59,0,1.18,0,1.77,0a40.89,40.89,0,0,0,26-9.25c8.17-6.52,12.32-14.86,12.32-24.8v-2.95m-12-31.74a29.23,29.23,0,0,1-8.41,20.22,25.68,25.68,0,0,1-19.5,8.38,27.3,27.3,0,0,1-20.2-8.39,28.22,28.22,0,0,1-8.66-20.34,28.66,28.66,0,0,1,7.88-20.61,27.21,27.21,0,0,1,19.53-9.45c.51,0,1,0,1.5,0,7.61,0,14,2.85,19.45,8.69A28.51,28.51,0,0,1,471.59,115.47Z"/><path fill="#082265" d="M274.1,58.75c-7-6.32-15.81-9.52-26.19-9.52H213.76v105.4h12.45V113.34h0V102.25h0V60.59h22.24a24.73,24.73,0,0,1,16.23,5.63,18.12,18.12,0,0,1,7.37,14c.39,6.62-1.77,11.88-6.61,16.07a23.43,23.43,0,0,1-16.31,6H236.24v11.09h14.91a33.34,33.34,0,0,0,23.23-8.85,29,29,0,0,0,10-21.91C284.5,72.89,281.05,64.87,274.1,58.75Z"/><path fill="#082265" d="M357.54,74.41c-9.92,0-18.3,3.43-24.94,10.2s-9.91,15.24-9.91,25.33v44.53h12V108.86a21.82,21.82,0,0,1,6.75-16.1A22.08,22.08,0,0,1,357.54,86a21.49,21.49,0,0,1,15.82,6.75,21.86,21.86,0,0,1,6.89,16.1v45.61h12V109.94c0-10.09-3.34-18.61-9.92-25.33A33.47,33.47,0,0,0,357.54,74.41Z"/></g></g></svg></a></div><style data-emotion="css 5qlh60">.css-5qlh60{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;padding-left:2rem;height:100%;}.css-5qlh60>:not(style)+:not(style){margin:0;margin-left:24px;}@media (min-width:0px){.css-5qlh60{;}}@media (min-width:900px){.css-5qlh60{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}</style><div class="css-5qlh60"><style data-emotion="css kiou0g">.css-kiou0g{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding-top:0.25rem;padding-bottom:0.25rem;}</style><div class="MuiBox-root css-kiou0g"><a style="text-decoration:none" hreflang="zh" href="/zh/"><style data-emotion="css 2jgwiy">.css-2jgwiy{margin:0;font-size:1rem;line-height:1.5rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:#666666;color:#282a36;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,"IBM Plex Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji";display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:4px;}</style><div class="MuiTypography-root MuiTypography-body1 css-2jgwiy">文档中心</div></a></div><div class="MuiBox-root css-kiou0g"><a style="text-decoration:none" hreflang="zh" href="/zh/tidb/stable"><div class="MuiTypography-root MuiTypography-body1 css-2jgwiy">TiDB</div></a></div><div class="MuiBox-root css-kiou0g"><a class="MuiTypography-root MuiTypography-body1 css-tx8jsd" target="_blank" href="https://asktug.com/" style="text-decoration:none"><div class="MuiTypography-root MuiTypography-body1 css-2jgwiy">社区</div></a></div><div class="MuiBox-root css-kiou0g"><a class="MuiTypography-root MuiTypography-body1 css-tx8jsd" target="_blank" href="https://cn.pingcap.com/contact/" style="text-decoration:none"><div class="MuiTypography-root MuiTypography-body1 css-2jgwiy">联系我们</div></a></div><div class="MuiBox-root css-kiou0g"><a class="MuiTypography-root MuiTypography-body1 css-tx8jsd" target="_blank" href="https://cn.pingcap.com/product/#SelectProduct" style="text-decoration:none"><div class="MuiTypography-root MuiTypography-body1 css-2jgwiy"><style data-emotion="css xnd31y">.css-xnd31y{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:1em;height:1em;display:inline-block;fill:currentColor;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;font-size:inherit;padding-top:0.5rem;}</style><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-xnd31y" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="DownloadIcon"><path d="M5 20h14v-2H5v2zM19 9h-4V3H9v6H5l7 7 7-7z"/></svg></div></a></div></div><style data-emotion="css 1vn3uc0">.css-1vn3uc0{color:#282a36;}@media (min-width:900px){.css-1vn3uc0{;}}</style><div class="MuiBox-root css-1vn3uc0"><style data-emotion="css btg76o">.css-btg76o{text-transform:none;font-family:-apple-system,"Poppins","Helvetica Neue",sans-serif,"Noto Sans","Fira Code","IBM Plex Sans","sans-serif";font-weight:500;font-size:0.875rem;line-height:1.75;min-width:64px;padding:6px 8px;border-radius:4px;-webkit-transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;color:inherit;border-color:currentColor;box-shadow:none;}.css-btg76o:hover{-webkit-text-decoration:none;text-decoration:none;background-color:rgba(0, 0, 0, 0.04);}@media (hover: none){.css-btg76o:hover{background-color:transparent;}}.css-btg76o.Mui-disabled{color:rgba(0, 0, 0, 0.26);}.css-btg76o:hover{box-shadow:none;}.css-btg76o.Mui-focusVisible{box-shadow:none;}.css-btg76o:active{box-shadow:none;}.css-btg76o.Mui-disabled{box-shadow:none;}</style><style data-emotion="css 1ei260h">.css-1ei260h{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;position:relative;box-sizing:border-box;-webkit-tap-highlight-color:transparent;background-color:transparent;outline:0;border:0;margin:0;border-radius:0;padding:0;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;-moz-appearance:none;-webkit-appearance:none;-webkit-text-decoration:none;text-decoration:none;color:inherit;text-transform:none;font-family:-apple-system,"Poppins","Helvetica Neue",sans-serif,"Noto Sans","Fira Code","IBM Plex Sans","sans-serif";font-weight:500;font-size:0.875rem;line-height:1.75;min-width:64px;padding:6px 8px;border-radius:4px;-webkit-transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;color:inherit;border-color:currentColor;box-shadow:none;}.css-1ei260h::-moz-focus-inner{border-style:none;}.css-1ei260h.Mui-disabled{pointer-events:none;cursor:default;}@media print{.css-1ei260h{-webkit-print-color-adjust:exact;color-adjust:exact;}}.css-1ei260h:hover{-webkit-text-decoration:none;text-decoration:none;background-color:rgba(0, 0, 0, 0.04);}@media (hover: none){.css-1ei260h:hover{background-color:transparent;}}.css-1ei260h.Mui-disabled{color:rgba(0, 0, 0, 0.26);}.css-1ei260h:hover{box-shadow:none;}.css-1ei260h.Mui-focusVisible{box-shadow:none;}.css-1ei260h:active{box-shadow:none;}.css-1ei260h.Mui-disabled{box-shadow:none;}</style><button class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textInherit MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorInherit MuiButton-disableElevation css-1ei260h" tabindex="0" type="button" id="header-nav-items" aria-haspopup="true"><style data-emotion="css 6xugel">.css-6xugel{display:inherit;margin-right:8px;margin-left:-4px;}.css-6xugel>*:nth-of-type(1){font-size:20px;}</style><span class="MuiButton-startIcon MuiButton-iconSizeMedium css-6xugel"><style data-emotion="css 1x9zct">.css-1x9zct{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:1em;height:1em;display:inline-block;fill:currentColor;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;font-size:1.5rem;width:6.75rem;height:1.5rem;}</style><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1x9zct" focusable="false" aria-hidden="true" viewbox="0 0 769.89 203.08"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path fill="#082265" d="M100.11,47.34l-88-25.1A9.5,9.5,0,0,0,0,31.38v162.2a9.51,9.51,0,0,0,9.48,9.5,9.35,9.35,0,0,0,2.22-.26l88-21h0a9.48,9.48,0,0,0,7.3-9.25V56.48A9.54,9.54,0,0,0,100.11,47.34Z"/><path fill="#00aeef" d="M160.05,41.57a9.55,9.55,0,0,0-6.88-9.11L41.16.37A9.5,9.5,0,0,0,29,9.51V132.59a9.47,9.47,0,0,0,11.72,9.23l112.14-27a9.47,9.47,0,0,0,7.28-9.26Z"/><path fill="#303eab" d="M100.11,47.34,29,27.07V132.59a9.47,9.47,0,0,0,11.72,9.23L107,125.88V56.48A9.54,9.54,0,0,0,100.11,47.34Z"/><path fill="#082265" d="M576.1,126.26h0l-.23.37a40.12,40.12,0,0,1-13.72,13.09,36.62,36.62,0,0,1-18.78,5.43c-10.94,0-20.51-4.36-28.42-13a43.82,43.82,0,0,1-11.37-31,43.09,43.09,0,0,1,11.74-29.38c7.62-8.17,16.81-12.31,27.3-12.31,14.37-.13,25.2,5.8,33.13,18.13L576,78h.22l9.33-5.77a51.65,51.65,0,0,0-15.42-16.39,48.17,48.17,0,0,0-26.73-8.09A46.85,46.85,0,0,0,507.66,63c-9.94,10.23-15,23.28-15,38.77,0,15,5,28.08,14.84,38.9,9.81,10.64,21.69,16,35.33,16h.51c17.92-.37,32.69-9.06,42.11-24.6Z"/><polygon fill="#082265" points="645.84 49.09 633.16 49.09 586.01 154.63 601.05 154.63 615.63 119.55 615.65 119.55 620.8 108.59 620.78 108.59 639.76 64.05 658.36 108.59 631.66 108.59 626.79 119.55 662.69 119.55 677.4 154.63 690.66 154.63 645.84 49.09"/><path fill="#082265" d="M759.63,58.75c-7-6.32-15.81-9.52-26.18-9.52H699.3v105.4h12.44V113.34h0V102.25h0V60.59H734a24.73,24.73,0,0,1,16.22,5.63,18.12,18.12,0,0,1,7.37,14c.39,6.62-1.77,11.88-6.61,16.07a23.43,23.43,0,0,1-16.31,6H721.77v11.09h14.91a33.34,33.34,0,0,0,23.23-8.85,29,29,0,0,0,10-21.91C770,72.89,766.58,64.87,759.63,58.75Z"/><rect fill="#082265" x="296.25" y="51.17" width="12.44" height="12.44"/><rect fill="#082265" x="296.25" y="79.04" width="12.44" height="75.74"/><path fill="#082265" d="M483.63,147.21V114.69a38.6,38.6,0,0,0-12.25-29.2c-8.22-8.22-18.1-12.27-29.35-12a39.17,39.17,0,0,0-27.82,12.54,40.08,40.08,0,0,0-11.29,28.49,41,41,0,0,0,12.24,29.59c8.19,8.18,18,12.12,29.22,11.71a38.78,38.78,0,0,0,27.48-12.33v5.17m0,0c0,6.88-2.73,12.89-8.11,17.88a27.1,27.1,0,0,1-19,7.73,27.83,27.83,0,0,1-16.93-5.64,25.92,25.92,0,0,1-9-10.54l-9.52,5.5a36.63,36.63,0,0,0,9.94,12c6.6,5.25,14.75,8.13,24.23,8.54.59,0,1.18,0,1.77,0a40.89,40.89,0,0,0,26-9.25c8.17-6.52,12.32-14.86,12.32-24.8v-2.95m-12-31.74a29.23,29.23,0,0,1-8.41,20.22,25.68,25.68,0,0,1-19.5,8.38,27.3,27.3,0,0,1-20.2-8.39,28.22,28.22,0,0,1-8.66-20.34,28.66,28.66,0,0,1,7.88-20.61,27.21,27.21,0,0,1,19.53-9.45c.51,0,1,0,1.5,0,7.61,0,14,2.85,19.45,8.69A28.51,28.51,0,0,1,471.59,115.47Z"/><path fill="#082265" d="M274.1,58.75c-7-6.32-15.81-9.52-26.19-9.52H213.76v105.4h12.45V113.34h0V102.25h0V60.59h22.24a24.73,24.73,0,0,1,16.23,5.63,18.12,18.12,0,0,1,7.37,14c.39,6.62-1.77,11.88-6.61,16.07a23.43,23.43,0,0,1-16.31,6H236.24v11.09h14.91a33.34,33.34,0,0,0,23.23-8.85,29,29,0,0,0,10-21.91C284.5,72.89,281.05,64.87,274.1,58.75Z"/><path fill="#082265" d="M357.54,74.41c-9.92,0-18.3,3.43-24.94,10.2s-9.91,15.24-9.91,25.33v44.53h12V108.86a21.82,21.82,0,0,1,6.75-16.1A22.08,22.08,0,0,1,357.54,86a21.49,21.49,0,0,1,15.82,6.75,21.86,21.86,0,0,1,6.89,16.1v45.61h12V109.94c0-10.09-3.34-18.61-9.92-25.33A33.47,33.47,0,0,0,357.54,74.41Z"/></g></g></svg></span><style data-emotion="css 1n4a93h">.css-1n4a93h{display:inherit;margin-right:-4px;margin-left:8px;}.css-1n4a93h>*:nth-of-type(1){font-size:20px;}</style><span class="MuiButton-endIcon MuiButton-iconSizeMedium css-1n4a93h"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="KeyboardArrowDownIcon"><path d="M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"/></svg></span></button></div><style data-emotion="css jnv64h">.css-jnv64h{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;margin-left:auto;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}@media (min-width:0px){.css-jnv64h>:not(style)+:not(style){margin:0;margin-left:8px;}}@media (min-width:1200px){.css-jnv64h>:not(style)+:not(style){margin:0;margin-left:24px;}}</style><div class="css-jnv64h"><style data-emotion="css 1qlh2t1">.css-1qlh2t1{color:#282a36;}</style><div class="MuiBox-root css-1qlh2t1"><style data-emotion="css 1mvsusm">.css-1mvsusm{text-align:center;-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto;font-size:1.5rem;padding:8px;border-radius:50%;overflow:visible;color:rgba(0, 0, 0, 0.54);-webkit-transition:background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;color:inherit;}.css-1mvsusm:hover{background-color:rgba(0, 0, 0, 0.04);}@media (hover: none){.css-1mvsusm:hover{background-color:transparent;}}.css-1mvsusm.Mui-disabled{background-color:transparent;color:rgba(0, 0, 0, 0.26);}@media (min-width:1200px){.css-1mvsusm{;}}</style><style data-emotion="css jwr93t">.css-jwr93t{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;position:relative;box-sizing:border-box;-webkit-tap-highlight-color:transparent;background-color:transparent;outline:0;border:0;margin:0;border-radius:0;padding:0;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;-moz-appearance:none;-webkit-appearance:none;-webkit-text-decoration:none;text-decoration:none;color:inherit;text-align:center;-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto;font-size:1.5rem;padding:8px;border-radius:50%;overflow:visible;color:rgba(0, 0, 0, 0.54);-webkit-transition:background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;color:inherit;}.css-jwr93t::-moz-focus-inner{border-style:none;}.css-jwr93t.Mui-disabled{pointer-events:none;cursor:default;}@media print{.css-jwr93t{-webkit-print-color-adjust:exact;color-adjust:exact;}}.css-jwr93t:hover{background-color:rgba(0, 0, 0, 0.04);}@media (hover: none){.css-jwr93t:hover{background-color:transparent;}}.css-jwr93t.Mui-disabled{background-color:transparent;color:rgba(0, 0, 0, 0.26);}@media (min-width:1200px){.css-jwr93t{;}}</style><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-jwr93t" tabindex="0" type="button"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="LanguageIcon"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"/></svg></button><style data-emotion="css t5gsfy">.css-t5gsfy{text-transform:none;font-family:-apple-system,"Poppins","Helvetica Neue",sans-serif,"Noto Sans","Fira Code","IBM Plex Sans","sans-serif";font-weight:500;font-size:0.875rem;line-height:1.75;min-width:64px;padding:6px 8px;border-radius:4px;-webkit-transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;color:inherit;border-color:currentColor;box-shadow:none;}.css-t5gsfy:hover{-webkit-text-decoration:none;text-decoration:none;background-color:rgba(0, 0, 0, 0.04);}@media (hover: none){.css-t5gsfy:hover{background-color:transparent;}}.css-t5gsfy.Mui-disabled{color:rgba(0, 0, 0, 0.26);}.css-t5gsfy:hover{box-shadow:none;}.css-t5gsfy.Mui-focusVisible{box-shadow:none;}.css-t5gsfy:active{box-shadow:none;}.css-t5gsfy.Mui-disabled{box-shadow:none;}@media (min-width:0px){.css-t5gsfy{;}}@media (min-width:1200px){.css-t5gsfy{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;}}</style><style data-emotion="css 1csz7wa">.css-1csz7wa{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;position:relative;box-sizing:border-box;-webkit-tap-highlight-color:transparent;background-color:transparent;outline:0;border:0;margin:0;border-radius:0;padding:0;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;-moz-appearance:none;-webkit-appearance:none;-webkit-text-decoration:none;text-decoration:none;color:inherit;text-transform:none;font-family:-apple-system,"Poppins","Helvetica Neue",sans-serif,"Noto Sans","Fira Code","IBM Plex Sans","sans-serif";font-weight:500;font-size:0.875rem;line-height:1.75;min-width:64px;padding:6px 8px;border-radius:4px;-webkit-transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;color:inherit;border-color:currentColor;box-shadow:none;}.css-1csz7wa::-moz-focus-inner{border-style:none;}.css-1csz7wa.Mui-disabled{pointer-events:none;cursor:default;}@media print{.css-1csz7wa{-webkit-print-color-adjust:exact;color-adjust:exact;}}.css-1csz7wa:hover{-webkit-text-decoration:none;text-decoration:none;background-color:rgba(0, 0, 0, 0.04);}@media (hover: none){.css-1csz7wa:hover{background-color:transparent;}}.css-1csz7wa.Mui-disabled{color:rgba(0, 0, 0, 0.26);}.css-1csz7wa:hover{box-shadow:none;}.css-1csz7wa.Mui-focusVisible{box-shadow:none;}.css-1csz7wa:active{box-shadow:none;}.css-1csz7wa.Mui-disabled{box-shadow:none;}@media (min-width:0px){.css-1csz7wa{;}}@media (min-width:1200px){.css-1csz7wa{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;}}</style><button class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textInherit MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorInherit MuiButton-disableElevation css-1csz7wa" tabindex="0" type="button" id="header-lang-switch" aria-haspopup="true"><span class="MuiButton-startIcon MuiButton-iconSizeMedium css-6xugel"><style data-emotion="css 1slalk2">.css-1slalk2{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:1em;height:1em;display:inline-block;fill:currentColor;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;font-size:1.5rem;fill:#282a36;}</style><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1slalk2" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="LanguageIcon"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"/></svg></span><style data-emotion="css 15r93eu">.css-15r93eu{margin:0;font-size:1rem;line-height:1.5rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:#666666;color:inherit;}</style><span class="MuiTypography-root MuiTypography-body1 css-15r93eu">语言</span><span class="MuiButton-endIcon MuiButton-iconSizeMedium css-1n4a93h"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1slalk2" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="KeyboardArrowDownIcon"><path d="M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"/></svg></span></button></div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-iuftj9" tabindex="0" type="button"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="SearchIcon"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg></button><style data-emotion="css ahtg4s">.css-ahtg4s{max-width:13rem;}@media (min-width:0px){.css-ahtg4s{;}}@media (min-width:1200px){.css-ahtg4s{display:block;}}</style><form class="MuiBox-root css-ahtg4s" novalidate="" autocomplete="off"><style data-emotion="css 24u6h2">.css-24u6h2 .MuiOutlinedInput-root:hover fieldset{border-color:#0ca6f2;border-width:1px;}.css-24u6h2 .MuiOutlinedInput-root.Mui-focused fieldset{border-color:#0ca6f2;border-width:1px;}</style><style data-emotion="css fzbqas">.css-fzbqas .MuiOutlinedInput-root:hover fieldset{border-color:#0ca6f2;border-width:1px;}.css-fzbqas .MuiOutlinedInput-root.Mui-focused fieldset{border-color:#0ca6f2;border-width:1px;}</style><style data-emotion="css bj7gct">.css-bj7gct{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;position:relative;min-width:0;padding:0;margin:0;border:0;vertical-align:top;width:100%;}.css-bj7gct .MuiOutlinedInput-root:hover fieldset{border-color:#0ca6f2;border-width:1px;}.css-bj7gct .MuiOutlinedInput-root.Mui-focused fieldset{border-color:#0ca6f2;border-width:1px;}</style><div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-bj7gct"><style data-emotion="css-global 1prfaxn">@-webkit-keyframes mui-auto-fill{from{display:block;}}@keyframes mui-auto-fill{from{display:block;}}@-webkit-keyframes mui-auto-fill-cancel{from{display:block;}}@keyframes mui-auto-fill-cancel{from{display:block;}}</style><style data-emotion="css sv5gtw">.css-sv5gtw{font-size:1rem;line-height:1.4375em;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:rgba(0, 0, 0, 0.87);box-sizing:border-box;position:relative;cursor:text;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;width:100%;position:relative;border-radius:4px;padding-left:14px;background:#fff;}.css-sv5gtw.Mui-disabled{color:rgba(0, 0, 0, 0.38);cursor:default;}.css-sv5gtw:hover .MuiOutlinedInput-notchedOutline{border-color:rgba(0, 0, 0, 0.87);}@media (hover: none){.css-sv5gtw:hover .MuiOutlinedInput-notchedOutline{border-color:rgba(0, 0, 0, 0.23);}}.css-sv5gtw.Mui-focused .MuiOutlinedInput-notchedOutline{border-color:#1976d2;border-width:2px;}.css-sv5gtw.Mui-error .MuiOutlinedInput-notchedOutline{border-color:#d32f2f;}.css-sv5gtw.Mui-disabled .MuiOutlinedInput-notchedOutline{border-color:rgba(0, 0, 0, 0.26);}</style><div class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedStart css-sv5gtw"><style data-emotion="css 1a6giau">.css-1a6giau{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;height:0.01em;max-height:2em;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;white-space:nowrap;color:rgba(0, 0, 0, 0.54);margin-right:8px;}</style><div class="MuiInputAdornment-root MuiInputAdornment-positionStart MuiInputAdornment-outlined MuiInputAdornment-sizeSmall css-1a6giau"><span class="notranslate"></span><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="SearchIcon"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg></div><style data-emotion="css f2zrvi">.css-f2zrvi{font:inherit;letter-spacing:inherit;color:currentColor;padding:4px 0 5px;border:0;box-sizing:content-box;background:none;height:1.4375em;margin:0;-webkit-tap-highlight-color:transparent;display:block;min-width:0;width:100%;-webkit-animation-name:mui-auto-fill-cancel;animation-name:mui-auto-fill-cancel;-webkit-animation-duration:10ms;animation-duration:10ms;padding-top:1px;-moz-appearance:textfield;padding:8.5px 14px;padding-left:0;}.css-f2zrvi::-webkit-input-placeholder{color:currentColor;opacity:0.42;-webkit-transition:opacity 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:opacity 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;}.css-f2zrvi::-moz-placeholder{color:currentColor;opacity:0.42;-webkit-transition:opacity 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:opacity 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;}.css-f2zrvi:-ms-input-placeholder{color:currentColor;opacity:0.42;-webkit-transition:opacity 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:opacity 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;}.css-f2zrvi::-ms-input-placeholder{color:currentColor;opacity:0.42;-webkit-transition:opacity 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:opacity 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;}.css-f2zrvi:focus{outline:0;}.css-f2zrvi:invalid{box-shadow:none;}.css-f2zrvi::-webkit-search-decoration{-webkit-appearance:none;}label[data-shrink=false]+.MuiInputBase-formControl .css-f2zrvi::-webkit-input-placeholder{opacity:0!important;}label[data-shrink=false]+.MuiInputBase-formControl .css-f2zrvi::-moz-placeholder{opacity:0!important;}label[data-shrink=false]+.MuiInputBase-formControl .css-f2zrvi:-ms-input-placeholder{opacity:0!important;}label[data-shrink=false]+.MuiInputBase-formControl .css-f2zrvi::-ms-input-placeholder{opacity:0!important;}label[data-shrink=false]+.MuiInputBase-formControl .css-f2zrvi:focus::-webkit-input-placeholder{opacity:0.42;}label[data-shrink=false]+.MuiInputBase-formControl .css-f2zrvi:focus::-moz-placeholder{opacity:0.42;}label[data-shrink=false]+.MuiInputBase-formControl .css-f2zrvi:focus:-ms-input-placeholder{opacity:0.42;}label[data-shrink=false]+.MuiInputBase-formControl .css-f2zrvi:focus::-ms-input-placeholder{opacity:0.42;}.css-f2zrvi.Mui-disabled{opacity:1;-webkit-text-fill-color:rgba(0, 0, 0, 0.38);}.css-f2zrvi:-webkit-autofill{-webkit-animation-duration:5000s;animation-duration:5000s;-webkit-animation-name:mui-auto-fill;animation-name:mui-auto-fill;}.css-f2zrvi:-webkit-autofill{border-radius:inherit;}</style><input type="search" aria-invalid="false" id="doc-search" placeholder="搜索文档" value="" class="MuiInputBase-input MuiOutlinedInput-input MuiInputBase-inputTypeSearch MuiInputBase-inputSizeSmall MuiInputBase-inputAdornedStart css-f2zrvi"/><style data-emotion="css 19w1uun">.css-19w1uun{border-color:rgba(0, 0, 0, 0.23);}</style><style data-emotion="css igs3ac">.css-igs3ac{text-align:left;bottom:0;right:0;top:-5px;left:0;margin:0;padding:0 8px;pointer-events:none;border-radius:inherit;border-style:solid;border-width:1px;overflow:hidden;min-width:0%;border-color:rgba(0, 0, 0, 0.23);}</style><fieldset aria-hidden="true" class="MuiOutlinedInput-notchedOutline css-igs3ac"><style data-emotion="css hdw1oc">.css-hdw1oc{float:unset;overflow:hidden;padding:0;line-height:11px;-webkit-transition:width 150ms cubic-bezier(0.0, 0, 0.2, 1) 0ms;transition:width 150ms cubic-bezier(0.0, 0, 0.2, 1) 0ms;}</style><legend class="css-hdw1oc"><span class="notranslate"></span></legend></fieldset></div></div></form></div></div></header><style data-emotion="css s1brf2">.css-s1brf2{margin-top:5rem;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}</style><div class="PingCAP-Doc MuiBox-root css-s1brf2"><style data-emotion="css hboir5">.css-hboir5{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;width:100%;}</style><div class="MuiBox-root css-hboir5"><style data-emotion="css 2tzg8">.css-2tzg8{width:18.75rem;border-right:1px solid #E5E4E4;}@media (min-width:0px){.css-2tzg8{;}}@media (min-width:1200px){.css-2tzg8{display:block;}}</style><aside class="MuiBox-root css-2tzg8"><style data-emotion="css 1eohm8p">.css-1eohm8p{position:-webkit-sticky;position:sticky;top:5rem;height:100%;max-height:calc(100vh - 7rem);overflow-y:auto;padding:1rem;}</style><div class="MuiBox-root css-1eohm8p"><style data-emotion="css fmyu0n">.css-fmyu0n{text-transform:none;font-family:-apple-system,"Poppins","Helvetica Neue",sans-serif,"Noto Sans","Fira Code","IBM Plex Sans","sans-serif";font-weight:500;font-size:0.875rem;line-height:1.75;min-width:64px;padding:6px 8px;border-radius:4px;-webkit-transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;color:#1976d2;width:100%;height:2rem;-webkit-box-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;border-style:solid;border-width:1px;border-color:#e5e5e5;margin-bottom:1rem;}.css-fmyu0n:hover{-webkit-text-decoration:none;text-decoration:none;background-color:rgba(25, 118, 210, 0.04);}@media (hover: none){.css-fmyu0n:hover{background-color:transparent;}}.css-fmyu0n.Mui-disabled{color:rgba(0, 0, 0, 0.26);}</style><style data-emotion="css 1rq233s">.css-1rq233s{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;position:relative;box-sizing:border-box;-webkit-tap-highlight-color:transparent;background-color:transparent;outline:0;border:0;margin:0;border-radius:0;padding:0;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;-moz-appearance:none;-webkit-appearance:none;-webkit-text-decoration:none;text-decoration:none;color:inherit;text-transform:none;font-family:-apple-system,"Poppins","Helvetica Neue",sans-serif,"Noto Sans","Fira Code","IBM Plex Sans","sans-serif";font-weight:500;font-size:0.875rem;line-height:1.75;min-width:64px;padding:6px 8px;border-radius:4px;-webkit-transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;color:#1976d2;width:100%;height:2rem;-webkit-box-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;border-style:solid;border-width:1px;border-color:#e5e5e5;margin-bottom:1rem;}.css-1rq233s::-moz-focus-inner{border-style:none;}.css-1rq233s.Mui-disabled{pointer-events:none;cursor:default;}@media print{.css-1rq233s{-webkit-print-color-adjust:exact;color-adjust:exact;}}.css-1rq233s:hover{-webkit-text-decoration:none;text-decoration:none;background-color:rgba(25, 118, 210, 0.04);}@media (hover: none){.css-1rq233s:hover{background-color:transparent;}}.css-1rq233s.Mui-disabled{color:rgba(0, 0, 0, 0.26);}</style><button class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium css-1rq233s" tabindex="0" type="button" id="version-select-button" aria-haspopup="true"><style data-emotion="css 3cb5vr">.css-3cb5vr{margin:0;font-size:1rem;line-height:1.5rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:#666666;padding:0 0.25rem;font-size:0.875rem;line-height:1.25rem;}</style><div class="MuiTypography-root MuiTypography-body1 css-3cb5vr">v7.1</div><style data-emotion="css 1n4a93h">.css-1n4a93h{display:inherit;margin-right:-4px;margin-left:8px;}.css-1n4a93h>*:nth-of-type(1){font-size:20px;}</style><span class="MuiButton-endIcon MuiButton-iconSizeMedium css-1n4a93h"><style data-emotion="css b5l66">.css-b5l66{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:1em;height:1em;display:inline-block;fill:currentColor;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;font-size:1.5rem;-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg);height:1.5rem;width:1.5rem;fill:#999999;margin-right:0.25rem;}</style><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-b5l66" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></span></button><style data-emotion="css 1c58svf">.css-1c58svf .MuiPaper-root{border-radius:6px;margin-top:8px;min-width:268px;color:rgb(55, 65, 81);box-shadow:rgb(255, 255, 255) 0px 0px 0px 0px,rgba(0, 0, 0, 0.05) 0px 0px 0px 1px,rgba(0, 0, 0, 0.1) 0px 10px 15px -3px,rgba(0, 0, 0, 0.05) 0px 4px 6px -2px;}.css-1c58svf .MuiPaper-root .MuiMenu-list{padding:4px 0;}.css-1c58svf .MuiPaper-root .MuiMenuItem-root .MuiSvgIcon-root{font-size:18px;color:rgba(0, 0, 0, 0.6);margin-right:12px;}.css-1c58svf .MuiPaper-root .MuiMenuItem-root:active{background-color:rgba(25, 118, 210, 0.08);}</style><style data-emotion="css yvxbj">.css-yvxbj .MuiPaper-root{border-radius:6px;margin-top:8px;min-width:268px;color:rgb(55, 65, 81);box-shadow:rgb(255, 255, 255) 0px 0px 0px 0px,rgba(0, 0, 0, 0.05) 0px 0px 0px 1px,rgba(0, 0, 0, 0.1) 0px 10px 15px -3px,rgba(0, 0, 0, 0.05) 0px 4px 6px -2px;}.css-yvxbj .MuiPaper-root .MuiMenu-list{padding:4px 0;}.css-yvxbj .MuiPaper-root .MuiMenuItem-root .MuiSvgIcon-root{font-size:18px;color:rgba(0, 0, 0, 0.6);margin-right:12px;}.css-yvxbj .MuiPaper-root .MuiMenuItem-root:active{background-color:rgba(25, 118, 210, 0.08);}</style><style data-emotion="css oe3wem">.css-oe3wem .MuiPaper-root{border-radius:6px;margin-top:8px;min-width:268px;color:rgb(55, 65, 81);box-shadow:rgb(255, 255, 255) 0px 0px 0px 0px,rgba(0, 0, 0, 0.05) 0px 0px 0px 1px,rgba(0, 0, 0, 0.1) 0px 10px 15px -3px,rgba(0, 0, 0, 0.05) 0px 4px 6px -2px;}.css-oe3wem .MuiPaper-root .MuiMenu-list{padding:4px 0;}.css-oe3wem .MuiPaper-root .MuiMenuItem-root .MuiSvgIcon-root{font-size:18px;color:rgba(0, 0, 0, 0.6);margin-right:12px;}.css-oe3wem .MuiPaper-root .MuiMenuItem-root:active{background-color:rgba(25, 118, 210, 0.08);}</style><style data-emotion="css 12mehxg">.css-12mehxg{padding:0;margin:0;list-style:none;outline:0;}</style><ul role="tree" id="left-nav-treeview" aria-multiselectable="false" class="MuiTreeView-root css-12mehxg" tabindex="0" aria-label="left navigation"><style data-emotion="css 1gesgke">.css-1gesgke .MuiTreeItem-content{color:#282a36;border-radius:4px;}.css-1gesgke .MuiTreeItem-content:hover{background-color:#f9f9f9;}.css-1gesgke .MuiTreeItem-content.Mui-selected,.css-1gesgke .MuiTreeItem-content.Mui-selected.Mui-focused{background-color:var(--tree-view-bg-color, #EAF6FB);color:var(--tree-view-color, #0A85C2);}.css-1gesgke .MuiTreeItem-content.Mui-selected svg.MuiTreeItem-ChevronRightIcon,.css-1gesgke .MuiTreeItem-content.Mui-selected.Mui-focused svg.MuiTreeItem-ChevronRightIcon{fill:var(--tree-view-color, #0A85C2);}.css-1gesgke .MuiTreeItem-content.Mui-focused{background-color:#f9f9f9;}.css-1gesgke .MuiTreeItem-content .MuiTreeItem-label{font-weight:inherit;color:inherit;}.css-1gesgke .MuiTreeItem-content .MuiTreeItem-iconContainer{;}.css-1gesgke .MuiTreeItem-group{margin-left:0;}.css-1gesgke .MuiTreeItem-group .MuiTreeItem-content{padding-left:16px;}</style><style data-emotion="css 1oy5rnm">.css-1oy5rnm{list-style:none;margin:0;padding:0;outline:0;}.css-1oy5rnm .MuiTreeItem-content{color:#282a36;border-radius:4px;}.css-1oy5rnm .MuiTreeItem-content:hover{background-color:#f9f9f9;}.css-1oy5rnm .MuiTreeItem-content.Mui-selected,.css-1oy5rnm .MuiTreeItem-content.Mui-selected.Mui-focused{background-color:var(--tree-view-bg-color, #EAF6FB);color:var(--tree-view-color, #0A85C2);}.css-1oy5rnm .MuiTreeItem-content.Mui-selected svg.MuiTreeItem-ChevronRightIcon,.css-1oy5rnm .MuiTreeItem-content.Mui-selected.Mui-focused svg.MuiTreeItem-ChevronRightIcon{fill:var(--tree-view-color, #0A85C2);}.css-1oy5rnm .MuiTreeItem-content.Mui-focused{background-color:#f9f9f9;}.css-1oy5rnm .MuiTreeItem-content .MuiTreeItem-label{font-weight:inherit;color:inherit;}.css-1oy5rnm .MuiTreeItem-content .MuiTreeItem-iconContainer{;}.css-1oy5rnm .MuiTreeItem-group{margin-left:0;}.css-1oy5rnm .MuiTreeItem-group .MuiTreeItem-content{padding-left:16px;}</style><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" id="left-nav-treeview-0-0" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><style data-emotion="css khel7y">.css-khel7y{padding:0 8px;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;cursor:pointer;-webkit-tap-highlight-color:transparent;}.css-khel7y:hover{background-color:rgba(0, 0, 0, 0.04);}@media (hover: none){.css-khel7y:hover{background-color:transparent;}}.css-khel7y.Mui-disabled{opacity:0.38;background-color:transparent;}.css-khel7y.Mui-focused{background-color:rgba(0, 0, 0, 0.12);}.css-khel7y.Mui-selected{background-color:rgba(25, 118, 210, 0.08);}.css-khel7y.Mui-selected:hover{background-color:rgba(25, 118, 210, 0.12);}@media (hover: none){.css-khel7y.Mui-selected:hover{background-color:rgba(25, 118, 210, 0.08);}}.css-khel7y.Mui-selected.Mui-focused{background-color:rgba(25, 118, 210, 0.2);}.css-khel7y .MuiTreeItem-iconContainer{margin-right:4px;width:15px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;}.css-khel7y .MuiTreeItem-iconContainer svg{font-size:18px;}.css-khel7y .MuiTreeItem-label{width:100%;min-width:0;padding-left:4px;position:relative;font-size:1rem;line-height:1.5rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:#666666;}</style><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><style data-emotion="css znl8a3">.css-znl8a3{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;min-height:1.75rem;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding-left:0rem;padding-top:0.25rem;padding-bottom:0.25rem;}</style><div class="css-znl8a3"><style data-emotion="css tx8jsd">.css-tx8jsd{margin:0;font-size:1rem;line-height:1.5rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:#666666;}</style><a class="MuiTypography-root MuiTypography-body1 css-tx8jsd" target="_blank" href="https://docs.pingcap.com/zh" style="text-decoration:none;width:100%;color:inherit"><style data-emotion="css 8atqhb">.css-8atqhb{width:100%;}</style><div class="MuiBox-root css-8atqhb"><style data-emotion="css 1hwyipb">.css-1hwyipb{margin:0;font-size:1rem;line-height:1.5rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:#666666;color:inherit;font-size:0.875rem;line-height:1.25rem;}</style><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">文档中心</div></div></a></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-1" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">关于 TiDB</div></div><style data-emotion="css xjq79n">.css-xjq79n{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:1em;height:1em;display:inline-block;fill:currentColor;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;font-size:1.5rem;fill:#999999;height:1rem;width:1rem;margin-left:auto;-webkit-transform:none;-moz-transform:none;-ms-transform:none;transform:none;}</style><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div><style data-emotion="css 1jozaee">.css-1jozaee{margin:0;padding:0;margin-left:17px;}</style></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-2" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">快速上手</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-3" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">应用开发</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-4" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">部署标准集群</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-5" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">数据迁移</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-6" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">数据集成</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-7" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">运维操作</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-8" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">监控与告警</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-9" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">故障诊断</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-10" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">性能调优</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-11" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">教程</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-12" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">TiDB 工具</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="true" id="left-nav-treeview-0-13" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content Mui-expanded" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">参考指南</div></div><style data-emotion="css 171pefp">.css-171pefp{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:1em;height:1em;display:inline-block;fill:currentColor;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;font-size:1.5rem;fill:#999999;height:1rem;width:1rem;margin-left:auto;-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg);}</style><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-171pefp" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div><style data-emotion="css 1xxsnna">.css-1xxsnna{height:auto;overflow:visible;-webkit-transition:height 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:height 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;margin:0;padding:0;margin-left:17px;}</style><ul class="MuiCollapse-root MuiCollapse-vertical MuiTreeItem-group MuiCollapse-entered css-1xxsnna" style="min-height:0px" role="group"><div class="MuiCollapse-wrapper MuiCollapse-vertical css-hboir5"><div class="MuiCollapse-wrapperInner MuiCollapse-vertical css-8atqhb"><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-0" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><style data-emotion="css kb2j4b">.css-kb2j4b{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;min-height:1.75rem;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding-left:0.5rem;padding-top:0.25rem;padding-bottom:0.25rem;}</style><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">架构</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-1" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">存储引擎 TiKV</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-2" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">存储引擎 TiFlash</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" id="left-nav-treeview-0-13-3" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content Mui-expanded" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><a aria-current="page" style="text-decoration:none;width:100%;color:inherit" class="" href="/zh/tidb/stable/system-variables"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">系统变量</div></div></a></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-4" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">配置文件参数</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-5" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">CLI</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-6" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">命令行参数</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-7" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">监控指标</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-8" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">安全加固</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-9" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">权限</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-10" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">SQL</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-11" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">UI</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" id="left-nav-treeview-0-13-12" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/telemetry"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">遥测</div></div></a></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" id="left-nav-treeview-0-13-13" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/error-codes"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">错误码</div></div></a></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" id="left-nav-treeview-0-13-14" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/schedule-replicas-by-topology-labels"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">通过拓扑 label 进行副本调度</div></div></a></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13-15" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-kb2j4b"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">内部组件介绍</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li></div></div></ul></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-14" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">常见问题解答 (FAQ)</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-15" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">版本发布历史</div></div><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-xjq79n" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ChevronRightIcon"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg></div></div></div></li><li class="MuiTreeItem-root css-1oy5rnm" role="treeitem" id="left-nav-treeview-0-16" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-khel7y MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-znl8a3"><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/glossary"><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1hwyipb">术语表</div></div></a></div></div></div></li></ul></div></aside><style data-emotion="css sb2sd0">.css-sb2sd0{width:100%;}@media (min-width:1200px){.css-sb2sd0{max-width:calc(100% - 18.75rem);}}</style><main class="MuiBox-root css-sb2sd0"><style data-emotion="css 1rnnmjb">.css-1rnnmjb{max-width:1340px;width:100%;margin-left:auto;margin-right:auto;display:block;box-sizing:border-box;}</style><div class="MuiBox-root css-1rnnmjb"><style data-emotion="css 90fn5w">.css-90fn5w{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}@media (min-width:0px){.css-90fn5w{-webkit-flex-direction:column-reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse;}}@media (min-width:600px){.css-90fn5w{-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;}}</style><div class="css-90fn5w"><style data-emotion="css vofosd">.css-vofosd{padding:1.5rem 0;}@media (min-width:0px){.css-vofosd{width:100%;}}@media (min-width:600px){.css-vofosd{width:calc(100% - 17.5rem);}}</style><div class="MuiBox-root css-vofosd"><style data-emotion="css 1ekb41w">.css-1ekb41w{width:100%;margin-left:auto;box-sizing:border-box;margin-right:auto;display:block;padding-left:16px;padding-right:16px;}@media (min-width:600px){.css-1ekb41w{padding-left:24px;padding-right:24px;}}@media (min-width:1536px){.css-1ekb41w{max-width:1536px;}}</style><div class="MuiContainer-root MuiContainer-maxWidthXl doc-content css-1ekb41w"><div class="markdown-body MuiBox-root css-0"><h1 id="系统变量" style="position:relative"><a href="#%E7%B3%BB%E7%BB%9F%E5%8F%98%E9%87%8F" aria-label="系统变量 permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>系统变量</h1><p>TiDB 系统变量的行为与 MySQL 相似,变量的作用范围可以是会话级别有效 (Session Scope) 或全局范围有效 (Global Scope)。其中:</p><ul><li>对 <code>SESSION</code> 作用域变量的更改,设置后<strong>只影响当前会话</strong>。</li><li>对 <code>GLOBAL</code> 作用域变量的更改,设置后立即生效。如果该变量也有 <code>SESSION</code> 作用域,已经连接的所有会话 (包括当前会话) 将继续使用会话当前的 <code>SESSION</code> 变量值。</li><li>要设置变量值,可使用 <a href="/zh/tidb/stable/sql-statement-set-variable"><code>SET</code> 语句</a>。</li></ul><pre><code class="language-sql"># 以下两个语句等价地改变一个 Session 变量 SET tidb_distsql_scan_concurrency = 10; SET SESSION tidb_distsql_scan_concurrency = 10; # 以下两个语句等价地改变一个 Global 变量 SET @@global.tidb_distsql_scan_concurrency = 10; SET GLOBAL tidb_distsql_scan_concurrency = 10; </code></pre><style data-emotion="css 1weqspv">.css-1weqspv{padding-top:0.5rem;padding-bottom:0.5rem;}.css-1weqspv .MuiAlert-message p{margin-bottom:0px;margin-top:0px;}</style><div class="MuiBox-root css-1weqspv"><style data-emotion="css 17zlexa">.css-17zlexa{font-size:0.875rem;line-height:1.25rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:rgb(1, 67, 97);background-color:rgb(229, 246, 253);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:6px 16px;}.css-17zlexa .MuiAlert-icon{color:#03a9f4;}</style><style data-emotion="css 152gid5">.css-152gid5{background-color:#fff;color:rgba(0, 0, 0, 0.87);-webkit-transition:box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;border-radius:4px;box-shadow:none;font-size:0.875rem;line-height:1.25rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:rgb(1, 67, 97);background-color:rgb(229, 246, 253);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:6px 16px;}.css-152gid5 .MuiAlert-icon{color:#03a9f4;}</style><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><style data-emotion="css 1l54tgj">.css-1l54tgj{margin-right:12px;padding:7px 0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;font-size:22px;opacity:0.9;}</style><div class="MuiAlert-icon css-1l54tgj"><style data-emotion="css 1cw4hi4">.css-1cw4hi4{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:1em;height:1em;display:inline-block;fill:currentColor;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;font-size:inherit;}</style><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><style data-emotion="css 1xsto0d">.css-1xsto0d{padding:8px 0;min-width:0;overflow:auto;}</style><div class="MuiAlert-message css-1xsto0d"><style data-emotion="css 1h2y6o4">.css-1h2y6o4{font-weight:500;margin-top:-2px;}</style><style data-emotion="css 17ioyuk">.css-17ioyuk{margin:0;font-size:1rem;line-height:1.5rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:#666666;margin-bottom:0.35em;font-weight:500;margin-top:-2px;}</style><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>部分 <code>GLOBAL</code> 作用域的变量会持久化到 TiDB 集群中。文档中的变量有一个“是否持久化到集群”的说明,可以为“是”或者“否”。</p><ul><li>对于持久化到集群的变量,当该全局变量被修改后,会通知所有 TiDB 服务器刷新其系统变量缓存。在集群中增加一个新的 TiDB 服务器时,或者重启现存的 TiDB 服务器时,都将自动使用该持久化变量。</li><li>对于不持久化到集群的变量,对变量的修改只对当前连接的 TiDB 实例生效。如果需要保留设置过的值,需要在 <code>tidb.toml</code> 配置文件中声明。</li></ul><p>此外,由于应用和连接器通常需要读取 MySQL 变量,为了兼容这一需求,在 TiDB 中,部分 MySQL 的变量既可读取也可设置。例如,尽管 JDBC 连接器不依赖于查询缓存 (query cache) 的行为,但仍然可以读取和设置查询缓存。</p></div></div></div><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>变量取较大值并不总会带来更好的性能。由于大部分变量对单个连接生效,设置变量时,还应考虑正在执行语句的并发连接数量。</p><p>确定安全值时,应考虑变量的单位:</p><ul><li>如果单位为线程,安全值通常取决于 CPU 核的数量。</li><li>如果单位为字节,安全值通常小于系统内存的总量。</li><li>如果单位为时间,单位可能为秒或毫秒。</li></ul><p>单位相同的多个变量可能会争夺同一组资源。</p></div></div></div><h2 id="变量参考" style="position:relative"><a href="#%E5%8F%98%E9%87%8F%E5%8F%82%E8%80%83" aria-label="变量参考 permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>变量参考</h2><h3 id="allow_auto_random_explicit_insert-span-classversion-mark从-v403-版本开始引入span" style="position:relative"><a href="#allow_auto_random_explicit_insert-span-classversion-mark%E4%BB%8E-v403-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="allow_auto_random_explicit_insert span classversion mark从 v403 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>allow_auto_random_explicit_insert</code> <span class="version-mark">从 v4.0.3 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>是否允许在 <code>INSERT</code> 语句中显式指定含有 <code>AUTO_RANDOM</code> 属性的列的值。</li></ul><h3 id="authentication_ldap_sasl_auth_method_name-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_sasl_auth_method_name-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_sasl_auth_method_name span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_sasl_auth_method_name</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>SCRAM-SHA-1</code></li><li>可选值:<code>SCRAM-SHA-1</code>、<code>SCRAM-SHA-256</code>、<code>GSSAPI</code></li><li>LDAP SASL 身份验证中,验证方法的名称。</li></ul><h3 id="authentication_ldap_sasl_bind_base_dn-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_sasl_bind_base_dn-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_sasl_bind_base_dn span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_sasl_bind_base_dn</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:""</li><li>LDAP SASL 身份验证中,搜索用户的范围。如果创建用户时没有通过 <code>AS ...</code> 指定 <code>dn</code>,TiDB 会自动在 LDAP Server 的该范围中根据用户名搜索用户 <code>dn</code>。例如 <code>dc=example,dc=org</code>。</li></ul><h3 id="authentication_ldap_sasl_bind_root_dn-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_sasl_bind_root_dn-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_sasl_bind_root_dn span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_sasl_bind_root_dn</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:""</li><li>LDAP SASL 身份验证中,TiDB 登录 LDAP Server 搜索用户时使用的 <code>dn</code>。</li></ul><h3 id="authentication_ldap_sasl_bind_root_pwd-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_sasl_bind_root_pwd-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_sasl_bind_root_pwd span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_sasl_bind_root_pwd</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:""</li><li>LDAP SASL 身份验证中,TiDB 登录 LDAP Server 搜索用户时使用的密码。</li></ul><h3 id="authentication_ldap_sasl_ca_path-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_sasl_ca_path-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_sasl_ca_path span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_sasl_ca_path</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:""</li><li>LDAP SASL 身份验证中,TiDB 对 StartTLS 连接使用的 CA 证书的路径。</li></ul><h3 id="authentication_ldap_sasl_init_pool_size-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_sasl_init_pool_size-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_sasl_init_pool_size span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_sasl_init_pool_size</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>10</code></li><li>范围:<code>[1, 32767]</code></li><li>LDAP SASL 身份验证中,TiDB 与 LDAP Server 间连接池的初始连接数。</li></ul><h3 id="authentication_ldap_sasl_max_pool_size-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_sasl_max_pool_size-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_sasl_max_pool_size span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_sasl_max_pool_size</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1000</code></li><li>范围:<code>[1, 32767]</code></li><li>LDAP SASL 身份验证中,TiDB 与 LDAP Server 间连接池的最大连接数。</li></ul><h3 id="authentication_ldap_sasl_server_host-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_sasl_server_host-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_sasl_server_host span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_sasl_server_host</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:""</li><li>LDAP SASL 身份验证中,LDAP Server 的主机名或地址。</li></ul><h3 id="authentication_ldap_sasl_server_port-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_sasl_server_port-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_sasl_server_port span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_sasl_server_port</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>389</code></li><li>范围:<code>[1, 65535]</code></li><li>LDAP SASL 身份验证中,LDAP Server 的 TCP/IP 端口号。</li></ul><h3 id="authentication_ldap_sasl_tls-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_sasl_tls-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_sasl_tls span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_sasl_tls</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>LDAP SASL 身份验证中,是否使用 StartTLS 对连接加密。</li></ul><h3 id="authentication_ldap_simple_auth_method_name-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_simple_auth_method_name-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_simple_auth_method_name span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_simple_auth_method_name</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>SIMPLE</code></li><li>可选值:<code>SIMPLE</code></li><li>LDAP simple 身份验证中,验证方法的名称。现在仅支持 <code>SIMPLE</code>。</li></ul><h3 id="authentication_ldap_simple_bind_base_dn-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_simple_bind_base_dn-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_simple_bind_base_dn span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_simple_bind_base_dn</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:""</li><li>LDAP simple 身份验证中,搜索用户的范围。如果创建用户时没有通过 <code>AS ...</code> 指定 <code>dn</code>,TiDB 会自动在 LDAP Server 的该范围中根据用户名搜索用户 <code>dn</code>。例如 <code>dc=example,dc=org</code>。</li></ul><h3 id="authentication_ldap_simple_bind_root_dn-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_simple_bind_root_dn-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_simple_bind_root_dn span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_simple_bind_root_dn</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:""</li><li>LDAP simple 身份验证中,TiDB 登录 LDAP Server 搜索用户时使用的 <code>dn</code>。</li></ul><h3 id="authentication_ldap_simple_bind_root_pwd-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_simple_bind_root_pwd-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_simple_bind_root_pwd span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_simple_bind_root_pwd</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:""</li><li>LDAP simple 身份验证中,TiDB 登录 LDAP Server 搜索用户时使用的密码。</li></ul><h3 id="authentication_ldap_simple_ca_path-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_simple_ca_path-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_simple_ca_path span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_simple_ca_path</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:""</li><li>LDAP simple 身份验证中,TiDB 对 StartTLS 连接使用的 CA 证书的路径。</li></ul><h3 id="authentication_ldap_simple_init_pool_size-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_simple_init_pool_size-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_simple_init_pool_size span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_simple_init_pool_size</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>10</code></li><li>范围:<code>[1, 32767]</code></li><li>LDAP simple 身份验证中,TiDB 与 LDAP Server 间连接池的初始连接数。</li></ul><h3 id="authentication_ldap_simple_max_pool_size-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_simple_max_pool_size-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_simple_max_pool_size span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_simple_max_pool_size</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1000</code></li><li>范围:<code>[1, 32767]</code></li><li>LDAP simple 身份验证中,TiDB 与 LDAP Server 间连接池的最大连接数。</li></ul><h3 id="authentication_ldap_simple_server_host-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_simple_server_host-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_simple_server_host span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_simple_server_host</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:""</li><li>LDAP simple 身份验证中,LDAP Server 的主机名或地址。</li></ul><h3 id="authentication_ldap_simple_server_port-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_simple_server_port-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_simple_server_port span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_simple_server_port</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>389</code></li><li>范围:<code>[1, 65535]</code></li><li>LDAP simple 身份验证中,LDAP Server 的 TCP/IP 端口号。</li></ul><h3 id="authentication_ldap_simple_tls-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#authentication_ldap_simple_tls-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="authentication_ldap_simple_tls span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>authentication_ldap_simple_tls</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>LDAP simple 身份验证中,是否使用 StartTLS 对连接加密。</li></ul><h3 id="auto_increment_increment" style="position:relative"><a href="#auto_increment_increment" aria-label="auto_increment_increment permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>auto_increment_increment</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1</code></li><li>范围:<code>[1, 65535]</code></li><li>控制 <code>AUTO_INCREMENT</code> 自增值字段的自增步长。该变量常与 <code>auto_increment_offset</code> 一起使用。</li></ul><h3 id="auto_increment_offset" style="position:relative"><a href="#auto_increment_offset" aria-label="auto_increment_offset permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>auto_increment_offset</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1</code></li><li>范围:<code>[1, 65535]</code></li><li>控制 <code>AUTO_INCREMENT</code> 自增值字段的初始值。该变量常与 <code>auto_increment_increment</code> 一起使用。示例如下:</li></ul><pre><code class="language-sql">mysql> CREATE TABLE t1 (a int not null primary key auto_increment); Query OK, 0 rows affected (0.10 sec) mysql> set auto_increment_offset=1; Query OK, 0 rows affected (0.00 sec) mysql> set auto_increment_increment=3; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO t1 VALUES (),(),(),(); Query OK, 4 rows affected (0.04 sec) Records: 4 Duplicates: 0 Warnings: 0 mysql> SELECT * FROM t1; +----+ | a | +----+ | 1 | | 4 | | 7 | | 10 | +----+ 4 rows in set (0.00 sec) </code></pre><h3 id="autocommit" style="position:relative"><a href="#autocommit" aria-label="autocommit permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>autocommit</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>用于设置在非显式事务时是否自动提交事务。更多信息,请参见<a href="/zh/tidb/stable/transaction-overview#自动提交">事务概述</a>。</li></ul><h3 id="block_encryption_mode" style="position:relative"><a href="#block_encryption_mode" aria-label="block_encryption_mode permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>block_encryption_mode</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>aes-128-ecb</code></li><li>可选值:<code>aes-128-ecb</code>、<code>aes-192-ecb</code>、<code>aes-256-ecb</code>、<code>aes-128-cbc</code>、<code>aes-192-cbc</code>、<code>aes-256-cbc</code>、<code>aes-128-ofb</code>、<code>aes-192-ofb</code>、<code>aes-256-ofb</code>、<code>aes-128-cfb</code>、<code>aes-192-cfb</code>、<code>aes-256-cfb</code></li><li>该变量用于设置 <code>AES_ENCRYPT()</code> 和 <code>AES_DECRYPT()</code> 函数的加密模式。</li></ul><h3 id="character_set_client" style="position:relative"><a href="#character_set_client" aria-label="character_set_client permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>character_set_client</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>utf8mb4</code></li><li>这个变量表示从客户端发出的数据所用的字符集。有关更多 TiDB 支持的字符集和排序规则,参阅<a href="/zh/tidb/stable/character-set-and-collation">字符集和排序规则</a>文档。如果需要更改字符集,建议使用 <a href="/zh/tidb/stable/sql-statement-set-names"><code>SET NAMES</code></a> 语句。</li></ul><h3 id="character_set_connection" style="position:relative"><a href="#character_set_connection" aria-label="character_set_connection permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>character_set_connection</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>utf8mb4</code></li><li>若没有为字符串常量指定字符集,该变量表示这些字符串常量所使用的字符集。</li></ul><h3 id="character_set_database" style="position:relative"><a href="#character_set_database" aria-label="character_set_database permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>character_set_database</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>utf8mb4</code></li><li>该变量表示当前默认在用数据库的字符集,<strong>不建议设置该变量</strong>。选择新的默认数据库后,服务器会更改该变量的值。</li></ul><h3 id="character_set_results" style="position:relative"><a href="#character_set_results" aria-label="character_set_results permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>character_set_results</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>utf8mb4</code></li><li>该变量表示数据发送至客户端时所使用的字符集。</li></ul><h3 id="character_set_server" style="position:relative"><a href="#character_set_server" aria-label="character_set_server permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>character_set_server</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>utf8mb4</code></li><li>当 <code>CREATE SCHEMA</code> 中没有指定字符集时,该变量表示这些新建的表结构所使用的字符集。</li></ul><h3 id="collation_connection" style="position:relative"><a href="#collation_connection" aria-label="collation_connection permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>collation_connection</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>utf8mb4_bin</code></li><li>该变量表示连接中所使用的排序规则。与 MySQL 中的 <code>collation_connection</code> 一致。</li></ul><h3 id="collation_database" style="position:relative"><a href="#collation_database" aria-label="collation_database permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>collation_database</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>utf8mb4_bin</code></li><li>该变量表示当前数据库默认所使用的排序规则。与 MySQL 中的 <code>collation_database</code> 一致。<strong>不建议设置此变量</strong>,当前使用的数据库变动时,此变量会被 TiDB 修改。</li></ul><h3 id="collation_server" style="position:relative"><a href="#collation_server" aria-label="collation_server permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>collation_server</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>utf8mb4_bin</code></li><li>该变量表示创建数据库时默认的排序规则。</li></ul><h3 id="cte_max_recursion_depth" style="position:relative"><a href="#cte_max_recursion_depth" aria-label="cte_max_recursion_depth permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>cte_max_recursion_depth</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1000</code></li><li>范围:<code>[0, 4294967295]</code></li><li>这个变量用于控制公共表表达式的最大递归深度。</li></ul><h3 id="datadir" style="position:relative"><a href="#datadir" aria-label="datadir permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>datadir</code></h3><ul><li>作用域:NONE</li><li>默认值:使用的组件和部署方式不同,默认值也不同。<ul><li><code>/tmp/tidb</code>:如果你将 <a href="/zh/tidb/stable/command-line-flags-for-tidb-configuration#--store"><code>--store</code></a> 设置为 <code>"unistore"</code> 或没有设置 <code>--store</code>,则默认值为 <code>/tmp/tidb</code>。</li><li><code>${pd-ip}:${pd-port}</code>:如果你设置的存储引擎是 TiKV(如果使用 TiUP 和 TiDB Operator 部署,则默认的存储引擎为 TiKV),则默认值为 <code>${pd-ip}:${pd-port}</code>。</li></ul></li><li>这个变量表示数据存储的位置,位置可以是本地路径 <code>/tmp/tidb</code>。如果数据存储在 TiKV 上,则可以是指向 PD 服务器的路径。变量值的格式为 <code>${pd-ip}:${pd-port}</code>,表示 TiDB 在启动时连接到的 PD 服务器。</li></ul><h3 id="ddl_slow_threshold" style="position:relative"><a href="#ddl_slow_threshold" aria-label="ddl_slow_threshold permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>ddl_slow_threshold</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:整数型</li><li>默认值:<code>300</code></li><li>取值范围:<code>[0, 2147483647]</code></li><li>单位:毫秒</li><li>耗时超过该阈值的 DDL 操作会被输出到日志。</li></ul><h3 id="default_authentication_plugin" style="position:relative"><a href="#default_authentication_plugin" aria-label="default_authentication_plugin permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>default_authentication_plugin</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>mysql_native_password</code></li><li>可选值:<code>mysql_native_password</code>,<code>caching_sha2_password</code>,<code>tidb_sm3_password</code>,<code>tidb_auth_token</code>,<code>authentication_ldap_sasl</code> 或 <code>authentication_ldap_simple</code>。</li><li><code>tidb_auth_token</code> 认证方式仅用于 TiDB Cloud 内部实现,<strong>不要设置为该值</strong>。</li><li>服务器和客户端建立连接时,这个变量用于设置服务器对外通告的默认身份验证方式。如要了解该变量的其他可选值,参见<a href="/zh/tidb/stable/security-compatibility-with-mysql#可用的身份验证插件">可用的身份验证插件</a>。</li><li>若要在用户登录时使用 <code>tidb_sm3_password</code> 插件,需要使用 <a href="https://github.com/pingcap/mysql-connector-j/tree/release/8.0-sm3" target="_blank" referrerpolicy="no-referrer-when-downgrade">TiDB-JDBC</a> 进行连接。</li></ul><h3 id="default_password_lifetime-span-classversion-mark从-v650-版本开始引入span" style="position:relative"><a href="#default_password_lifetime-span-classversion-mark%E4%BB%8E-v650-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="default_password_lifetime span classversion mark从 v650 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>default_password_lifetime</code> <span class="version-mark">从 v6.5.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>取值范围:<code>[0, 65535]</code></li><li>该变量用于设置全局自动密码过期策略,默认值为 <code>0</code>,即禁用全局自动密码过期。如果设置该变量的值为正整数 N,则表示允许的密码生存期为 N,即必须在 N 天之内更改密码。</li></ul><h3 id="default_week_format" style="position:relative"><a href="#default_week_format" aria-label="default_week_format permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>default_week_format</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>取值范围:<code>[0, 7]</code></li><li>设置 <code>WEEK()</code> 函数使用的周格式。</li></ul><h3 id="disconnect_on_expired_password-span-classversion-mark从-v650-版本开始引入span" style="position:relative"><a href="#disconnect_on_expired_password-span-classversion-mark%E4%BB%8E-v650-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="disconnect_on_expired_password span classversion mark从 v650 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>disconnect_on_expired_password</code> <span class="version-mark">从 v6.5.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>该变量是一个只读变量,用来显示 TiDB 是否会直接断开密码已过期用户的连接。当其值为 <code>ON</code>,表示 TiDB 会断开密码已过期用户的连接。当其值为 <code>OFF</code>,表示 TiDB 会将密码已过期用户的连接置于“沙盒模式”,允许该用户建立连接并执行密码重置操作。</li><li>如果需要改变 TiDB 对密码已过期用户连接的处理方式,请在 TiDB 配置文件中的 <code>[security]</code> 部分修改 <a href="/zh/tidb/stable/tidb-configuration-file#disconnect-on-expired-password-从-v650-版本开始引入"><code>disconnect-on-expired-password</code></a> 选项。</li></ul><h3 id="error_count" style="position:relative"><a href="#error_count" aria-label="error_count permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>error_count</code></h3><ul><li>作用域:SESSION</li><li>默认值:<code>0</code></li><li>类型:整数型</li><li>表示上一条生成消息的 SQL 语句中的错误数。该变量为只读变量。</li></ul><h3 id="foreign_key_checks" style="position:relative"><a href="#foreign_key_checks" aria-label="foreign_key_checks permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>foreign_key_checks</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:在 v6.6.0 之前版本中为 <code>OFF</code>,在 v6.6.0 及之后的版本中为 <code>ON</code>。</li><li>表示是否开启外键约束检查。</li></ul><h3 id="group_concat_max_len" style="position:relative"><a href="#group_concat_max_len" aria-label="group_concat_max_len permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>group_concat_max_len</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1024</code></li><li>取值范围:<code>[4, 18446744073709551615]</code></li><li>表示 <code>GROUP_CONCAT()</code> 函数中,项目的最大缓冲区大小。</li></ul><h3 id="have_openssl" style="position:relative"><a href="#have_openssl" aria-label="have_openssl permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>have_openssl</code></h3><ul><li>作用域:NONE</li><li>类型:布尔型</li><li>默认值:<code>DISABLED</code></li><li>用于 MySQL 兼容性的只读变量。当服务器启用 TLS 时,服务器将其设置为 <code>YES</code>。</li></ul><h3 id="have_ssl" style="position:relative"><a href="#have_ssl" aria-label="have_ssl permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>have_ssl</code></h3><ul><li>作用域:NONE</li><li>类型:布尔型</li><li>默认值:<code>DISABLED</code></li><li>用于 MySQL 兼容性的只读变量。当服务器启用 TLS 时,服务器将其设置为 <code>YES</code>。</li></ul><h3 id="hostname" style="position:relative"><a href="#hostname" aria-label="hostname permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>hostname</code></h3><ul><li>作用域:NONE</li><li>默认值:(系统主机名)</li><li>这个变量一个只读变量,表示 TiDB server 的主机名。</li></ul><h3 id="identity-span-classversion-mark从-v530-版本开始引入span" style="position:relative"><a href="#identity-span-classversion-mark%E4%BB%8E-v530-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="identity span classversion mark从 v530 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>identity</code> <span class="version-mark">从 v5.3.0 版本开始引入</span></h3><ul><li>该变量为变量 <a href="#last_insert_id-%E4%BB%8E-v530-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>last_insert_id</code></a> 的别名。</li></ul><h3 id="init_connect" style="position:relative"><a href="#init_connect" aria-label="init_connect permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>init_connect</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:""</li><li>用户首次连接到 TiDB 服务器时,<code>init_connect</code> 特性允许 TiDB 自动执行一条或多条 SQL 语句。如果你有 <code>CONNECTION_ADMIN</code> 或者 <code>SUPER</code> 权限,这些 SQL 语句将不会被自动执行。如果这些语句执行报错,你的用户连接将被终止。</li></ul><h3 id="innodb_lock_wait_timeout" style="position:relative"><a href="#innodb_lock_wait_timeout" aria-label="innodb_lock_wait_timeout permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>innodb_lock_wait_timeout</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>50</code></li><li>范围:<code>[1, 3600]</code></li><li>单位:秒</li><li>悲观事务语句等锁时间。</li></ul><h3 id="interactive_timeout" style="position:relative"><a href="#interactive_timeout" aria-label="interactive_timeout permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>interactive_timeout</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>28800</code></li><li>范围:<code>[1, 31536000]</code></li><li>单位:秒</li><li>该变量表示交互式用户会话的空闲超时。交互式用户会话是指使用 <code>CLIENT_INTERACTIVE</code> 选项调用 <a href="https://dev.mysql.com/doc/c-api/5.7/en/mysql-real-connect.html" target="_blank" referrerpolicy="no-referrer-when-downgrade"><code>mysql_real_connect()</code></a> API 建立的会话(例如:MySQL shell 和 MySQL client)。该变量与 MySQL 完全兼容。</li></ul><h3 id="last_insert_id-span-classversion-mark从-v530-版本开始引入span" style="position:relative"><a href="#last_insert_id-span-classversion-mark%E4%BB%8E-v530-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="last_insert_id span classversion mark从 v530 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>last_insert_id</code> <span class="version-mark">从 v5.3.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>取值范围:<code>[0, 9223372036854775807]</code></li><li>返回由 <code>INSERT</code> 语句产生的最新 <code>AUTO_INSCRENT</code> 或者 <code>AUTO_RANDOM</code> 值,与 <code>LAST_INSERT_ID()</code> 的返回的结果相同。与 MySQL 中的 <code>last_insert_id</code> 一致。</li></ul><h3 id="last_plan_from_binding-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#last_plan_from_binding-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="last_plan_from_binding span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>last_plan_from_binding</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量用来显示上一条执行的语句所使用的执行计划是否来自 binding 的<a href="/zh/tidb/stable/sql-plan-management">执行计划</a>。</li></ul><h3 id="last_plan_from_cache-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#last_plan_from_cache-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="last_plan_from_cache span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>last_plan_from_cache</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来显示上一个 <code>execute</code> 语句所使用的执行计划是不是直接从 plan cache 中取出来的。</li></ul><h3 id="last_sql_use_alloc-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#last_sql_use_alloc-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="last_sql_use_alloc span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>last_sql_use_alloc</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>默认值:<code>OFF</code></li><li>这个变量是一个只读变量,用来显示上一个语句是否使用了缓存的 Chunk 对象 (Chunk allocation)。</li></ul><h3 id="license" style="position:relative"><a href="#license" aria-label="license permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>license</code></h3><ul><li>作用域:NONE</li><li>默认值:<code>Apache License 2.0</code></li><li>这个变量表示 TiDB 服务器的安装许可证。</li></ul><h3 id="log_bin" style="position:relative"><a href="#log_bin" aria-label="log_bin permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>log_bin</code></h3><ul><li>作用域:NONE</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量表示是否使用 <a href="/zh/tidb/stable/tidb-binlog-overview">TiDB Binlog</a>。</li></ul><h3 id="max_connections" style="position:relative"><a href="#max_connections" aria-label="max_connections permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>max_connections</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>取值范围:<code>[0, 100000]</code></li><li>该变量表示 TiDB 中同时允许的最大客户端连接数,用于资源控制。</li><li>默认情况下,该变量值为 <code>0</code> 表示不限制客户端连接数。当本变量的值大于 <code>0</code> 且客户端连接数到达此值时,TiDB 服务端将会拒绝新的客户端连接。</li></ul><h3 id="max_execution_time" style="position:relative"><a href="#max_execution_time" aria-label="max_execution_time permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>max_execution_time</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 2147483647]</code></li><li>单位:毫秒</li><li>语句最长执行时间。默认值 (0) 表示无限制。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li><code>max_execution_time</code> 目前只用于控制只读语句的最大执行时长,实际精度在 100ms 级别,而非更准确的毫秒级别。</li><li>对于使用了 <a href="/zh/tidb/stable/optimizer-hints#max_execution_timen"><code>MAX_EXECUTION_TIME</code></a> Hint 的 SQL 语句,这些语句的最长执行时间将不受该变量限制,而是由该 Hint 进行限制。你也可以使用该 Hint 来创建 SQL 绑定,详情请参考 <a href="/zh/tidb/stable/sql-faq#如何阻止特定的-sql-语句执行或者将某个-sql-语句加入黑名单">SQL 操作常见问题</a>。</li></ul></div></div></div><h3 id="max_prepared_stmt_count" style="position:relative"><a href="#max_prepared_stmt_count" aria-label="max_prepared_stmt_count permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>max_prepared_stmt_count</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>范围:<code>[-1, 1048576]</code></li><li>指定当前实例中 <a href="/zh/tidb/stable/sql-statement-prepare"><code>PREPARE</code></a> 语句的最大数量。</li><li>值为 <code>-1</code> 时表示不对实例中的 <code>PREPARE</code> 语句数量进行限制。</li><li>如果将变量值设为超过上限 <code>1048576</code>,则使用上限值 <code>1048576</code>:</li></ul><pre><code class="language-sql">mysql> SET GLOBAL max_prepared_stmt_count = 1048577; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> SHOW WARNINGS; +---------+------+--------------------------------------------------------------+ | Level | Code | Message | +---------+------+--------------------------------------------------------------+ | Warning | 1292 | Truncated incorrect max_prepared_stmt_count value: '1048577' | +---------+------+--------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> SHOW GLOBAL VARIABLES LIKE 'max_prepared_stmt_count'; +-------------------------+---------+ | Variable_name | Value | +-------------------------+---------+ | max_prepared_stmt_count | 1048576 | +-------------------------+---------+ 1 row in set (0.00 sec) </code></pre><h3 id="max_allowed_packet-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#max_allowed_packet-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="max_allowed_packet span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>max_allowed_packet</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>67108864</code></li><li>取值范围:<code>[1024, 1073741824]</code></li><li>该变量取值应为 1024 的整数倍。若取值无法被 1024 整除,则会提示 warning 并向下取整。例如设置为 1025 时,则 TiDB 中的实际取值为 1024。</li><li>服务器端和客户端在一次传送数据包的过程中所允许最大的数据包大小,单位为字节。</li><li>该变量的行为与 MySQL 兼容。</li></ul><h3 id="mpp_exchange_compression_mode-span-classversion-mark从-v660-版本开始引入span" style="position:relative"><a href="#mpp_exchange_compression_mode-span-classversion-mark%E4%BB%8E-v660-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="mpp_exchange_compression_mode span classversion mark从 v660 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>mpp_exchange_compression_mode</code> <span class="version-mark">从 v6.6.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>UNSPECIFIED</code></li><li>可选值:<code>NONE</code>,<code>FAST</code>,<code>HIGH_COMPRESSION</code>,<code>UNSPECIFIED</code></li><li>该变量用于选择 MPP Exchange 算子的数据压缩模式,当 TiDB 选择版本号为 <code>1</code> 的 MPP 执行计划时生效。该变量值的含义如下:<ul><li><code>UNSPECIFIED</code>:表示未指定,TiDB 将自动选择压缩模式,当前 TiDB 自动选择 <code>FAST</code> 模式</li><li><code>NONE</code>:不使用数据压缩</li><li><code>FAST</code>:快速模式,整体性能较好,压缩比小于 <code>HIGH_COMPRESSION</code></li><li><code>HIGH_COMPRESSION</code>:高压缩比模式</li></ul></li></ul><h3 id="mpp_version-span-classversion-mark从-v660-版本开始引入span" style="position:relative"><a href="#mpp_version-span-classversion-mark%E4%BB%8E-v660-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="mpp_version span classversion mark从 v660 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>mpp_version</code> <span class="version-mark">从 v6.6.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>UNSPECIFIED</code></li><li>可选值:<code>UNSPECIFIED</code>,<code>0</code>,<code>1</code></li><li>该变量用于指定不同版本的 MPP 执行计划。指定后,TiDB 会选择指定版本的 MPP 执行计划。该变量值含义如下:<ul><li><code>UNSPECIFIED</code>:表示未指定,此时 TiDB 自动选择最新版本 <code>1</code>。</li><li><code>0</code>:兼容所有 TiDB 集群版本,MPP 版本大于 <code>0</code> 的新特性均不会生效。</li><li><code>1</code>:从 v6.6.0 版本开始引入,用于开启 TiFlash 带压缩的数据交换,详情参见 <a href="/zh/tidb/stable/explain-mpp#mpp-version-和-exchange-数据压缩">MPP Version 和 Exchange 数据压缩</a>。</li></ul></li></ul><h3 id="password_history-span-classversion-mark从-v650-版本开始引入span" style="position:relative"><a href="#password_history-span-classversion-mark%E4%BB%8E-v650-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="password_history span classversion mark从 v650 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>password_history</code> <span class="version-mark">从 v6.5.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 4294967295]</code></li><li>该变量用于建立密码重用策略,使 TiDB 基于密码更改次数限制密码的重复使用。该变量默认值为 <code>0</code>,表示禁用基于密码更改次数的密码重用策略。当设置该变量为一个正整数 N 时,表示不允许重复使用最近 N 次使用过的密码。</li></ul><h3 id="password_reuse_interval-span-classversion-mark从-v650-版本开始引入span" style="position:relative"><a href="#password_reuse_interval-span-classversion-mark%E4%BB%8E-v650-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="password_reuse_interval span classversion mark从 v650 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>password_reuse_interval</code> <span class="version-mark">从 v6.5.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 4294967295]</code></li><li>该变量用于建立密码重用策略,使 TiDB 基于经过时间限制密码重复使用。该变量默认值为 0,表示禁用基于密码经过时间的密码重用策略。当设置该变量为一个正整数 N 时,表示不允许重复使用最近 N 天内使用过的密码。</li></ul><h3 id="plugin_dir" style="position:relative"><a href="#plugin_dir" aria-label="plugin_dir permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>plugin_dir</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>默认值:""</li><li>指定加载插件的目录。</li></ul><h3 id="plugin_load" style="position:relative"><a href="#plugin_load" aria-label="plugin_load permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>plugin_load</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>默认值:""</li><li>指定 TiDB 启动时加载的插件,多个插件之间用逗号(,)分隔。</li></ul><h3 id="port" style="position:relative"><a href="#port" aria-label="port permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>port</code></h3><ul><li>作用域:NONE</li><li>类型:整数型</li><li>默认值:<code>4000</code></li><li>范围:<code>[0, 65535]</code></li><li>使用 MySQL 协议时 tidb-server 监听的端口。</li></ul><h3 id="rand_seed1" style="position:relative"><a href="#rand_seed1" aria-label="rand_seed1 permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>rand_seed1</code></h3><ul><li>作用域:SESSION</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 2147483647]</code></li><li>该变量用于为 SQL 函数 <code>RAND()</code> 中使用的随机值生成器添加种子。</li><li>该变量的行为与 MySQL 兼容。</li></ul><h3 id="rand_seed2" style="position:relative"><a href="#rand_seed2" aria-label="rand_seed2 permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>rand_seed2</code></h3><ul><li>作用域:SESSION</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 2147483647]</code></li><li>该变量用于为 SQL 函数 <code>RAND()</code> 中使用的随机值生成器添加种子。</li><li>该变量的行为与 MySQL 兼容。</li></ul><h3 id="require_secure_transport-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#require_secure_transport-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="require_secure_transport span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>require_secure_transport</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量控制是否所有 TiDB 的连接都在本地 socket 上进行通信,或使用 TLS。详情见<a href="/zh/tidb/stable/enable-tls-between-clients-and-servers">为 TiDB 客户端服务端间通信开启加密传输</a>。</li><li>该变量设置为 <code>ON</code> 时,必须使用开启 TLS 的会话连接到 TiDB,防止在 TLS 配置不正确时出现锁定的情况。</li><li>在 v6.1.0 之前这个开关通过 TiDB 配置文件 (<code>security.require-secure-transport</code>) 进行配置,升级到 v6.1.0 时会自动继承原有设置。</li></ul><h3 id="skip_name_resolve-span-classversion-mark从-v520-版本开始引入span" style="position:relative"><a href="#skip_name_resolve-span-classversion-mark%E4%BB%8E-v520-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="skip_name_resolve span classversion mark从 v520 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>skip_name_resolve</code> <span class="version-mark">从 v5.2.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量控制 <code>tidb-server</code> 实例是否将主机名作为连接握手的一部分来解析。</li><li>当 DNS 不可靠时,可以启用该变量来提高网络性能。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>当 <code>skip_name_resolve</code> 设置为 <code>ON</code> 时,身份信息中包含主机名的用户将无法登录服务器。例如:</p><pre><code class="language-sql">CREATE USER 'appuser'@'apphost' IDENTIFIED BY 'app-password'; </code></pre><p>该示例中,建议将 <code>apphost</code> 替换为 IP 地址或通配符(<code>%</code>)。</p></div></div></div><h3 id="socket" style="position:relative"><a href="#socket" aria-label="socket permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>socket</code></h3><ul><li>作用域:NONE</li><li>默认值:""</li><li>使用 MySQL 协议时,tidb-server 所监听的本地 unix 套接字文件。</li></ul><h3 id="sql_log_bin" style="position:relative"><a href="#sql_log_bin" aria-label="sql_log_bin permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>sql_log_bin</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>表示是否将更改写入 TiDB Binlog。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>不建议将 <code>sql_log_bin</code> 设置为全局变量,因为 TiDB 的未来版本可能只允许将其设置为会话变量。</p></div></div></div><h3 id="sql_mode" style="position:relative"><a href="#sql_mode" aria-label="sql_mode permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>sql_mode</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION</code></li><li>这个变量控制许多 MySQL 兼容行为。详情见 <a href="/zh/tidb/stable/sql-mode">SQL 模式</a>。</li></ul><h3 id="sql_require_primary_key-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#sql_require_primary_key-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="sql_require_primary_key span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>sql_require_primary_key</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制表是否必须有主键。启用该变量后,如果在没有主键的情况下创建或修改表,将返回错误。</li><li>该功能基于 MySQL 8.0 的特性 <a href="https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_require_primary_key" target="_blank" referrerpolicy="no-referrer-when-downgrade"><code>sql_require_primary_key</code></a>。</li><li>强烈推荐在使用 TiCDC 时启用该变量,因为同步数据变更至 MySQL sink 时要求表必须有主键。</li></ul><h3 id="sql_select_limit-span-classversion-mark从-v402-版本开始引入span" style="position:relative"><a href="#sql_select_limit-span-classversion-mark%E4%BB%8E-v402-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="sql_select_limit span classversion mark从 v402 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>sql_select_limit</code> <span class="version-mark">从 v4.0.2 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>18446744073709551615</code></li><li>范围:<code>[0, 18446744073709551615]</code></li><li>单位:行</li><li><code>SELECT</code> 语句返回的最大行数。</li></ul><h3 id="ssl_ca" style="position:relative"><a href="#ssl_ca" aria-label="ssl_ca permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>ssl_ca</code></h3><ul><li>作用域:NONE</li><li>默认值:""</li><li>证书颁发机构 (CA) 文件的位置。若文件不存在,则变量值为空。该变量的值由 TiDB 配置项 <a href="/zh/tidb/stable/tidb-configuration-file#ssl-ca"><code>ssl-ca</code></a> 定义。</li></ul><h3 id="ssl_cert" style="position:relative"><a href="#ssl_cert" aria-label="ssl_cert permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>ssl_cert</code></h3><ul><li>作用域:NONE</li><li>默认值:""</li><li>用于 SSL/TLS 连接的证书文件的位置。若文件不存在,则变量值为空。该变量的值由 TiDB 配置项 <a href="/zh/tidb/stable/tidb-configuration-file#ssl-cert"><code>ssl-cert</code></a> 定义。</li></ul><h3 id="ssl_key" style="position:relative"><a href="#ssl_key" aria-label="ssl_key permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>ssl_key</code></h3><ul><li>作用域:NONE</li><li>默认值:""</li><li>用于 SSL/TLS 连接的私钥文件的位置。若文件不存在,则变量值为空。该变量的值由 TiDB 配置项 <a href="/zh/tidb/stable/tidb-configuration-file#ssl-cert"><code>ssl-key</code></a> 定义。</li></ul><h3 id="system_time_zone" style="position:relative"><a href="#system_time_zone" aria-label="system_time_zone permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>system_time_zone</code></h3><ul><li>作用域:NONE</li><li>默认值:(随系统)</li><li>该变量显示首次引导启动 TiDB 时的系统时区。另请参阅 <a href="#time_zone"><code>time_zone</code></a>。</li></ul><h3 id="tidb_adaptive_closest_read_threshold-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_adaptive_closest_read_threshold-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_adaptive_closest_read_threshold span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_adaptive_closest_read_threshold</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>4096</code></li><li>取值范围:<code>[0, 9223372036854775807]</code></li><li>单位:字节</li><li>这个变量用于控制当 <a href="#tidb_replica_read-%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>replica-read</code></a> 设置为 <code>closest-adaptive</code> 时,优先将读请求发送至 TiDB server 所在区域副本的阈值。当读请求预估的返回结果的大小超过此阈值时,TiDB 会将读请求优先发送至同一可用区的副本,否则会发送至 leader 副本。</li></ul><h3 id="tidb_allow_batch_cop-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_allow_batch_cop-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_allow_batch_cop span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_allow_batch_cop</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li><p>作用域:SESSION | GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:整数型</p></li><li><p>默认值:<code>1</code></p></li><li><p>范围:<code>[0, 2]</code></p></li><li><p>这个变量用于控制 TiDB 向 TiFlash 发送 coprocessor 请求的方式,有以下几种取值:</p><ul><li>0:从不批量发送请求</li><li>1:aggregation 和 join 的请求会进行批量发送</li><li>2:所有的 cop 请求都会批量发送</li></ul></li></ul><h3 id="tidb_allow_fallback_to_tikv-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_allow_fallback_to_tikv-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_allow_fallback_to_tikv span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_allow_fallback_to_tikv</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:""</li><li>这个变量表示将 TiKV 作为备用存储引擎的存储引擎列表。当该列表中的存储引擎发生故障导致 SQL 语句执行失败时,TiDB 会使用 TiKV 作为存储引擎再次执行该 SQL 语句。目前支持设置该变量为 "" 或者 "tiflash"。如果设置该变量为 "tiflash",当 TiFlash 返回超时错误(对应的错误码为 ErrTiFlashServerTimeout)时,TiDB 会使用 TiKV 作为存储引擎再次执行该 SQL 语句。</li></ul><h3 id="tidb_allow_function_for_expression_index-span-classversion-mark从-v520-版本开始引入span" style="position:relative"><a href="#tidb_allow_function_for_expression_index-span-classversion-mark%E4%BB%8E-v520-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_allow_function_for_expression_index span classversion mark从 v520 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_allow_function_for_expression_index</code> <span class="version-mark">从 v5.2.0 版本开始引入</span></h3><ul><li>作用域:NONE</li><li>默认值:<code>json_array</code>、<code>json_array_append</code>、<code>json_array_insert</code>、<code>json_contains</code>、<code>json_contains_path</code>、<code>json_depth</code>、<code>json_extract</code>、<code>json_insert</code>、<code>json_keys</code>、<code>json_length</code>、<code>json_merge_patch</code>、<code>json_merge_preserve</code>、<code>json_object</code>、<code>json_pretty</code>、<code>json_quote</code>、<code>json_remove</code>、<code>json_replace</code>、<code>json_search</code>、<code>json_set</code>、<code>json_storage_size</code>、<code>json_type</code>、<code>json_unquote</code>、<code>json_valid</code>、<code>lower</code>、<code>md5</code>、<code>reverse</code>、<code>tidb_shard</code>、<code>upper</code>、<code>vitess_hash</code></li><li>这个变量用于显示创建表达式索引所允许使用的函数。</li></ul><h3 id="tidb_allow_mpp-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_allow_mpp-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_allow_mpp span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_allow_mpp</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于控制是否使用 TiFlash 的 MPP 模式执行查询,可以设置的值包括:<ul><li>0 或 OFF,代表从不使用 MPP 模式</li><li>1 或 ON,代表由优化器根据代价估算选择是否使用 MPP 模式(默认)</li></ul></li></ul><p>MPP 是 TiFlash 引擎提供的分布式计算框架,允许节点之间的数据交换并提供高性能、高吞吐的 SQL 算法。MPP 模式选择的详细说明参见<a href="/zh/tidb/stable/use-tiflash-mpp-mode#控制是否选择-mpp-模式">控制是否选择 MPP 模式</a>。</p><h3 id="tidb_allow_remove_auto_inc-span-classversion-mark从-v2118-和-v304-版本开始引入span" style="position:relative"><a href="#tidb_allow_remove_auto_inc-span-classversion-mark%E4%BB%8E-v2118-%E5%92%8C-v304-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_allow_remove_auto_inc span classversion mark从 v2118 和 v304 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_allow_remove_auto_inc</code> <span class="version-mark">从 v2.1.18 和 v3.0.4 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来控制是否允许通过 <code>ALTER TABLE MODIFY</code> 或 <code>ALTER TABLE CHANGE</code> 来移除某个列的 <code>AUTO_INCREMENT</code> 属性。默认 (<code>OFF</code>) 为不允许。</li></ul><h3 id="tidb_analyze_partition_concurrency" style="position:relative"><a href="#tidb_analyze_partition_concurrency" aria-label="tidb_analyze_partition_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_analyze_partition_concurrency</code></h3><div class="MuiBox-root css-1weqspv"><style data-emotion="css 1rl2db2">.css-1rl2db2{font-size:0.875rem;line-height:1.25rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:rgb(95, 33, 32);background-color:rgb(253, 237, 237);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:6px 16px;}.css-1rl2db2 .MuiAlert-icon{color:#ef5350;}</style><style data-emotion="css 21rxh6">.css-21rxh6{background-color:#fff;color:rgba(0, 0, 0, 0.87);-webkit-transition:box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;transition:box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;border-radius:4px;box-shadow:none;font-size:0.875rem;line-height:1.25rem;font-family:"Helvetica Neue","sans-serif";font-weight:400;font-style:normal;color:rgb(95, 33, 32);background-color:rgb(253, 237, 237);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:6px 16px;}.css-21rxh6 .MuiAlert-icon{color:#ef5350;}</style><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>当前版本中该变量控制的功能尚未完全生效,请保留默认值。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>1</code></li><li>这个变量用于 TiDB analyze 分区表时,对分区表统计信息进行读写的并发度。</li></ul><h3 id="tidb_analyze_version-span-classversion-mark从-v510-版本开始引入span" style="position:relative"><a href="#tidb_analyze_version-span-classversion-mark%E4%BB%8E-v510-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_analyze_version span classversion mark从 v510 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_analyze_version</code> <span class="version-mark">从 v5.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>2</code></li><li>范围:<code>[1, 2]</code></li><li>这个变量用于控制 TiDB 收集统计信息的行为。</li><li>在 v5.3.0 及之后的版本中,该变量的默认值为 <code>2</code>,具体可参照<a href="/zh/tidb/stable/statistics">统计信息简介</a>文档。如果从 v5.3.0 之前版本的集群升级至 v5.3.0 及之后的版本,<code>tidb_analyze_version</code> 的默认值不发生变化。</li></ul><h3 id="tidb_auto_analyze_end_time" style="position:relative"><a href="#tidb_auto_analyze_end_time" aria-label="tidb_auto_analyze_end_time permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_auto_analyze_end_time</code></h3><ul><li><p>作用域:GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:时间</p></li><li><p>默认值:<code>23:59 +0000</code></p></li><li><p>这个变量用来设置一天中允许自动 ANALYZE 更新统计信息的结束时间。例如,只允许在 UTC 时间的凌晨 1:00 至 3:00 之间自动更新统计信息,可以设置如下:</p><ul><li><code>tidb_auto_analyze_start_time='01:00 +0000'</code></li><li><code>tidb_auto_analyze_end_time='03:00 +0000'</code></li></ul></li></ul><h3 id="tidb_auto_analyze_partition_batch_size-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_auto_analyze_partition_batch_size-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_auto_analyze_partition_batch_size span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_auto_analyze_partition_batch_size</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>1</code></li><li>范围:<code>[1, 1024]</code></li><li>用于设置 TiDB <a href="/zh/tidb/stable/statistics#自动更新">自动 analyze</a> 分区表(即自动收集分区表上的统计信息)时,每次同时 analyze 分区的个数。</li><li>若该变量值小于分区表的分区数,则 TiDB 会分多批自动 analyze 该分区表的所有分区。若该变量值大于等于分区表的分区数,则 TiDB 会同时 analyze 该分区表的所有分区。</li><li>若分区表个数远大于该变量值,且自动 analyze 花费时间较长,可调大该参数的值以减少耗时。</li></ul><h3 id="tidb_auto_analyze_ratio" style="position:relative"><a href="#tidb_auto_analyze_ratio" aria-label="tidb_auto_analyze_ratio permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_auto_analyze_ratio</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>默认值:<code>0.5</code></li><li>范围:<code>[0, 18446744073709551615]</code></li><li>这个变量用来设置 TiDB 在后台自动执行 <a href="/zh/tidb/stable/sql-statement-analyze-table"><code>ANALYZE TABLE</code></a> 更新统计信息的阈值。<code>0.5</code> 指的是当表中超过 50% 的行被修改时,触发自动 ANALYZE 更新。可以指定 <code>tidb_auto_analyze_start_time</code> 和 <code>tidb_auto_analyze_end_time</code> 来限制自动 ANALYZE 的时间</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>当系统变量 <code>tidb_enable_auto_analyze</code> 设置为 <code>ON</code> 时,TiDB 才会触发 <code>auto_analyze</code>。</p></div></div></div><h3 id="tidb_auto_analyze_start_time" style="position:relative"><a href="#tidb_auto_analyze_start_time" aria-label="tidb_auto_analyze_start_time permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_auto_analyze_start_time</code></h3><ul><li><p>作用域:GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:时间</p></li><li><p>默认值:<code>00:00 +0000</code></p></li><li><p>这个变量用来设置一天中允许自动 ANALYZE 更新统计信息的开始时间。例如,只允许在 UTC 时间的凌晨 1:00 至 3:00 之间自动更新统计信息,可以设置如下:</p><ul><li><code>tidb_auto_analyze_start_time='01:00 +0000'</code></li><li><code>tidb_auto_analyze_end_time='03:00 +0000'</code></li></ul></li></ul><h3 id="tidb_auto_build_stats_concurrency-span-classversion-mark从-v650-版本开始引入span" style="position:relative"><a href="#tidb_auto_build_stats_concurrency-span-classversion-mark%E4%BB%8E-v650-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_auto_build_stats_concurrency span classversion mark从 v650 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_auto_build_stats_concurrency</code> <span class="version-mark">从 v6.5.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1</code></li><li>范围:<code>[1, 256]</code></li><li>这个变量用来设置执行统计信息自动更新的并发度。</li></ul><h3 id="tidb_backoff_lock_fast" style="position:relative"><a href="#tidb_backoff_lock_fast" aria-label="tidb_backoff_lock_fast permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_backoff_lock_fast</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>10</code></li><li>范围:<code>[1, 2147483647]</code></li><li>这个变量用来设置读请求遇到锁的 backoff 时间。</li></ul><h3 id="tidb_backoff_weight" style="position:relative"><a href="#tidb_backoff_weight" aria-label="tidb_backoff_weight permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_backoff_weight</code></h3><ul><li><p>作用域:SESSION | GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:整数型</p></li><li><p>默认值:<code>2</code></p></li><li><p>范围:<code>[0, 2147483647]</code></p></li><li><p>这个变量用来给 TiDB 的 <code>backoff</code> 最大时间增加权重,即内部遇到网络或其他组件 (TiKV, PD) 故障时,发送重试请求的最大重试时间。可以通过这个变量来调整最大重试时间,最小值为 1。</p><p> 例如,TiDB 向 PD 取 TSO 的基础超时时间是 15 秒,当 <code>tidb_backoff_weight = 2</code> 时,取 TSO 的最大超时时间为:基础时间 <!-- -->*<!-- --> 2 等于 30 秒。</p><p> 在网络环境较差的情况下,适当增大该变量值可以有效缓解因为超时而向应用端报错的情况;而如果应用端希望更快地接到报错信息,则应该尽量减小该变量的值。</p></li></ul><h3 id="tidb_batch_commit" style="position:relative"><a href="#tidb_batch_commit" aria-label="tidb_batch_commit permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_batch_commit</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p><strong>不建议</strong>开启此变量。</p></div></div></div><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量控制是否启用已废弃的 batch-commit 特性。当该变量开启时,事务可能会通过分组一些语句被拆分为多个事务,并被非原子地提交。不推荐使用这种方式。</li></ul><h3 id="tidb_batch_delete" style="position:relative"><a href="#tidb_batch_delete" aria-label="tidb_batch_delete permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_batch_delete</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>该变量与废弃的 batch-dml 特性相关,可能会导致数据损坏。因此,不建议开启该变量来使用 batch-dml。作为替代,请使用<a href="/zh/tidb/stable/non-transactional-dml">非事务 DML 语句</a>。</p></div></div></div><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量控制是否启用已废弃的 batch-dml 特性中的 batch-delete 特性。当该变量开启时,<code>DELETE</code> 语句可能会被拆分为多个事务,并被非原子地提交。要使该特性生效,还需要开启 <code>tidb_enable_batch_dml</code> 并将 <code>tidb_dml_batch_size</code> 的值设置为正数。不推荐使用这种方式。</li></ul><h3 id="tidb_batch_insert" style="position:relative"><a href="#tidb_batch_insert" aria-label="tidb_batch_insert permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_batch_insert</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>该变量与废弃的 batch-dml 特性相关,可能会导致数据损坏。因此,不建议开启该变量来使用 batch-dml。作为替代,请使用<a href="/zh/tidb/stable/non-transactional-dml">非事务 DML 语句</a>。</p></div></div></div><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量控制是否启用已废弃的 batch-dml 特性中的 batch-insert 特性。当该变量开启时,<code>INSERT</code> 语句可能会被拆分为多个事务,并被非原子地提交。要使该特性生效,还需要开启 <code>tidb_enable_batch_dml</code> 并将 <code>tidb_dml_batch_size</code> 的值设置为正数。不推荐使用这种方式。</li></ul><h3 id="tidb_batch_pending_tiflash_count-span-classversion-mark从-v60-版本开始引入span" style="position:relative"><a href="#tidb_batch_pending_tiflash_count-span-classversion-mark%E4%BB%8E-v60-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_batch_pending_tiflash_count span classversion mark从 v60 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_batch_pending_tiflash_count</code> <span class="version-mark">从 v6.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>4000</code></li><li>范围:<code>[0, 4294967295]</code></li><li>使用 <code>ALTER DATABASE SET TIFLASH REPLICA</code> 语句为 TiFlash 添加副本时,能容许的不可用表的个数上限。如果超过该上限,则会停止或者以非常慢的速度为库中的剩余表设置 TiFlash 副本。</li></ul><h3 id="tidb_broadcast_join_threshold_count-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_broadcast_join_threshold_count-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_broadcast_join_threshold_count span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_broadcast_join_threshold_count</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>10240</code></li><li>范围:<code>[0, 9223372036854775807]</code></li><li>单位:行</li><li>如果 join 的对象为子查询,优化器无法估计子查询结果集大小,在这种情况下通过结果集行数判断。如果子查询的行数估计值小于该变量,则选择 Broadcast Hash Join 算法。否则选择 Shuffled Hash Join 算法。</li><li>开启 <a href="/zh/tidb/stable/system-variables#tidb_prefer_broadcast_join_by_exchange_data_size-从-v710-版本开始引入"><code>tidb_prefer_broadcast_join_by_exchange_data_size</code></a> 功能后,该变量将不再生效。</li></ul><h3 id="tidb_broadcast_join_threshold_size-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_broadcast_join_threshold_size-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_broadcast_join_threshold_size span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_broadcast_join_threshold_size</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>104857600</code> (100 MiB)</li><li>范围:<code>[0, 9223372036854775807]</code></li><li>单位:字节</li><li>如果表大小(字节数)小于该值,则选择 Broadcast Hash Join 算法。否则选择 Shuffled Hash Join 算法。</li><li>开启 <a href="/zh/tidb/stable/system-variables#tidb_prefer_broadcast_join_by_exchange_data_size-从-v710-版本开始引入"><code>tidb_prefer_broadcast_join_by_exchange_data_size</code></a> 功能后,该变量将不再生效。</li></ul><h3 id="tidb_build_stats_concurrency" style="position:relative"><a href="#tidb_build_stats_concurrency" aria-label="tidb_build_stats_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_build_stats_concurrency</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>单位:线程</li><li>默认值:<code>4</code></li><li>取值范围:<code>[1, 256]</code></li><li>这个变量用来设置 ANALYZE 语句执行时并发度。</li><li>当这个变量被设置得更大时,会对其它的查询语句执行性能产生一定影响。</li></ul><h3 id="tidb_capture_plan_baselines-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_capture_plan_baselines-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_capture_plan_baselines span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_capture_plan_baselines</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制是否开启<a href="/zh/tidb/stable/sql-plan-management#自动捕获绑定-baseline-capturing">自动捕获绑定</a>功能。该功能依赖 Statement Summary,因此在使用自动绑定之前需打开 Statement Summary 开关。</li><li>开启该功能后会定期遍历一次 Statement Summary 中的历史 SQL 语句,并为至少出现两次的 SQL 语句自动创建绑定。</li></ul><h3 id="tidb_cdc_write_source-span-classversion-mark从-v650-版本开始引入span" style="position:relative"><a href="#tidb_cdc_write_source-span-classversion-mark%E4%BB%8E-v650-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_cdc_write_source span classversion mark从 v650 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_cdc_write_source</code> <span class="version-mark">从 v6.5.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>是否持久化到集群:否</li><li>类型:整数型</li><li>默认值: <code>0</code></li><li>范围:<code>[0, 15]</code></li><li>当变量非 <code>0</code> 时,该 SESSION 写入的数据将被视为是由 TiCDC 写入的。这个变量仅由 TiCDC 设置,任何时候都不应该手动调整该变量。</li></ul><h3 id="tidb_check_mb4_value_in_utf8" style="position:relative"><a href="#tidb_check_mb4_value_in_utf8" aria-label="tidb_check_mb4_value_in_utf8 permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_check_mb4_value_in_utf8</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>设置该变量为 <code>ON</code> 可强制只存储<a href="https://zh.wikipedia.org/zh-hans/Unicode字符平面映射" target="_blank" referrerpolicy="no-referrer-when-downgrade">基本多文种平面 (BMP)</a> 编码区段内的 <code>utf8</code> 字符值。若要存储 BMP 区段外的 <code>utf8</code> 值,推荐使用 <code>utf8mb4</code> 字符集。</li><li>早期版本的 TiDB 中 (v2.1.x),<code>utf8</code> 检查更为宽松。如果你的 TiDB 集群是从早期版本升级的,推荐关闭该变量,详情参阅<a href="/zh/tidb/stable/upgrade-faq">升级与升级后常见问题</a>。</li></ul><h3 id="tidb_committer_concurrency-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_committer_concurrency-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_committer_concurrency span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_committer_concurrency</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>128</code></li><li>范围:<code>[1, 10000]</code></li><li>在单个事务的提交阶段,用于执行提交操作相关请求的 goroutine 数量。</li><li>若提交的事务过大,事务提交时的流控队列等待耗时可能会过长。此时,可以通过调大该配置项来加速提交。</li><li>在 v6.1.0 之前这个开关通过 TiDB 配置文件 (<code>performance.committer-concurrency</code>) 进行配置,升级到 v6.1.0 时会自动继承原有设置。</li></ul><h3 id="tidb_checksum_table_concurrency" style="position:relative"><a href="#tidb_checksum_table_concurrency" aria-label="tidb_checksum_table_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_checksum_table_concurrency</code></h3><ul><li>作用域:SESSION</li><li>类型:整数型</li><li>默认值:<code>4</code></li><li>取值范围:<code>[1, 256]</code></li><li>单位:线程</li><li>这个变量用来设置 <a href="/zh/tidb/stable/sql-statement-admin-checksum-table"><code>ADMIN CHECKSUM TABLE</code></a> 语句执行时扫描索引的并发度。当这个变量被设置得更大时,会对其它的查询语句执行性能产生一定影响。</li></ul><h3 id="tidb_config" style="position:relative"><a href="#tidb_config" aria-label="tidb_config permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_config</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>默认值:""</li><li>这个变量是一个只读变量,用来获取当前 TiDB Server 的配置信息。</li></ul><h3 id="tidb_constraint_check_in_place" style="position:relative"><a href="#tidb_constraint_check_in_place" aria-label="tidb_constraint_check_in_place permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_constraint_check_in_place</code></h3><ul><li><p>作用域:SESSION | GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:布尔型</p></li><li><p>默认值:<code>OFF</code></p></li><li><p>该变量仅适用于乐观事务模型。悲观事务模式中的行为由 <a href="#tidb_constraint_check_in_place_pessimistic-%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_constraint_check_in_place_pessimistic</code></a> 控制。</p></li><li><p>当这个变量设置为 <code>OFF</code> 时,唯一索引的重复值检查会被推迟到事务提交时才进行。这有助于提高性能,但对于某些应用,可能导致非预期的行为。详情见<a href="/zh/tidb/stable/constraints#乐观事务">约束</a>。</p><ul><li><p>乐观事务模型下将 <code>tidb_constraint_check_in_place</code> 设置为 <code>OFF</code>:</p><pre><code class="language-sql">create table t (i int key); insert into t values (1); begin optimistic; insert into t values (1); </code></pre><pre><code>Query OK, 1 row affected </code></pre><pre><code class="language-sql">tidb> commit; -- 事务提交时才检查 </code></pre><pre><code>ERROR 1062 : Duplicate entry '1' for key 't.PRIMARY' </code></pre></li><li><p>乐观事务模型下将 <code>tidb_constraint_check_in_place</code> 设置为 <code>ON</code>:</p><pre><code class="language-sql">set @@tidb_constraint_check_in_place=ON; begin optimistic; insert into t values (1); </code></pre><pre><code>ERROR 1062 : Duplicate entry '1' for key 't.PRIMARY' </code></pre></li></ul></li></ul><h3 id="tidb_constraint_check_in_place_pessimistic-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_constraint_check_in_place_pessimistic-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_constraint_check_in_place_pessimistic span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_constraint_check_in_place_pessimistic</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li><p>作用域:SESSION</p></li><li><p>类型:布尔型</p></li><li><p>默认值:当配置项 <a href="/zh/tidb/stable/tidb-configuration-file#constraint-check-in-place-pessimistic-从-v640-版本开始引入"><code>pessimistic-txn.constraint-check-in-place-pessimistic</code></a> 为默认值 <code>true</code> 时,该变量的默认值为 <code>ON</code>。当配置项 <a href="/zh/tidb/stable/tidb-configuration-file#constraint-check-in-place-pessimistic-从-v640-版本开始引入"><code>pessimistic-txn.constraint-check-in-place-pessimistic</code></a> 为 <code>false</code> 时,该变量的默认值为 <code>OFF</code>。</p></li><li><p>该变量仅适用于悲观事务模型。乐观事务模式中的行为由 <a href="#tidb_constraint_check_in_place"><code>tidb_constraint_check_in_place</code></a> 控制。</p></li><li><p>当这个变量设置为 <code>OFF</code> 时,唯一约束检查会被推迟到下一次需要对这个索引加锁的语句执行时,或事务提交时才进行。这有助于提高性能,但对于某些应用,可能导致非预期的行为。详情见<a href="/zh/tidb/stable/constraints#悲观事务">约束</a>。</p></li><li><p>关闭该变量可能会导致悲观事务中返回 <code>LazyUniquenessCheckFailure</code> 报错。返回该错误时,TiDB 将会回滚当前事务。</p></li><li><p>关闭该变量后,悲观事务中不支持使用 <a href="/zh/tidb/stable/sql-statement-savepoint"><code>SAVEPOINT</code></a> 功能。</p></li><li><p>关闭该变量时,commit 语句可能会报出 <code>Write conflict</code> 错误或 <code>Duplicate entry</code> 错误,两种错误都意味着事务回滚。</p><ul><li><p>悲观事务模型下将 <code>tidb_constraint_check_in_place_pessimistic</code> 设置为 <code>OFF</code>:</p><pre><code class="language-sql">set @@tidb_constraint_check_in_place_pessimistic=OFF; create table t (i int key); insert into t values (1); begin pessimistic; insert into t values (1); </code></pre><pre><code>Query OK, 1 row affected </code></pre><pre><code class="language-sql">tidb> commit; -- 事务提交时才检查 </code></pre><pre><code>ERROR 1062 : Duplicate entry '1' for key 't.PRIMARY' </code></pre></li><li><p>悲观事务模型下将 <code>tidb_constraint_check_in_place_pessimistic</code> 设置为 <code>ON</code>:</p><pre><code class="language-sql">set @@tidb_constraint_check_in_place_pessimistic=ON; begin pessimistic; insert into t values (1); </code></pre><pre><code>ERROR 1062 : Duplicate entry '1' for key 't.PRIMARY' </code></pre></li></ul></li></ul><h3 id="tidb_cost_model_version-span-classversion-mark从-v620-版本开始引入span" style="position:relative"><a href="#tidb_cost_model_version-span-classversion-mark%E4%BB%8E-v620-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_cost_model_version span classversion mark从 v620 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_cost_model_version</code> <span class="version-mark">从 v6.2.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li>自 v6.5.0 开始,新创建的 TiDB 集群默认使用 Cost Model Version 2。如果从 v6.4.0 及之前版本的集群升级到 v6.5.0 及之后的版本,<code>tidb_cost_model_version</code> 的值不发生变化。</li><li>切换代价模型版本可能会引起查询计划的变动。</li></ul></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>2</code></li><li>取值范围:<code>[1, 2]</code></li><li>可选值:<ul><li><code>1</code>:使用 Cost Model Version 1 代价模型。TiDB v6.4.0 及之前的版本默认使用 Cost Model Version 1。</li><li><code>2</code>:使用 Cost Model Version 2 代价模型。TiDB v6.5.0 正式发布了代价模型 <a href="/zh/tidb/stable/cost-model#cost-model-version-2">Cost Model Version 2</a>,在内部测试中比 Version 1 版本的代价模型更加准确。</li></ul></li><li>代价模型会影响优化器对计划的选择,具体可见<a href="/zh/tidb/stable/cost-model">代价模型</a>。</li></ul><h3 id="tidb_current_ts" style="position:relative"><a href="#tidb_current_ts" aria-label="tidb_current_ts permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_current_ts</code></h3><ul><li>作用域:SESSION</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>取值范围:<code>[0, 9223372036854775807]</code></li><li>这个变量是一个只读变量,用来获取当前事务的时间戳。</li></ul><h3 id="tidb_ddl_disk_quota-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_ddl_disk_quota-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_ddl_disk_quota span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_ddl_disk_quota</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>107374182400</code> (100 GiB)</li><li>范围:<code>[107374182400, 1125899906842624]</code> (<!-- -->[100 GiB, 1 PiB]<!-- -->)</li><li>单位:字节</li><li>这个变量仅在 <a href="#tidb_ddl_enable_fast_reorg-%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_ddl_enable_fast_reorg</code></a> 开启的情况下生效,用于设置创建索引的回填过程中本地存储空间的使用限制。</li></ul><h3 id="tidb_ddl_enable_fast_reorg-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_ddl_enable_fast_reorg-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_ddl_enable_fast_reorg span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_ddl_enable_fast_reorg</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制是否开启添加索引加速功能,来提升创建索引回填过程的速度。开启该变量对于数据量较大的表有一定的性能提升。</li><li>TiDB v7.1.0 引入了快速加索引功能的检查点机制,即使 TiDB owner 因故障重启或者切换,也能够通过自动定期保存的检查点恢复部分进度。</li><li>要验证已经完成的 <code>ADD INDEX</code> 操作是否使用了添加索引加速功能,可以执行 <a href="/zh/tidb/stable/sql-statement-admin-show-ddl#admin-show-ddl-jobs"><code>ADMIN SHOW DDL JOBS</code></a> 语句查看 <code>JOB_TYPE</code> 一列中是否含有 <code>ingest</code> 字样。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>目前,PITR 恢复会额外处理日志备份时间段内通过索引加速功能创建的索引,以达到兼容效果。详细内容请参考<a href="/zh/tidb/stable/backup-and-restore-faq#索引加速功能为什么与-pitr-功能不兼容">索引加速功能为什么与 PITR 功能不兼容</a>。</p></div></div></div><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li><p>要使用索引加速功能,你需要提供一个可写且具有足够空余空间的临时路径 <a href="/zh/tidb/stable/tidb-configuration-file#temp-dir-从-v630-版本开始引入"><code>temp-dir</code></a>。如果 <code>temp-dir</code> 无法使用,TiDB 会退回到非加速的索引创建方式。建议将 <code>temp-dir</code> 挂载在 SSD 磁盘上。</p></li><li><p>在升级到 v6.5.0 及以上版本时,请确保 TiDB 的 <a href="/zh/tidb/stable/tidb-configuration-file#temp-dir-从-v630-版本开始引入"><code>temp-dir</code></a> 路径已正确挂载了 SSD 磁盘,并确保运行 TiDB 的操作系统用户对该目录有读写权限,否则在运行时可能产生不可预知的问题。该参数是 TiDB 的配置参数,设置后需要重启 TiDB 才能生效。因此,在升级前提前进行设置,可以避免再次重启。</p></li></ul></div></div></div><h3 id="tidb_enable_dist_task-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#tidb_enable_dist_task-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_dist_task span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_dist_task</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>该功能目前为实验特性,不建议在生产环境中使用。</p></div></div></div><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制是否开启 <a href="/zh/tidb/stable/tidb-distributed-execution-framework">TiDB 后端任务分布式框架</a>。开启分布式框架后,DDL 和 Import 等后端任务将会由集群中多个 TiDB 节点共同完成。</li><li>在 TiDB v7.1.0 中,只支持分布式执行分区表的 <code>ADD INDEX</code>。</li><li>该变量由 <code>tidb_ddl_distribute_reorg</code> 改名而来。</li></ul><h3 id="tidb_ddl_error_count_limit" style="position:relative"><a href="#tidb_ddl_error_count_limit" aria-label="tidb_ddl_error_count_limit permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_ddl_error_count_limit</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>512</code></li><li>范围:<code>[0, 9223372036854775807]</code></li><li>这个变量用来控制 DDL 操作失败重试的次数。失败重试次数超过该参数的值后,会取消出错的 DDL 操作。</li></ul><h3 id="tidb_ddl_flashback_concurrency-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_ddl_flashback_concurrency-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_ddl_flashback_concurrency span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_ddl_flashback_concurrency</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>64</code></li><li>范围:<code>[1, 256]</code></li><li>这个变量用来控制 <a href="/zh/tidb/stable/sql-statement-flashback-to-timestamp"><code>FLASHBACK CLUSTER TO TIMESTAMP</code></a> 的并发数。</li></ul><h3 id="tidb_ddl_reorg_batch_size" style="position:relative"><a href="#tidb_ddl_reorg_batch_size" aria-label="tidb_ddl_reorg_batch_size permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_ddl_reorg_batch_size</code></h3><ul><li><p>作用域:GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:整数型</p></li><li><p>默认值:<code>256</code></p></li><li><p>范围:<code>[32, 10240]</code></p></li><li><p>单位:行</p></li><li><p>这个变量用来设置 DDL 操作 <code>re-organize</code> 阶段的 batch size。比如 <code>ADD INDEX</code> 操作,需要回填索引数据,通过并发 <code>tidb_ddl_reorg_worker_cnt</code> 个 worker 一起回填数据,每个 worker 以 batch 为单位进行回填。</p><ul><li>如果 <code>ADD INDEX</code> 操作时有较多 <code>UPDATE</code> 操作或者 <code>REPLACE</code> 等更新操作,batch size 越大,事务冲突的概率也会越大,此时建议调小 batch size 的值,最小值是 32。</li><li>在没有事务冲突的情况下,batch size 可设为较大值(需要参考 worker 数量,见<a href="/zh/tidb/stable/online-workloads-and-add-index-operations">线上负载与 <code>ADD INDEX</code> 相互影响测试</a>),这样回填数据的速度更快,但是 TiKV 的写入压力也会变大。</li></ul></li></ul><h3 id="tidb_ddl_reorg_priority" style="position:relative"><a href="#tidb_ddl_reorg_priority" aria-label="tidb_ddl_reorg_priority permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_ddl_reorg_priority</code></h3><ul><li>作用域:SESSION</li><li>类型:枚举型</li><li>默认值:<code>PRIORITY_LOW</code></li><li>可选值:<code>PRIORITY_LOW</code>、<code>PRIORITY_NORMAL</code>、<code>PRIORITY_HIGH</code></li><li>这个变量用来设置 <code>ADD INDEX</code> 操作 <code>re-organize</code> 阶段的执行优先级,可设置为 <code>PRIORITY_LOW</code>/<code>PRIORITY_NORMAL</code>/<code>PRIORITY_HIGH</code>。</li></ul><h3 id="tidb_ddl_reorg_worker_cnt" style="position:relative"><a href="#tidb_ddl_reorg_worker_cnt" aria-label="tidb_ddl_reorg_worker_cnt permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_ddl_reorg_worker_cnt</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>4</code></li><li>范围:<code>[1, 256]</code></li><li>单位:线程</li><li>这个变量用来设置 DDL 操作 <code>re-organize</code> 阶段的并发度。</li></ul><h3 id="tidb_default_string_match_selectivity-span-classversion-mark从-v620-版本开始引入span" style="position:relative"><a href="#tidb_default_string_match_selectivity-span-classversion-mark%E4%BB%8E-v620-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_default_string_match_selectivity span classversion mark从 v620 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_default_string_match_selectivity</code> <span class="version-mark">从 v6.2.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点型</li><li>默认值:<code>0.8</code></li><li>范围:<code>[0, 1]</code></li><li>这个变量用来设置过滤条件中的 <code>like</code>、<code>rlike</code>、<code>regexp</code> 函数在行数估算时的默认选择率,以及是否对这些函数启用 TopN 辅助估算。</li><li>TiDB 总是会尝试利用统计信息对过滤条件中的 <code>like</code> 进行估算,但是当 <code>like</code> 匹配的字符串太复杂时,或者面对 <code>rlike</code> 或 <code>regexp</code> 时,往往无法充分利用统计信息,转而使用 <code>0.8</code> 作为选择率,造成行数估算的误差较大。</li><li>该变量可以用于修改这个行为,当变量被设为 <code>0</code> 以外的值时,会使用变量的值而不是默认的 <code>0.8</code> 作为选择率。</li><li>如果将该变量的值设为 <code>0</code>,TiDB 在对上述三个函数进行行数估算时,会尝试利用统计信息中的 TopN 进行求值来提高估算精度,同时也会考虑统计信息中的 NULL 数。求值操作预计会造成少量性能损耗。这个功能生效的前提是统计信息是在 <a href="#tidb_analyze_version-%E4%BB%8E-v510-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_analyze_version</code></a> 设为 <code>2</code> 时收集的。</li><li>当该变量的值被设为默认值以外的值的时候,会对 <code>not like</code>、<code>not rlike</code>、<code>not regexp</code> 的行数估算也进行相应的调整。</li></ul><h3 id="tidb_disable_txn_auto_retry" style="position:relative"><a href="#tidb_disable_txn_auto_retry" aria-label="tidb_disable_txn_auto_retry permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_disable_txn_auto_retry</code></h3><ul><li><p>作用域:SESSION | GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:布尔型</p></li><li><p>默认值:<code>ON</code></p></li><li><p>这个变量用来设置是否禁用显式的乐观事务自动重试,设置为 <code>ON</code> 时,不会自动重试,如果遇到事务冲突需要在应用层重试。</p><p> 如果将该变量的值设为 <code>OFF</code>,TiDB 将会自动重试事务,这样在事务提交时遇到的错误更少。需要注意的是,这样可能会导致数据更新丢失。</p><p> 这个变量不会影响自动提交的隐式事务和 TiDB 内部执行的事务,它们依旧会根据 <code>tidb_retry_limit</code> 的值来决定最大重试次数。</p><p> 关于是否需要禁用自动重试,请参考<a href="/zh/tidb/stable/optimistic-transaction#重试的局限性">重试的局限性</a>。</p><p> 该变量只适用于乐观事务,不适用于悲观事务。悲观事务的重试次数由 <a href="/zh/tidb/stable/tidb-configuration-file#max-retry-count"><code>max_retry_count</code></a> 控制。</p></li></ul><h3 id="tidb_distsql_scan_concurrency" style="position:relative"><a href="#tidb_distsql_scan_concurrency" aria-label="tidb_distsql_scan_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_distsql_scan_concurrency</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>15</code></li><li>范围:<code>[1, 256]</code></li><li>单位:线程</li><li>这个变量用来设置 scan 操作的并发度。</li><li>AP 类应用适合较大的值,TP 类应用适合较小的值。对于 AP 类应用,最大值建议不要超过所有 TiKV 节点的 CPU 核数。</li><li>若表的分区较多可以适当调小该参数(取决于扫描数据量的大小以及扫描频率),避免 TiKV 内存溢出 (OOM)。</li></ul><h3 id="tidb_dml_batch_size" style="position:relative"><a href="#tidb_dml_batch_size" aria-label="tidb_dml_batch_size permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_dml_batch_size</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>该变量与废弃的 batch-dml 特性相关,可能会导致数据损坏。因此,不建议开启该变量来使用 batch-dml。作为替代,请使用<a href="/zh/tidb/stable/non-transactional-dml">非事务 DML 语句</a>。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 2147483647]</code></li><li>单位:行</li><li>这个变量的值大于 <code>0</code> 时,TiDB 会将 <code>INSERT</code> 语句在更小的事务中批量提交。这样可减少内存使用,确保大批量修改时事务大小不会达到 <code>txn-total-size-limit</code> 限制。</li><li>只有变量值为 <code>0</code> 时才符合 ACID 要求。否则无法保证 TiDB 的原子性和隔离性要求。</li><li>要使该特性生效,还需要开启 <code>tidb_enable_batch_dml</code>,以及至少开启 <code>tidb_batch_insert</code> 和 <code>tidb_batch_delete</code> 中的一个。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>自 v7.0.0 起,<code>tidb_dml_batch_size</code> 对 <a href="/zh/tidb/stable/sql-statement-load-data"><code>LOAD DATA</code> 语句</a>不再生效。</p></div></div></div><h3 id="tidb_enable_1pc-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_enable_1pc-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_1pc span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_1pc</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>指定是否在只涉及一个 Region 的事务上启用一阶段提交特性。比起传统两阶段提交,一阶段提交能大幅降低事务提交延迟并提升吞吐。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li>对于新创建的集群,默认值为 ON。对于升级版本的集群,如果升级前是 v5.0 以下版本,升级后默认值为 <code>OFF</code>。</li><li>启用 TiDB Binlog 后,开启该选项无法获得性能提升。要获得性能提升,建议使用 <a href="/zh/tidb/stable/ticdc-overview">TiCDC</a> 替代 TiDB Binlog。</li><li>启用该参数仅意味着一阶段提交成为可选的事务提交模式,实际由 TiDB 自行判断选择最合适的提交模式进行事务提交。</li></ul></div></div></div><h3 id="tidb_enable_analyze_snapshot-span-classversion-mark从-v620-版本开始引入span" style="position:relative"><a href="#tidb_enable_analyze_snapshot-span-classversion-mark%E4%BB%8E-v620-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_analyze_snapshot span classversion mark从 v620 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_analyze_snapshot</code> <span class="version-mark">从 v6.2.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量控制 <code>ANALYZE</code> 读取历史时刻的数据还是读取最新的数据。当该变量设置为 <code>ON</code> 时,<code>ANALYZE</code> 读取 <code>ANALYZE</code> 开始时刻的历史数据。当该变量设置为 <code>OFF</code> 时,<code>ANALYZE</code> 读取最新的数据。</li><li>在 v5.2 之前,<code>ANALYZE</code> 读取最新的数据。v5.2 至 v6.1 版本 <code>ANALYZE</code> 读取 <code>ANALYZE</code> 开始时刻的历史数据。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>如果 <code>ANALYZE</code> 读取 <code>ANALYZE</code> 开始时刻的历史数据,长时间的 <code>AUTO ANALYZE</code> 可能会因为历史数据被 GC 而出现 <code>GC life time is shorter than transaction duration</code> 的报错。</p></div></div></div><h3 id="tidb_enable_async_commit-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_enable_async_commit-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_async_commit span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_async_commit</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>该变量控制是否启用 Async Commit 特性,使事务两阶段提交的第二阶段于后台异步进行。开启本特性能降低事务提交的延迟。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li>对于新创建的集群,默认值为 ON。对于升级版本的集群,如果升级前是 v5.0 以下版本,升级后默认值为 <code>OFF</code>。</li><li>启用 TiDB Binlog 后,开启该选项无法获得性能提升。要获得性能提升,建议使用 <a href="/zh/tidb/stable/ticdc-overview">TiCDC</a> 替代 TiDB Binlog。</li><li>启用该参数仅意味着 Async Commit 成为可选的事务提交模式,实际由 TiDB 自行判断选择最合适的提交模式进行事务提交。</li></ul></div></div></div><h3 id="tidb_enable_auto_analyze-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_enable_auto_analyze-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_auto_analyze span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_auto_analyze</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>该变量控制 TiDB 是否以后台操作自动更新表的统计信息。</li><li>在 v6.1.0 之前这个开关通过 TiDB 配置文件 (<code>performance.run-auto-analyze</code>) 进行配置,升级到 v6.1.0 时会自动继承原有设置。</li></ul><h3 id="tidb_enable_auto_increment_in_generated" style="position:relative"><a href="#tidb_enable_auto_increment_in_generated" aria-label="tidb_enable_auto_increment_in_generated permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_auto_increment_in_generated</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制是否允许在创建生成列或者表达式索引时引用自增列。</li></ul><h3 id="tidb_enable_batch_dml" style="position:relative"><a href="#tidb_enable_batch_dml" aria-label="tidb_enable_batch_dml permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_batch_dml</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>该变量与废弃的 batch-dml 特性相关,可能会导致数据损坏。因此,不建议开启该变量来使用 batch-dml。作为替代,请使用<a href="/zh/tidb/stable/non-transactional-dml">非事务 DML 语句</a>。</p></div></div></div><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量控制是否启用废弃的 batch-dml 特性。启用该变量后,部分语句可能会被拆分为多个事务执行,这是非原子性的,使用时需谨慎。使用 batch-dml 时,必须确保正在操作的数据没有并发操作。要使该变量生效,还需要为 <code>tidb_batch_dml_size</code> 指定一个正值,并启用 <code>tidb_batch_insert</code> 和 <code>tidb_batch_delete</code> 中的至少一个。</li></ul><h3 id="tidb_enable_cascades_planner" style="position:relative"><a href="#tidb_enable_cascades_planner" aria-label="tidb_enable_cascades_planner permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_cascades_planner</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>目前 cascades planner 为实验特性,不建议在生产环境中使用。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制是否开启 cascades planner。</li></ul><h3 id="tidb_enable_chunk_rpc-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_enable_chunk_rpc-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_chunk_rpc span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_chunk_rpc</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来设置是否启用 Coprocessor 的 <code>Chunk</code> 数据编码格式。</li></ul><h3 id="tidb_enable_clustered_index-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_enable_clustered_index-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_clustered_index span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_clustered_index</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>ON</code></li><li>可选值:<code>OFF</code>,<code>ON</code>,<code>INT_ONLY</code></li><li>这个变量用于控制默认情况下表的主键是否使用<a href="/zh/tidb/stable/clustered-indexes">聚簇索引</a>。“默认情况”即不显式指定 <code>CLUSTERED</code>/<code>NONCLUSTERED</code> 关键字的情况。可设置为 <code>OFF</code>/<code>ON</code>/<code>INT_ONLY</code>。<ul><li><code>OFF</code> 表示所有主键默认使用非聚簇索引。</li><li><code>ON</code> 表示所有主键默认使用聚簇索引。</li><li><code>INT_ONLY</code> 此时的行为受配置项 <code>alter-primary-key</code> 控制。如果该配置项取值为 <code>true</code>,则所有主键默认使用非聚簇索引;如果该配置项取值为 <code>false</code>,则由单个整数类型的列构成的主键默认使用聚簇索引,其他类型的主键默认使用非聚簇索引。</li></ul></li></ul><h3 id="tidb_enable_collect_execution_info" style="position:relative"><a href="#tidb_enable_collect_execution_info" aria-label="tidb_enable_collect_execution_info permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_collect_execution_info</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于控制是否同时将各个执行算子的执行信息记录入 slow query log 中。</li></ul><h3 id="tidb_enable_column_tracking-span-classversion-mark从-v540-版本开始引入span" style="position:relative"><a href="#tidb_enable_column_tracking-span-classversion-mark%E4%BB%8E-v540-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_column_tracking span classversion mark从 v540 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_column_tracking</code> <span class="version-mark">从 v5.4.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>收集 <code>PREDICATE COLUMNS</code> 的统计信息目前为实验特性,不建议在生产环境中使用。</p></div></div></div><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制是否开启 TiDB 对 <code>PREDICATE COLUMNS</code> 的收集。关闭该变量后,之前收集的 <code>PREDICATE COLUMNS</code> 会被清除。详情见<a href="/zh/tidb/stable/statistics#收集部分列的统计信息">收集部分列的统计信息</a>。</li></ul><h3 id="tidb_enable_ddl-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_enable_ddl-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_ddl span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_ddl</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>默认值:<code>ON</code></li><li>可选值:<code>OFF</code>,<code>ON</code></li><li>用于设置该 TiDB 实例是否可以成为 DDL owner。若当前 TiDB 集群中只有一台 TiDB 实例,则不能禁止该实例成为 DDL owner,即不能设置为 <code>OFF</code>。</li></ul><h3 id="tidb_enable_enhanced_security" style="position:relative"><a href="#tidb_enable_enhanced_security" aria-label="tidb_enable_enhanced_security permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_enhanced_security</code></h3><ul><li>作用域:NONE</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量表示所连接的 TiDB 服务器是否启用了安全增强模式 (SEM)。若要改变该变量值,你需要在 TiDB 服务器的配置文件中修改 <code>enable-sem</code> 项的值,并重启 TiDB 服务器。</li><li>安全增强模式受<a href="https://zh.wikipedia.org/wiki/安全增强式Linux" target="_blank" referrerpolicy="no-referrer-when-downgrade">安全增强式 Linux</a> 等系统设计的启发,削减拥有 MySQL <code>SUPER</code> 权限的用户能力,转而使用细粒度的 <code>RESTRICTED</code> 权限作为替代。这些细粒度的 <code>RESTRICTED</code> 权限如下:<ul><li><code>RESTRICTED_TABLES_ADMIN</code>:能够写入 <code>mysql</code> 库中的系统表,能查看 <code>information_schema</code> 表上的敏感列。</li><li><code>RESTRICTED_STATUS_ADMIN</code>:能够在 <code>SHOW STATUS</code> 命令中查看敏感内容。</li><li><code>RESTRICTED_VARIABLES_ADMIN</code>:能够在 <code>SHOW [GLOBAL] VARIABLES</code> 和 <code>SET</code> 命令中查看和设置包含敏感内容的变量。</li><li><code>RESTRICTED_USER_ADMIN</code>:能够阻止其他用户更改或删除用户帐户。</li><li><code>RESTRICTED_CONNECTION_ADMIN</code>:能够阻止其它用户使用 <code>KILL</code> 语句终止连接。</li></ul></li></ul><h3 id="tidb_enable_external_ts_read-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_enable_external_ts_read-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_external_ts_read span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_external_ts_read</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>当此变量设置为 <code>ON</code> 时,TiDB 会读取 <a href="#tidb_external_ts-%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_external_ts</code></a> 指定时间戳前的历史数据。</li></ul><h3 id="tidb_external_ts-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_external_ts-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_external_ts span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_external_ts</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>当 <a href="#tidb_enable_external_ts_read-%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_enable_external_ts_read</code></a> 设置为 <code>ON</code> 时,TiDB 会依据该变量指定的时间戳读取历史数据。</li></ul><h3 id="tidb_restricted_read_only-span-classversion-mark从-v520-版本开始引入span" style="position:relative"><a href="#tidb_restricted_read_only-span-classversion-mark%E4%BB%8E-v520-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_restricted_read_only span classversion mark从 v520 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_restricted_read_only</code> <span class="version-mark">从 v5.2.0 版本开始引入</span></h3><ul><li><p>作用域:GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:布尔型</p></li><li><p>默认值:<code>OFF</code></p></li><li><p>可选值:<code>OFF</code> 和 <code>ON</code></p></li><li><p><code>tidb_restricted_read_only</code>和 <a href="#tidb_super_read_only-%E4%BB%8E-v531-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_super_read_only</code></a> 的作用相似。在大多数情况下,你只需要使用 <a href="#tidb_super_read_only-%E4%BB%8E-v531-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_super_read_only</code></a> 即可。</p></li><li><p>拥有 <code>SUPER</code> 或 <code>SYSTEM_VARIABLES_ADMIN</code> 权限的用户可以修改该变量。如果 TiDB 开启了<a href="#tidb_enable_enhanced_security">安全增强模式</a>,你还需要额外的 <code>RESTRICTED_VARIABLES_ADMIN</code> 权限才能读取或修改该变量。</p></li><li><p><code>tidb_restricted_read_only</code> 的设置将影响 <a href="#tidb_super_read_only-%E4%BB%8E-v531-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_super_read_only</code></a> 的值:</p><ul><li>当设置 <code>tidb_restricted_read_only</code> 为 <code>ON</code> 时,<a href="#tidb_super_read_only-%E4%BB%8E-v531-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_super_read_only</code></a> 的将自动被设置为 <code>ON</code>。</li><li>当设置 <code>tidb_restricted_read_only</code> 为 <code>OFF</code> 时,<a href="#tidb_super_read_only-%E4%BB%8E-v531-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_super_read_only</code></a> 的值将不受影响。</li><li>当 <code>tidb_restricted_read_only</code> 为 <code>ON</code> 时,<a href="#tidb_super_read_only-%E4%BB%8E-v531-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_super_read_only</code></a> 的值无法设置为 <code>OFF</code>。</li></ul></li><li><p>对于 TiDB 的 DBaaS 供应商,当 TiDB 为另一个数据库的下游数据库时,如果要将整个 TiDB 集群设置为只读模式,你需要开启<a href="#tidb_enable_enhanced_security">安全增强模式</a> 并将 <code>tidb_restricted_read_only</code> 设置为 <code>ON</code>,从而防止你的用户通过 <a href="#tidb_super_read_only-%E4%BB%8E-v531-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_super_read_only</code></a> 将 TiDB 集群设置为可写。实现方法:首先开启<a href="#tidb_enable_enhanced_security">安全增强模式</a>,然后由你(作为 DBaaS 的控制面)使用一个 admin 用户控制 <code>tidb_restricted_read_only</code>(需要拥有 <code>SYSTEM_VARIABLES_ADMIN</code> 和 <code>RESTRICTED_VARIABLES_ADMIN</code> 权限),由你的数据库用户使用 root 用户控制 <a href="#tidb_super_read_only-%E4%BB%8E-v531-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_super_read_only</code></a>(需要拥有 <code>SUPER</code> 权限)。</p></li><li><p>该变量可以控制整个集群的只读状态。开启后(即该值为 <code>ON</code>),整个集群中的 TiDB 服务器都将进入只读状态,只有 <code>SELECT</code>、<code>USE</code>、<code>SHOW</code> 等不会修改数据的语句才能被执行,其他如 <code>INSERT</code>、<code>UPDATE</code> 等语句会被拒绝执行。</p></li><li><p>该变量开启只读模式只保证整个集群最终进入只读模式,当变量修改状态还没被同步到其他 TiDB 服务器时,尚未同步的 TiDB 仍然停留在非只读模式。</p></li><li><p>在执行 SQL 语句之前,TiDB 会检查集群的只读标志。从 v6.2.0 起,在提交 SQL 语句之前,TiDB 也会检查该标志,从而防止在服务器被置于只读模式后某些长期运行的 <a href="/zh/tidb/stable/transaction-overview#自动提交">auto commit</a> 语句可能修改数据的情况。</p></li><li><p>在变量开启时,对于尚未提交的事务:</p><ul><li>如果有尚未提交的只读事务,可正常提交该事务。</li><li>如果尚未提交的事务为非只读事务,在事务内执行写入的 SQL 语句会被拒绝。</li><li>如果尚未提交的事务已经有数据改动,其提交也会被拒绝。</li></ul></li><li><p>当集群开启只读模式后,所有用户(包括 <code>SUPER</code> 用户)都无法执行可能写入数据的 SQL 语句,除非该用户被显式地授予了 <code>RESTRICTED_REPLICA_WRITER_ADMIN</code> 权限。</p></li></ul><h3 id="tidb_enable_exchange_partition" style="position:relative"><a href="#tidb_enable_exchange_partition" aria-label="tidb_enable_exchange_partition permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_exchange_partition</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>该变量用于设置是否启用 <a href="/zh/tidb/stable/partitioned-table#分区管理"><code>exchange partitions with tables</code></a> 特性。默认值为 <code>ON</code>,即默认开启该功能。</li><li>该变量自 v6.3.0 开始废弃,其取值将固定为默认值 <code>ON</code>,即默认开启 <code>exchange partitions with tables</code>。</li></ul><h3 id="tidb_enable_extended_stats" style="position:relative"><a href="#tidb_enable_extended_stats" aria-label="tidb_enable_extended_stats permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_extended_stats</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量指定 TiDB 是否收集扩展统计信息来指导优化器。</li></ul><h3 id="tidb_enable_fast_analyze" style="position:relative"><a href="#tidb_enable_fast_analyze" aria-label="tidb_enable_fast_analyze permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_fast_analyze</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>目前快速分析功能为实验特性,不建议在生产环境中使用。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来控制是否启用统计信息快速分析功能。默认值 0 表示不开启。</li><li>快速分析功能开启后,TiDB 会随机采样约 10000 行的数据来构建统计信息。因此在数据分布不均匀或者数据量比较少的情况下,统计信息的准确度会比较低。这可能导致执行计划不优,比如选错索引。如果可以接受普通 <code>ANALYZE</code> 语句的执行时间,则推荐关闭快速分析功能。</li></ul><h3 id="tidb_enable_foreign_key-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_enable_foreign_key-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_foreign_key span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_foreign_key</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:在 v6.6.0 之前版本中为 <code>OFF</code>,在 v6.6.0 及之后的版本中为 <code>ON</code>。</li><li>这个变量用于控制是否开启 <code>FOREIGN KEY</code> 特性。</li></ul><h3 id="tidb_enable_gc_aware_memory_track" style="position:relative"><a href="#tidb_enable_gc_aware_memory_track" aria-label="tidb_enable_gc_aware_memory_track permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_gc_aware_memory_track</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>该变量为 TiDB 内部调试变量,可能会在未来版本中删除,<strong>请勿</strong>设置该变量。</p></div></div></div><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制是否开启可感知到垃圾回收的内存追踪 (GC-Aware memory track)。</li></ul><h3 id="tidb_enable_non_prepared_plan_cache" style="position:relative"><a href="#tidb_enable_non_prepared_plan_cache" aria-label="tidb_enable_non_prepared_plan_cache permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_non_prepared_plan_cache</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>非 Prepare 语句执行计划缓存目前为实验特性,不建议在生产环境中使用。该功能可能会在未事先通知的情况下发生变化或删除。如果发现 bug,请在 GitHub 上提 <a href="https://github.com/pingcap/tidb/issues" target="_blank" referrerpolicy="no-referrer-when-downgrade">issue</a> 反馈。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来控制是否开启<a href="/zh/tidb/stable/sql-non-prepared-plan-cache">非 Prepare 语句执行计划缓存</a>。</li></ul><h3 id="tidb_enable_non_prepared_plan_cache_for_dml-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#tidb_enable_non_prepared_plan_cache_for_dml-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_non_prepared_plan_cache_for_dml span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_non_prepared_plan_cache_for_dml</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>非 Prepare 语句执行计划缓存目前为实验特性,不建议在生产环境中使用。该功能可能会在未事先通知的情况下发生变化或删除。如果发现 bug,请在 GitHub 上提 <a href="https://github.com/pingcap/tidb/issues" target="_blank" referrerpolicy="no-referrer-when-downgrade">issue</a> 反馈。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来控制<a href="/zh/tidb/stable/sql-non-prepared-plan-cache">非 Prepare 语句执行计划缓存</a>是否支持 DML 语句。</li></ul><h3 id="tidb_enable_gogc_tuner-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_enable_gogc_tuner-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_gogc_tuner span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_gogc_tuner</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>该变量来用控制是否开启 GOGC Tuner。</li></ul><h3 id="tidb_enable_historical_stats" style="position:relative"><a href="#tidb_enable_historical_stats" aria-label="tidb_enable_historical_stats permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_historical_stats</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制是否开启历史统计信息。默认值为 <code>ON</code> 表示默认开启历史统计信息。</li></ul><h3 id="tidb_enable_historical_stats_for_capture" style="position:relative"><a href="#tidb_enable_historical_stats_for_capture" aria-label="tidb_enable_historical_stats_for_capture permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_historical_stats_for_capture</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>当前版本中该变量控制的功能尚未完全生效,请保留默认值。</p></div></div></div><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来控制 <code>PLAN REPLAYER CAPTURE</code> 抓取的内容是否默认带历史统计信息。默认值为 <code>OFF</code>,表示默认不带历史统计信息。</li></ul><h3 id="tidb_enable_index_merge-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_enable_index_merge-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_index_merge span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_index_merge</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li>当集群从 v4.0.0 以下版本升级到 v5.4.0 及以上版本时,该变量开关默认关闭,防止升级后计划发生变化导致回退。</li><li>当集群从 v4.0.0 及以上版本升级到 v5.4.0 及以上版本时,该变量开关保持升级前的状态。</li><li>对于 v5.4.0 及以上版本的新建集群,该变量开关默认开启。</li></ul></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于控制是否开启 index merge 功能。</li></ul><h3 id="tidb_enable_index_merge_join" style="position:relative"><a href="#tidb_enable_index_merge_join" aria-label="tidb_enable_index_merge_join permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_index_merge_join</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>表示是否启用 <code>IndexMergeJoin</code> 算子。</li><li>该变量为 TiDB 内部变量,<strong>不推荐使用</strong>,否则可能会造成数据正确性问题。</li></ul><h3 id="tidb_enable_legacy_instance_scope-span-classversion-mark从-v600-版本开始引入span" style="position:relative"><a href="#tidb_enable_legacy_instance_scope-span-classversion-mark%E4%BB%8E-v600-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_legacy_instance_scope span classversion mark从 v600 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_legacy_instance_scope</code> <span class="version-mark">从 v6.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于允许使用 <code>SET SESSION</code> 对 <code>INSTANCE</code> 作用域的变量进行设置,用法同 <code>SET GLOBAL</code>。</li><li>为了兼容之前的 TiDB 版本,该变量值默认为 <code>ON</code>。</li></ul><h3 id="tidb_enable_list_partition-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_enable_list_partition-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_list_partition span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_list_partition</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来设置是否开启 <code>LIST (COLUMNS) TABLE PARTITION</code> 特性。</li></ul><h3 id="tidb_enable_local_txn" style="position:relative"><a href="#tidb_enable_local_txn" aria-label="tidb_enable_local_txn permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_local_txn</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量用于一个未发布的特性,<strong>请勿修改该变量值</strong>。</li></ul><h3 id="tidb_enable_metadata_lock-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_enable_metadata_lock-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_metadata_lock span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_metadata_lock</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来设置是否开启<a href="/zh/tidb/stable/metadata-lock">元数据锁</a>特性。需要注意,在设置该变量时,集群中不能有 DDL 任务,以免造成非预期数据正确性、一致性问题。</li></ul><h3 id="tidb_enable_mutation_checker-span-classversion-mark从-v600-版本开始引入span" style="position:relative"><a href="#tidb_enable_mutation_checker-span-classversion-mark%E4%BB%8E-v600-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_mutation_checker span classversion mark从 v600 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_mutation_checker</code> <span class="version-mark">从 v6.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于设置是否开启 mutation checker。mutation checker 是一项在 DML 语句执行过程中进行的数据索引一致性校验,校验报错会回滚当前语句。开启该校验会导致 CPU 使用轻微上升。详见<a href="/zh/tidb/stable/troubleshoot-data-inconsistency-errors">数据索引一致性报错</a>。</li><li>对于新创建的 v6.0.0 及以上的集群,默认值为 <code>ON</code>。对于升级版本的集群,如果升级前是低于 v6.0.0 的版本,升级后默认值为 <code>OFF</code>。</li></ul><h3 id="tidb_enable_new_cost_interface-span-classversion-mark从-v620-版本开始引入span" style="position:relative"><a href="#tidb_enable_new_cost_interface-span-classversion-mark%E4%BB%8E-v620-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_new_cost_interface span classversion mark从 v620 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_new_cost_interface</code> <span class="version-mark">从 v6.2.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>TiDB v6.2.0 对代价模型的实现进行了代码层面的重构,这个变量用来控制是否使用重构后的代价模型 <a href="/zh/tidb/stable/cost-model#cost-model-version-2">Cost Model Version 2</a>。</li><li>重构后的代价模型使用完全一样的代价公式,因此不会引起计划选择的变动,此开关默认打开。</li><li>从 v6.1 升级至 v6.2 的用户,此开关保持升级前的 <code>OFF</code> 状态,此时建议直接打开;对于从 v6.1 之前版本升级至 v6.2 的用户,此开关默认为 <code>ON</code>。</li></ul><h3 id="tidb_enable_new_only_full_group_by_check-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_enable_new_only_full_group_by_check-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_new_only_full_group_by_check span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_new_only_full_group_by_check</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量用于控制 TiDB 执行 <code>ONLY_FULL_GROUP_BY</code> 检查时的行为。有关 <code>ONLY_FULL_GROUP_BY</code> 的信息可以参考 <a href="https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_only_full_group_by" target="_blank" referrerpolicy="no-referrer-when-downgrade">MySQL 文档</a>。在 v6.1 中 TiDB 对该项检查做了更严格正确的处理。</li><li>由于可能存在版本升级造成的兼容性问题,在 v6.1 中该变量默认值是 <code>OFF</code>,即默认关闭。</li></ul><h3 id="tidb_enable_noop_functions-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_enable_noop_functions-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_noop_functions span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_noop_functions</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>OFF</code></li><li>可选值:<code>ON</code>、<code>OFF</code>、<code>WARN</code></li><li>默认情况下,用户尝试将某些语法用于尚未实现的功能时,TiDB 会报错。若将该变量值设为 <code>ON</code>,TiDB 则自动忽略此类功能不可用的情况,即不会报错。若用户无法更改 SQL 代码,可考虑将变量值设为 <code>ON</code>。</li><li>启用 <code>noop</code> 函数可以控制以下行为:<ul><li><code>LOCK IN SHARE MODE</code> 语法</li><li><code>SQL_CALC_FOUND_ROWS</code> 语法</li><li><code>START TRANSACTION READ ONLY</code> 和 <code>SET TRANSACTION READ ONLY</code> 语法</li><li><code>tx_read_only</code>、<code>transaction_read_only</code>、<code>offline_mode</code>、<code>super_read_only</code>、<code>read_only</code> 以及 <code>sql_auto_is_null</code> 系统变量</li><li><code>GROUP BY <expr> ASC|DESC</code> 语法</li></ul></li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>该变量只有在默认值 <code>OFF</code> 时,才算是安全的。因为设置 <code>tidb_enable_noop_functions=1</code> 后,TiDB 会自动忽略某些语法而不报错,这可能会导致应用程序出现异常行为。例如,允许使用语法 <code>START TRANSACTION READ ONLY</code> 时,事务仍会处于读写模式。</p></div></div></div><h3 id="tidb_enable_noop_variables-span-classversion-mark从-v620-版本开始引入span" style="position:relative"><a href="#tidb_enable_noop_variables-span-classversion-mark%E4%BB%8E-v620-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_noop_variables span classversion mark从 v620 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_noop_variables</code> <span class="version-mark">从 v6.2.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>若该变量值为 <code>OFF</code>,TiDB 具有以下行为:<ul><li>使用 <code>SET</code> 设置 <code>noop</code> 的系统变量时会报 <code>"setting *variable_name* has no effect in TiDB"</code> 的警告。</li><li><code>SHOW [SESSION | GLOBAL] VARIABLES</code> 的结果不显示 <code>noop</code> 的系统变量。</li><li>使用 <code>SELECT</code> 读取 <code>noop</code> 的系统变量时会报 <code>"variable *variable_name* has no effect in TiDB"</code> 的警告。</li></ul></li><li>你可以通过 <code>SELECT * FROM INFORMATION_SCHEMA.CLIENT_ERRORS_SUMMARY_GLOBAL;</code> 语句来检查 TiDB 实例是否曾设置和读取 <code>noop</code> 系统变量。</li></ul><h3 id="tidb_enable_null_aware_anti_join-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_enable_null_aware_anti_join-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_null_aware_anti_join span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_null_aware_anti_join</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:在 v7.0.0 之前版本中为 <code>OFF</code>,即默认关闭。在 v7.0.0 及之后的版本中为 <code>ON</code>,即默认开启。</li><li>这个变量用于控制 TiDB 对特殊集合算子 <code>NOT IN</code> 和 <code>!= ALL</code> 引导的子查询产生的 ANTI JOIN 是否采用 Null Aware Hash Join 的执行方式。</li><li>从旧版本升级到 v7.0.0 及之后版本,该功能自动开启,即该变量的值修改为默认值 <code>ON</code>。</li></ul><h3 id="tidb_enable_outer_join_reorder-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_enable_outer_join_reorder-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_outer_join_reorder span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_outer_join_reorder</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li><p>作用域:SESSION | GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:布尔型</p></li><li><p>默认值:<code>ON</code></p></li><li><p>自 v6.1.0 起,TiDB 的 <a href="/zh/tidb/stable/join-reorder">Join Reorder 算法</a>开始支持 Outer Join。该变量用于控制是否启用 Outer Join 的 Join Reorder。</p></li><li><p>对于从较低版本升级到当前版本的 TiDB:</p><ul><li>如果升级前 TiDB 的版本低于 v6.1.0,升级后该变量的默认值为 <code>ON</code>。</li><li>如果升级前 TiDB 的版本等于或大于 v6.1.0,升级后该变量的默认值跟随升级前的设定值。</li></ul></li></ul><h3 id="tidb_enable_inl_join_inner_multi_pattern-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_enable_inl_join_inner_multi_pattern-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_inl_join_inner_multi_pattern span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_inl_join_inner_multi_pattern</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量用于控制当内表上有 <code>Selection</code>/<code>Projection</code> 算子时是否支持 Index Join。<code>OFF</code> 表示不支持。</li></ul><h3 id="tidb_enable_ordered_result_mode" style="position:relative"><a href="#tidb_enable_ordered_result_mode" aria-label="tidb_enable_ordered_result_mode permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_ordered_result_mode</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>指定是否对最终的输出结果进行自动排序。</li><li>例如,开启该变量后,TiDB 会将 <code>SELECT a, MAX(b) FROM t GROUP BY a</code> 处理为 <code>SELECT a, MAX(b) FROM t GROUP BY a ORDER BY a, MAX(b)</code>。</li></ul><h3 id="tidb_enable_paging-span-classversion-mark从-v540-版本开始引入span" style="position:relative"><a href="#tidb_enable_paging-span-classversion-mark%E4%BB%8E-v540-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_paging span classversion mark从 v540 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_paging</code> <span class="version-mark">从 v5.4.0 版本开始引入</span></h3><ul><li><p>作用域:SESSION | GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:布尔型</p></li><li><p>默认值:<code>ON</code></p></li><li><p>这个变量用于控制是否使用分页 (paging) 方式发送 Coprocessor 请求。对于 [v5.4.0, v6.2.0) 区间的 TiDB 版本,该变量只对 <code>IndexLookup</code> 算子生效;对于 v6.2.0 以及之后的版本,该变量对全局生效。从 v6.4.0 版本开始,该变量默认值由 <code>OFF</code> 改成 <code>ON</code>。</p></li><li><p>适用场景:</p><ul><li>推荐在所有偏 OLTP 的场景下使用 paging。</li><li>对于使用 <code>IndexLookUp</code> 和 <code>Limit</code> 并且 <code>Limit</code> 无法下推到 <code>IndexScan</code> 上的读请求,可能会出现读请求的延迟高、TiKV 的 Unified read pool CPU 使用率高的情况。在这种情况下,由于 <code>Limit</code> 算子只需要少部分数据,开启 <a href="#tidb_enable_paging-%E4%BB%8E-v540-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_enable_paging</code></a> 能够减少处理数据的数量,从而降低延迟、减少资源消耗。</li><li>对于 <a href="/zh/tidb/stable/dumpling-overview">Dumpling</a> 数据导出或者全表扫描这类的场景,开启 paging 后可以有效降低 TiDB 进程的内存消耗。</li></ul></li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>对于偏 OLAP 的场景,并且以 TiKV 而非 TiFlash 作为存储引擎时,开启 paging 可能导致部分场景下性能回退。此时,你可以考虑通过该变量关闭 paging 或者通过系统变量 <a href="/zh/tidb/stable/system-variables#tidb_min_paging_size-从-v620-版本开始引入"><code>tidb_min_paging_size</code></a> 和 <a href="/zh/tidb/stable/system-variables#tidb_max_paging_size-从-v630-版本开始引入"><code>tidb_max_paging_size</code></a> 调整 paging size 的行数范围。</p></div></div></div><h3 id="tidb_enable_parallel_apply-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_enable_parallel_apply-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_parallel_apply span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_parallel_apply</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制是否开启 Apply 算子并发,并发数由 <code>tidb_executor_concurrency</code> 变量控制。Apply 算子用来处理关联子查询且默认无并发,所以执行速度较慢。打开 Apply 并发开关可增加并发度,提高执行速度。目前默认关闭。</li></ul><h3 id="tidb_enable_pipelined_window_function" style="position:relative"><a href="#tidb_enable_pipelined_window_function" aria-label="tidb_enable_pipelined_window_function permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_pipelined_window_function</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>该变量指定是否对窗口函数采用流水线的执行算法。</li></ul><h3 id="tidb_enable_plan_cache_for_param_limit-span-classversion-mark从-v660-版本开始引入span" style="position:relative"><a href="#tidb_enable_plan_cache_for_param_limit-span-classversion-mark%E4%BB%8E-v660-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_plan_cache_for_param_limit span classversion mark从 v660 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_plan_cache_for_param_limit</code> <span class="version-mark">从 v6.6.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制 Prepared Plan Cache 是否缓存 <code>LIMIT</code> 后面带变量 (<code>LIMIT ?</code>) 的执行计划。目前不支持缓存 <code>LIMIT</code> 后面带变量且变量值大于 10000 的执行计划。</li></ul><h3 id="tidb_enable_plan_cache_for_subquery-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_enable_plan_cache_for_subquery-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_plan_cache_for_subquery span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_plan_cache_for_subquery</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制 Prepared Plan Cache 是否缓存包含子查询的查询。</li></ul><h3 id="tidb_enable_plan_replayer_capture" style="position:relative"><a href="#tidb_enable_plan_replayer_capture" aria-label="tidb_enable_plan_replayer_capture permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_plan_replayer_capture</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制是否开启 <a href="/zh/tidb/stable/sql-plan-replayer#使用-plan-replayer-capture-抓取目标计划"><code>PLAN REPLAYER CAPTURE</code> 功能</a>。默认值 <code>ON</code> 代表开启 <code>PLAN REPLAYER CAPTURE</code> 功能。</li></ul><h3 id="tidb_enable_plan_replayer_continuous_capture-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_enable_plan_replayer_continuous_capture-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_plan_replayer_continuous_capture span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_plan_replayer_continuous_capture</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来控制是否开启 <a href="/zh/tidb/stable/sql-plan-replayer#使用-plan-replayer-continuous-capture"><code>PLAN REPLAYER CONTINUOUS CAPTURE</code> 功能</a>。默认值 <code>OFF</code> 代表关闭功能。</li></ul><h3 id="tidb_enable_prepared_plan_cache-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_enable_prepared_plan_cache-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_prepared_plan_cache span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_prepared_plan_cache</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制是否开启 <a href="/zh/tidb/stable/sql-prepared-plan-cache">Prepared Plan Cache</a>。开启后,对 <code>Prepare</code>、<code>Execute</code> 请求的执行计划会进行缓存,以便在后续执行时跳过查询计划优化这个步骤,获得性能上的提升。</li><li>在 v6.1.0 之前这个开关通过 TiDB 配置文件 (<code>prepared-plan-cache.enabled</code>) 进行配置,升级到 v6.1.0 时会自动继承原有设置。</li></ul><h3 id="tidb_enable_prepared_plan_cache_memory_monitor-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_enable_prepared_plan_cache_memory_monitor-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_prepared_plan_cache_memory_monitor span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_prepared_plan_cache_memory_monitor</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制是否统计 Prepared Plan Cache 中所缓存的执行计划占用的内存。具体可见 <a href="/zh/tidb/stable/sql-prepared-plan-cache#prepared-plan-cache-的内存管理">Prepared Plan Cache 的内存管理</a>。</li></ul><h3 id="tidb_enable_pseudo_for_outdated_stats-span-classversion-mark从-v530-版本开始引入span" style="position:relative"><a href="#tidb_enable_pseudo_for_outdated_stats-span-classversion-mark%E4%BB%8E-v530-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_pseudo_for_outdated_stats span classversion mark从 v530 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_pseudo_for_outdated_stats</code> <span class="version-mark">从 v5.3.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来控制优化器在一张表上的统计信息过期时的行为。</li><li>统计信息过期的判断标准:最近一次对某张表执行 <code>ANALYZE</code> 获得统计信息后,该表数据被修改的行数大于该表总行数的 80%,便可判定该表的统计信息已过期。该比例可通过 <a href="/zh/tidb/stable/tidb-configuration-file#pseudo-estimate-ratio"><code>pseudo-estimate-ratio</code></a> 配置参数调整。</li><li>默认情况下(即该变量值为 <code>OFF</code> 时),某张表上的统计信息过期后,优化器仍会使用该表上的统计信息。将该变量值设为 <code>ON</code> 时,当统计信息过期后,优化器认为该表上除总行数以外的统计信息不再可靠,转而使用 pseudo 统计信息。</li><li>如果表数据修改较频繁,没有及时对表执行 <code>ANALYZE</code>,但又希望执行计划保持稳定,推荐将该变量值设为 <code>OFF</code>。</li></ul><h3 id="tidb_enable_rate_limit_action" style="position:relative"><a href="#tidb_enable_rate_limit_action" aria-label="tidb_enable_rate_limit_action permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_rate_limit_action</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量控制是否为读数据的算子开启动态内存控制功能。读数据的算子默认启用 <a href="/zh/tidb/stable/system-variables#tidb_distsql_scan_concurrency"><code>tidb_distsql_scan_concurrency</code></a> 所允许的最大线程数来读取数据。当单条 SQL 语句的内存使用每超过 <a href="/zh/tidb/stable/system-variables#tidb_mem_quota_query"><code>tidb_mem_quota_query</code></a> 一次,读数据的算子会停止一个线程。</li><li>当读数据的算子只剩 1 个线程且当单条 SQL 语句的内存使用继续超过 <a href="/zh/tidb/stable/system-variables#tidb_mem_quota_query"><code>tidb_mem_quota_query</code></a> 时,该 SQL 语句会触发其它的内存控制行为,例如<a href="/zh/tidb/stable/system-variables#tidb_enable_tmp_storage_on_oom">落盘</a>。</li><li>该变量在单条查询仅涉及读数据的情况下,对内存控制效果较好。若还存在额外的计算操作(如连接、聚合等),打开该变量可能会导致内存不受 <code>tidb_mem_quota_query</code> 控制,加剧 OOM 风险。</li></ul><h3 id="tidb_enable_resource_control-span-classversion-mark从-v660-版本开始引入span" style="position:relative"><a href="#tidb_enable_resource_control-span-classversion-mark%E4%BB%8E-v660-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_resource_control span classversion mark从 v660 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_resource_control</code> <span class="version-mark">从 v6.6.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>ON</code></li><li>类型:布尔型</li><li>该变量是<a href="/zh/tidb/stable/tidb-resource-control">资源管控特性</a>的开关。该变量设置为 <code>ON</code> 时,集群支持应用按照资源组做资源隔离。</li></ul><h3 id="tidb_enable_reuse_chunk-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_enable_reuse_chunk-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_reuse_chunk span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_reuse_chunk</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>可选值:<code>OFF</code>,<code>ON</code></li><li>该变量用于控制 TiDB 是否启用 Chunk 对象缓存。如果为 <code>ON</code>,则优先使用缓存中的 Chunk 对象,缓存中找不到申请的对象时才会从系统内存中申请。如果为 <code>OFF</code>,则直接从系统内存中申请 Chunk 对象。</li></ul><h3 id="tidb_enable_slow_log" style="position:relative"><a href="#tidb_enable_slow_log" aria-label="tidb_enable_slow_log permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_slow_log</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于控制是否开启 slow log 功能。</li></ul><h3 id="tidb_enable_stmt_summary-span-classversion-mark从-v304-版本开始引入span" style="position:relative"><a href="#tidb_enable_stmt_summary-span-classversion-mark%E4%BB%8E-v304-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_stmt_summary span classversion mark从 v304 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_stmt_summary</code> <span class="version-mark">从 v3.0.4 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制是否开启 statement summary 功能。如果开启,SQL 的耗时等执行信息将被记录到系统表 <code>information_schema.STATEMENTS_SUMMARY</code> 中,用于定位和排查 SQL 性能问题。</li></ul><h3 id="tidb_enable_strict_double_type_check-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_enable_strict_double_type_check-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_strict_double_type_check span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_strict_double_type_check</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制是否可以用 <code>DOUBLE</code> 类型的无效定义创建表。该设置的目的是提供一个从 TiDB 早期版本升级的方法,因为早期版本在验证类型方面不太严格。</li><li>该变量的默认值 <code>ON</code> 与 MySQL 兼容。</li></ul><p>例如,由于无法保证浮点类型的精度,现在将 <code>DOUBLE(10)</code> 类型视为无效。将 <code>tidb_enable_strict_double_type_check</code> 更改为 <code>OFF</code> 后,将会创建表。如下所示:</p><pre><code class="language-sql">CREATE TABLE t1 (id int, c double(10)); ERROR 1149 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use SET tidb_enable_strict_double_type_check = 'OFF'; Query OK, 0 rows affected (0.00 sec) CREATE TABLE t1 (id int, c double(10)); Query OK, 0 rows affected (0.09 sec) </code></pre><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>该设置仅适用于 <code>DOUBLE</code> 类型,因为 MySQL 允许为 <code>FLOAT</code> 类型指定精度。从 MySQL 8.0.17 开始已弃用此行为,不建议为 <code>FLOAT</code> 或 <code>DOUBLE</code> 类型指定精度。</p></div></div></div><h3 id="tidb_enable_table_partition" style="position:relative"><a href="#tidb_enable_table_partition" aria-label="tidb_enable_table_partition permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_table_partition</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>ON</code></li><li>类型:枚举型</li><li>可选值:<code>OFF</code>,<code>ON</code>,<code>AUTO</code></li><li>这个变量用来设置是否开启 <code>TABLE PARTITION</code> 特性。目前变量支持以下三种值:<ul><li>默认值 <code>ON</code> 表示开启 TiDB 当前已实现了的分区表类型,目前 Range partition、Hash partition 以及 Range column 单列的场景会生效。</li><li><code>AUTO</code> 目前作用和 <code>ON</code> 一样。</li><li><code>OFF</code> 表示关闭 <code>TABLE PARTITION</code> 特性,此时语法还是保持兼容,只是创建的表并不是真正的分区表,而是普通的表。</li></ul></li></ul><h3 id="tidb_enable_telemetry-span-classversion-mark从-v402-版本开始引入span" style="position:relative"><a href="#tidb_enable_telemetry-span-classversion-mark%E4%BB%8E-v402-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_telemetry span classversion mark从 v402 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_telemetry</code> <span class="version-mark">从 v4.0.2 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于动态地控制 TiDB 遥测功能是否开启,当前版本默认关闭 TiDB 的遥测功能。当所有 TiDB 实例都设置配置项 <a href="/zh/tidb/stable/tidb-configuration-file#enable-telemetry-从-v402-版本开始引入"><code>enable-telemetry</code></a> 为 <code>false</code> 时,将忽略该系统变量,并总是关闭 TiDB 遥测功能。参阅<a href="/zh/tidb/stable/telemetry">遥测</a>了解该功能详情。</li></ul><h3 id="tidb_enable_tiflash_read_for_write_stmt-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_enable_tiflash_read_for_write_stmt-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_tiflash_read_for_write_stmt span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_tiflash_read_for_write_stmt</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li><p>作用域:SESSION | GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:布尔型</p></li><li><p>默认值:<code>ON</code></p></li><li><p>这个变量用于控制包含增删改的 SQL 语句中的读取操作能否下推到 TiFlash,比如:</p><ul><li><code>INSERT INTO SELECT</code> 语句中的 <code>SELECT</code> 查询(典型应用场景为 <a href="/zh/tidb/stable/tiflash-results-materialization">TiFlash 查询结果物化</a>)</li><li><code>UPDATE</code> 和 <code>DELETE</code> 语句中的 <code>WHERE</code> 条件过滤</li></ul></li><li><p>从 v7.1.0 开始,该变量废弃。当 <a href="/zh/tidb/stable/system-variables#tidb_allow_mpp-从-v50-版本开始引入"><code>tidb_allow_mpp = ON</code></a> 时,优化器将根据 <a href="/zh/tidb/stable/sql-mode">SQL 模式</a>及 TiFlash 副本的代价估算自行决定是否将查询下推至 TiFlash。需要注意的是,只有当前会话的 <a href="/zh/tidb/stable/sql-mode">SQL 模式</a>为非严格模式(即 <code>sql_mode</code> 值不包含 <code>STRICT_TRANS_TABLES</code> 和 <code>STRICT_ALL_TABLES</code>)时,TiDB 才允许将包含增删改的 SQL 语句(如 <code>INSERT INTO SELECT</code>)中的读取操作下推至 TiFlash。</p></li></ul><h3 id="tidb_enable_tmp_storage_on_oom" style="position:relative"><a href="#tidb_enable_tmp_storage_on_oom" aria-label="tidb_enable_tmp_storage_on_oom permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_tmp_storage_on_oom</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>设置是否在单条 SQL 语句的内存使用超出系统变量 <a href="/zh/tidb/stable/system-variables#tidb_mem_quota_query"><code>tidb_mem_quota_query</code></a> 限制时为某些算子启用临时磁盘。</li><li>在 v6.3.0 之前这个开关可通过 TiDB 配置文件中的 <code>oom-use-tmp-storage</code> 项进行配置。在升级到 v6.3.0 及更新的版本后,集群会自动使用原 <code>oom-use-tmp-storage</code> 的值来初始化该开关,配置文件中 <code>oom-use-tmp-storage</code> 的新设置不再影响该开关。</li></ul><h3 id="tidb_enable_top_sql-span-classversion-mark从-v540-版本开始引入span" style="position:relative"><a href="#tidb_enable_top_sql-span-classversion-mark%E4%BB%8E-v540-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_top_sql span classversion mark从 v540 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_top_sql</code> <span class="version-mark">从 v5.4.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>Top SQL 目前是实验性功能,不建议在生产环境中使用。</p></div></div></div><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制是否开启 <a href="/zh/tidb/stable/top-sql">Top SQL 特性</a>。</li></ul><h3 id="tidb_enable_tso_follower_proxy-span-classversion-mark从-v530-版本开始引入span" style="position:relative"><a href="#tidb_enable_tso_follower_proxy-span-classversion-mark%E4%BB%8E-v530-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_tso_follower_proxy span classversion mark从 v530 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_tso_follower_proxy</code> <span class="version-mark">从 v5.3.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来开启 TSO Follower Proxy 特性。当该值为 <code>OFF</code> 时,TiDB 仅会从 PD leader 获取 TSO。开启该特性之后,TiDB 在获取 TSO 时会将请求均匀地发送到所有 PD 节点上,通过 PD follower 转发 TSO 请求,从而降低 PD leader 的 CPU 压力。</li><li>适合开启 TSO Follower Proxy 的场景:<ul><li>PD leader 因高压力的 TSO 请求而达到 CPU 瓶颈,导致 TSO RPC 请求的延迟较高。</li><li>集群中的 TiDB 实例数量较多,且调高 <a href="/zh/tidb/stable/system-variables#tidb_tso_client_batch_max_wait_time-从-v530-版本开始引入"><code>tidb_tso_client_batch_max_wait_time</code></a> 并不能缓解 TSO RPC 请求延迟高的问题。</li></ul></li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>如果 PD leader 的 TSO RPC 延迟升高,但其现象并非由 CPU 使用率达到瓶颈而导致(可能存在网络等问题),此时,打开 TSO Follower Proxy 可能会导致 TiDB 的语句执行延迟上升,从而影响集群的 QPS 表现。</p></div></div></div><h3 id="tidb_enable_unsafe_substitute-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_enable_unsafe_substitute-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_unsafe_substitute span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_unsafe_substitute</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制是否对生成列中表达式替换使用不安全的替换方式。默认值为 <code>OFF</code>,即默认关闭不安全的替换方式。详情见<a href="/zh/tidb/stable/generated-columns">生成列</a>。</li></ul><h3 id="tidb_enable_vectorized_expression-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_enable_vectorized_expression-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_vectorized_expression span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_vectorized_expression</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于控制是否开启向量化执行。</li></ul><h3 id="tidb_enable_window_function" style="position:relative"><a href="#tidb_enable_window_function" aria-label="tidb_enable_window_function permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_window_function</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制是否开启窗口函数的支持。默认值 1 代表开启窗口函数的功能。</li><li>由于窗口函数会使用一些保留关键字,可能导致原先可以正常执行的 SQL 语句在升级 TiDB 后无法被解析语法,此时可以将 <code>tidb_enable_window_function</code> 设置为 <code>OFF</code>。</li></ul><h3 id="tidb_enable_row_level_checksum-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#tidb_enable_row_level_checksum-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enable_row_level_checksum span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enable_row_level_checksum</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制是否开启 <a href="/zh/tidb/stable/ticdc-integrity-check">TiCDC 单行数据正确性校验</a>功能。</li></ul><h3 id="tidb_enforce_mpp-span-classversion-mark从-v51-版本开始引入span" style="position:relative"><a href="#tidb_enforce_mpp-span-classversion-mark%E4%BB%8E-v51-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_enforce_mpp span classversion mark从 v51 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_enforce_mpp</code> <span class="version-mark">从 v5.1 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code>(表示关闭)。如需修改此变量的默认值,请配置 <a href="/zh/tidb/stable/tidb-configuration-file#enforce-mpp"><code>performance.enforce-mpp</code></a> 参数。</li><li>这个变量用于控制是否忽略优化器代价估算,强制使用 TiFlash 的 MPP 模式执行查询,可以设置的值包括:<ul><li>0 或 OFF,代表不强制使用 MPP 模式(默认)</li><li>1 或 ON,代表将忽略代价估算,强制使用 MPP 模式。注意:只有当 <code>tidb_allow_mpp=true</code> 时该设置才生效。</li></ul></li></ul><p>MPP 是 TiFlash 引擎提供的分布式计算框架,允许节点之间的数据交换并提供高性能、高吞吐的 SQL 算法。MPP 模式选择的详细说明参见<a href="/zh/tidb/stable/use-tiflash-mpp-mode#控制是否选择-mpp-模式">控制是否选择 MPP 模式</a>。</p><h3 id="tidb_evolve_plan_baselines-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_evolve_plan_baselines-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_evolve_plan_baselines span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_evolve_plan_baselines</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li><p>作用域:SESSION | GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:布尔型</p></li><li><p>默认值:<code>OFF</code></p></li><li><p>这个变量用于控制是否启用自动演进绑定功能。该功能的详细介绍和使用方法可以参考<a href="/zh/tidb/stable/sql-plan-management#自动演进绑定-baseline-evolution">自动演进绑定</a>。</p></li><li><p>为了减少自动演进对集群的影响,可以进行以下配置:</p><ul><li>设置 <code>tidb_evolve_plan_task_max_time</code>,限制每个执行计划运行的最长时间,其默认值为 600s;</li><li>设置<code>tidb_evolve_plan_task_start_time</code> 和 <code>tidb_evolve_plan_task_end_time</code>,限制运行演进任务的时间窗口,默认值分别为 <code>00:00 +0000</code> 和 <code>23:59 +0000</code>。</li></ul></li></ul><h3 id="tidb_evolve_plan_task_end_time-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_evolve_plan_task_end_time-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_evolve_plan_task_end_time span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_evolve_plan_task_end_time</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:时间</li><li>默认值:<code>23:59 +0000</code></li><li>这个变量用来设置一天中允许自动演进的结束时间。</li></ul><h3 id="tidb_evolve_plan_task_max_time-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_evolve_plan_task_max_time-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_evolve_plan_task_max_time span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_evolve_plan_task_max_time</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>600</code></li><li>范围:<code>[-1, 9223372036854775807]</code></li><li>单位:秒</li><li>该变量用于限制自动演进功能中,每个执行计划运行的最长时间。</li></ul><h3 id="tidb_evolve_plan_task_start_time-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_evolve_plan_task_start_time-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_evolve_plan_task_start_time span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_evolve_plan_task_start_time</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:时间</li><li>默认值:<code>00:00 +0000</code></li><li>这个变量用来设置一天中允许自动演进的开始时间。</li></ul><h3 id="tidb_executor_concurrency-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_executor_concurrency-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_executor_concurrency span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_executor_concurrency</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>5</code></li><li>范围:<code>[1, 256]</code></li><li>单位:线程</li></ul><p>变量用来统一设置各个 SQL 算子的并发度,包括:</p><ul><li><code>index lookup</code></li><li><code>index lookup join</code></li><li><code>hash join</code></li><li><code>hash aggregation</code>(partial 和 final 阶段)</li><li><code>window</code></li><li><code>projection</code></li></ul><p><code>tidb_executor_concurrency</code> 整合了已有的系统变量,方便管理。这些变量所列如下:</p><ul><li><code>tidb_index_lookup_concurrency</code></li><li><code>tidb_index_lookup_join_concurrency</code></li><li><code>tidb_hash_join_concurrency</code></li><li><code>tidb_hashagg_partial_concurrency</code></li><li><code>tidb_hashagg_final_concurrency</code></li><li><code>tidb_projection_concurrency</code></li><li><code>tidb_window_concurrency</code></li></ul><p>v5.0 后,用户仍可以单独修改以上系统变量(会有废弃警告),且修改只影响单个算子。后续通过 <code>tidb_executor_concurrency</code> 的修改也不会影响该算子。若要通过 <code>tidb_executor_concurrency</code> 来管理所有算子的并发度,需要将以上所列变量的值设置为 <code>-1</code>。</p><p>对于从 v5.0 之前的版本升级到 v5.0 的系统,如果用户对上述所列变量的值没有做过改动(即 <code>tidb_hash_join_concurrency</code> 值为 <code>5</code>,其他值为 <code>4</code>),则会自动转为使用 <code>tidb_executor_concurrency</code> 来统一管理算子并发度。如果用户对上述变量的值做过改动,则沿用之前的变量对相应的算子做并发控制。</p><h3 id="tidb_expensive_query_time_threshold" style="position:relative"><a href="#tidb_expensive_query_time_threshold" aria-label="tidb_expensive_query_time_threshold permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_expensive_query_time_threshold</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:整数型</li><li>默认值:<code>60</code></li><li>范围:<code>[10, 2147483647]</code></li><li>单位:秒</li><li>这个变量用来控制打印 expensive query 日志的阈值时间,默认值是 60 秒。expensive query 日志和慢日志的差别是,慢日志是在语句执行完后才打印,expensive query 日志可以把正在执行中的语句且执行时间超过阈值的语句及其相关信息打印出来。</li></ul><h3 id="tidb_force_priority" style="position:relative"><a href="#tidb_force_priority" aria-label="tidb_force_priority permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_force_priority</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:枚举型</li><li>默认值:<code>NO_PRIORITY</code></li><li>可选值:<code>NO_PRIORITY</code>、<code>LOW_PRIORITY</code>、<code>DELAYED</code>、<code>HIGH_PRIORITY</code></li><li>这个变量用于改变 TiDB server 上执行的语句的默认优先级。例如,你可以通过设置该变量来确保正在执行 OLAP 查询的用户优先级低于正在执行 OLTP 查询的用户。</li><li>默认值 <code>NO_PRIORITY</code> 表示不强制改变执行语句的优先级。</li></ul><h3 id="tidb_gc_concurrency-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_gc_concurrency-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_gc_concurrency span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_gc_concurrency</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>范围:<code>[1, 256]</code></li><li>单位:线程</li><li>这个变量用于指定 GC 在<a href="/zh/tidb/stable/garbage-collection-overview#resolve-locks清理锁">Resolve Locks(清理锁)</a>步骤中线程的数量。默认值 <code>-1</code> 表示由 TiDB 自主判断运行 GC 要使用的线程的数量。</li></ul><h3 id="tidb_gc_enable-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_gc_enable-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_gc_enable span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_gc_enable</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于控制是否启用 TiKV 的垃圾回收 (GC) 机制。如果不启用 GC 机制,系统将不再清理旧版本的数据,因此会有损系统性能。</li></ul><h3 id="tidb_gc_life_time-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_gc_life_time-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_gc_life_time span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_gc_life_time</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:Duration</li><li>默认值:<code>10m0s</code></li><li>范围:<code>[10m0s, 8760h0m0s]</code></li><li>这个变量用于指定每次进行垃圾回收 (GC) 时保留数据的时限。变量值为 Go 的 Duration 字符串格式。每次进行 GC 时,将以当前时间减去该变量的值作为 safe point。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li>在数据频繁更新的场景下,将 <code>tidb_gc_life_time</code> 的值设置得过大(如数天甚至数月)可能会导致一些潜在的问题,如:<ul><li>占用更多的存储空间。</li><li>大量的历史数据可能会在一定程度上影响系统性能,尤其是范围的查询(如 <code>select count(*) from t</code>)。</li></ul></li><li>如果一个事务的运行时长超过了 <code>tidb_gc_life_time</code> 配置的值,在 GC 时,为了使这个事务可以继续正常运行,系统会保留从这个事务开始时间 <code>start_ts</code> 以来的数据。例如,如果 <code>tidb_gc_life_time</code> 的值配置为 10 分钟,且在一次 GC 时,集群正在运行的事务中最早开始的那个事务已经运行了 15 分钟,那么本次 GC 将保留最近 15 分钟的数据。</li></ul></div></div></div><h3 id="tidb_gc_max_wait_time-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_gc_max_wait_time-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_gc_max_wait_time span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_gc_max_wait_time</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>86400</code></li><li>范围:<code>[600, 31536000]</code></li><li>单位:秒</li><li>这个变量用于指定活跃事务阻碍 GC safe point 推进的最大时间。每次进行 GC 时,默认 GC safe point 不会超过正在执行中的事务的开始时间。如果活跃事务运行时间未超过该值,GC safe point 会一直被阻塞不更新,直到活跃事务运行时间超过该值 safe point 才会正常推进。</li></ul><h3 id="tidb_gc_run_interval-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_gc_run_interval-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_gc_run_interval span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_gc_run_interval</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:Duration</li><li>默认值:<code>10m0s</code></li><li>范围:<code>[10m0s, 8760h0m0s]</code></li><li>这个变量用于指定垃圾回收 (GC) 运行的时间间隔。变量值为 Go 的 Duration 字符串格式,如<code>"1h30m"</code>、<code>"15m"</code>等。</li></ul><h3 id="tidb_gc_scan_lock_mode-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_gc_scan_lock_mode-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_gc_scan_lock_mode span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_gc_scan_lock_mode</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>Green GC 目前是实验性功能,不建议在生产环境中使用。</p></div></div></div><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>LEGACY</code></li><li>可设置为:<code>PHYSICAL</code>,<code>LEGACY</code><ul><li><code>LEGACY</code>:使用旧的扫描方式,即禁用 Green GC。</li><li><code>PHYSICAL</code>:使用物理扫描方式,即启用 Green GC。</li></ul></li><li>这个变量用于指定垃圾回收 (GC) 的 Resolve Locks(清理锁)步骤中扫描锁的方式。当变量值设置为 <code>LEGACY</code> 时,TiDB 以 Region 为单位进行扫描。当变量值设置为 <code>PHYSICAL</code> 时,每个 TiKV 节点分别绕过 Raft 层直接扫描数据,可以有效地缓解在启用 <a href="/zh/tidb/stable/tikv-configuration-file#hibernate-regions">Hibernate Region</a> 功能时,GC 唤醒全部 Region 的影响,从而提升 Resolve Locks(清理锁)这个步骤的执行速度。</li></ul><h3 id="tidb_general_log" style="position:relative"><a href="#tidb_general_log" aria-label="tidb_general_log permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_general_log</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来设置是否在<a href="/zh/tidb/stable/tidb-configuration-file#logfile">日志</a>里记录所有的 SQL 语句。该功能默认关闭。如果系统运维人员在定位问题过程中需要追踪所有 SQL 记录,可考虑开启该功能。</li><li>在 TiDB 配置项 <a href="/zh/tidb/stable/tidb-configuration-file#level"><code>log.level</code></a> 为 <code>"info"</code> 或 <code>"debug"</code> 时,通过查询 <code>"GENERAL_LOG"</code> 字符串可以定位到该功能在日志中的所有记录。日志会记录以下内容:<ul><li><code>conn</code>:当前会话对应的 ID</li><li><code>user</code>:当前会话用户</li><li><code>schemaVersion</code>:当前 schema 版本</li><li><code>txnStartTS</code>:当前事务的开始时间戳</li><li><code>forUpdateTS</code>:事务模式为悲观事务时,SQL 语句的当前时间戳。悲观事务内发生写冲突时,会重试当前执行语句,该时间戳会被更新。重试次数由 <a href="/zh/tidb/stable/tidb-configuration-file#max-retry-count"><code>max-retry-count</code></a> 配置。事务模式为乐观事务时,该条目与 <code>txnStartTS</code> 等价。</li><li><code>isReadConsistency</code>:当前事务隔离级别是否是读已提交 (RC)</li><li><code>current_db</code>:当前数据库名</li><li><code>txn_mode</code>:事务模式。可选值:<code>OPTIMISTIC</code>(乐观事务模式),或 <code>PESSIMISTIC</code>(悲观事务模式)</li><li><code>sql</code>:当前查询对应的 SQL 语句</li></ul></li></ul><h3 id="tidb_non_prepared_plan_cache_size" style="position:relative"><a href="#tidb_non_prepared_plan_cache_size" aria-label="tidb_non_prepared_plan_cache_size permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_non_prepared_plan_cache_size</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>从 v7.1.0 开始,该变量被废弃。请使用 <a href="#tidb_session_plan_cache_size-%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_session_plan_cache_size</code></a> 进行设置。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>100</code></li><li>范围:<code>[1, 100000]</code></li><li>这个变量用来控制<a href="/zh/tidb/stable/sql-non-prepared-plan-cache">非 Prepare 语句执行计划缓存</a>最多能够缓存的计划数量。</li></ul><h3 id="tidb_generate_binary_plan-span-classversion-mark从-v620-版本开始引入span" style="position:relative"><a href="#tidb_generate_binary_plan-span-classversion-mark%E4%BB%8E-v620-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_generate_binary_plan span classversion mark从 v620 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_generate_binary_plan</code> <span class="version-mark">从 v6.2.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于指定是否在 slow log 和 statement summary 里包含以二进制格式编码的执行计划。</li><li>开启该变量后,即可在 TiDB Dashboard 中查看查询的图形化执行计划。注意,TiDB Dashboard 只显示变量开启时产生的查询的执行计划。</li><li>用 <code>select tidb_decode_binary_plan('xxx...')</code> SQL 语句可以从编码后的执行计划解析出具体的执行计划。</li></ul><h3 id="tidb_gogc_tuner_threshold-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_gogc_tuner_threshold-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_gogc_tuner_threshold span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_gogc_tuner_threshold</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>0.6</code></li><li>范围:<code>[0, 0.9)</code></li><li>这个变量用来控制 GOGC Tuner 自动调节的最大内存阈值,超过阈值后 GOGC Tuner 会停止工作。</li></ul><h3 id="tidb_guarantee_linearizability-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_guarantee_linearizability-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_guarantee_linearizability span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_guarantee_linearizability</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>此变量控制异步提交 (Async Commit) 中提交时间戳的计算方式。默认情况下(使用 <code>ON</code> 值),两阶段提交从 PD 服务器请求一个新的时间戳,并使用该时间戳计算最终提交的时间戳,这样可保证所有并发事务可线性化。</li><li>如果将该变量值设为 <code>OFF</code>,从 PD 获取时间戳的操作会被省掉,这种情况下只保证因果一致性但不保证线性一致性。详情请参考 PingCAP 博文 <a href="https://pingcap.com/zh/blog/async-commit-principle" target="_blank" referrerpolicy="no-referrer-when-downgrade">Async Commit 原理介绍</a>。</li><li>对于需要只保证因果一致性的场景,可将此变量设为 <code>OFF</code> 以提升性能。</li></ul><h3 id="tidb_hash_exchange_with_new_collation" style="position:relative"><a href="#tidb_hash_exchange_with_new_collation" aria-label="tidb_hash_exchange_with_new_collation permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_hash_exchange_with_new_collation</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>该值表示是否在开启 new collation 的集群里生成 MPP hash partition exchange 算子。<code>true</code> 表示生成此算子,<code>false</code>表示不生成。</li><li>该变量为 TiDB 内部变量,<strong>不推荐设置该变量</strong>。</li></ul><h3 id="tidb_hash_join_concurrency" style="position:relative"><a href="#tidb_hash_join_concurrency" aria-label="tidb_hash_join_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_hash_join_concurrency</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>从 v5.0 版本开始,该变量被废弃。请使用 <a href="#tidb_executor_concurrency-%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_executor_concurrency</code></a> 进行设置。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>范围:<code>[1, 256]</code></li><li>单位:线程</li><li>这个变量用来设置 hash join 算法的并发度。</li><li>默认值 <code>-1</code> 表示使用 <code>tidb_executor_concurrency</code> 的值。</li></ul><h3 id="tidb_hashagg_final_concurrency" style="position:relative"><a href="#tidb_hashagg_final_concurrency" aria-label="tidb_hashagg_final_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_hashagg_final_concurrency</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>从 v5.0 版本开始,该变量被废弃。请使用 <a href="#tidb_executor_concurrency-%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_executor_concurrency</code></a> 进行设置。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>范围:<code>[1, 256]</code></li><li>单位:线程</li><li>这个变量用来设置并行 hash aggregation 算法 final 阶段的执行并发度。对于聚合函数参数不为 distinct 的情况,HashAgg 分为 partial 和 final 阶段分别并行执行。</li><li>默认值 <code>-1</code> 表示使用 <code>tidb_executor_concurrency</code> 的值。</li></ul><h3 id="tidb_hashagg_partial_concurrency" style="position:relative"><a href="#tidb_hashagg_partial_concurrency" aria-label="tidb_hashagg_partial_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_hashagg_partial_concurrency</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>从 v5.0 版本开始,该变量被废弃。请使用 <a href="#tidb_executor_concurrency-%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_executor_concurrency</code></a> 进行设置。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>范围:<code>[1, 256]</code></li><li>单位:线程</li><li>这个变量用来设置并行 hash aggregation 算法 partial 阶段的执行并发度。对于聚合函数参数不为 distinct 的情况,HashAgg 分为 partial 和 final 阶段分别并行执行。</li><li>默认值 <code>-1</code> 表示使用 <code>tidb_executor_concurrency</code> 的值。</li></ul><h3 id="tidb_historical_stats_duration-span-classversion-mark从-v660-版本开始引入span" style="position:relative"><a href="#tidb_historical_stats_duration-span-classversion-mark%E4%BB%8E-v660-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_historical_stats_duration span classversion mark从 v660 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_historical_stats_duration</code> <span class="version-mark">从 v6.6.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:Duration</li><li>默认值:<code>168h</code>,即 7 天</li><li>这个变量用来控制历史统计信息在存储中的保留时间。</li></ul><h3 id="tidb_ignore_prepared_cache_close_stmt-span-classversion-mark从-v600-版本开始引入span" style="position:relative"><a href="#tidb_ignore_prepared_cache_close_stmt-span-classversion-mark%E4%BB%8E-v600-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_ignore_prepared_cache_close_stmt span classversion mark从 v600 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_ignore_prepared_cache_close_stmt</code> <span class="version-mark">从 v6.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来设置是否忽略关闭 Prepared Statement 的指令。</li><li>如果变量值设为 <code>ON</code>,Binary 协议的 <code>COM_STMT_CLOSE</code> 信号和文本协议的 <a href="/zh/tidb/stable/sql-statement-deallocate"><code>DEALLOCATE PREPARE</code></a> 语句都会被忽略。</li></ul><h3 id="tidb_index_join_batch_size" style="position:relative"><a href="#tidb_index_join_batch_size" aria-label="tidb_index_join_batch_size permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_index_join_batch_size</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>25000</code></li><li>范围:<code>[1, 2147483647]</code></li><li>单位:行</li><li>这个变量用来设置 index lookup join 操作的 batch 大小,AP 类应用适合较大的值,TP 类应用适合较小的值。</li></ul><h3 id="tidb_index_join_double_read_penalty_cost_rate-span-classversion-mark从-v660-版本开始引入span" style="position:relative"><a href="#tidb_index_join_double_read_penalty_cost_rate-span-classversion-mark%E4%BB%8E-v660-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_index_join_double_read_penalty_cost_rate span classversion mark从 v660 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_index_join_double_read_penalty_cost_rate</code> <span class="version-mark">从 v6.6.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 18446744073709551615]</code></li><li>这个变量用来设置是否给选择 index join 增加一些惩罚性的代价,以降低优化器选择 index join 操作的倾向,从而增加选择其他 join 方式的倾向,例如如选择 hash join 和 tiflash join 等。</li><li>优化器选择 index join 可能触发较多的回表请求,造成较多的资源开销,此时可以通过设置这个变量,来减少优化器选择 index join 的倾向。</li><li>这个变量只有在 <a href="/zh/tidb/stable/system-variables#tidb_cost_model_version-从-v620-版本开始引入"><code>tidb_cost_model_version</code></a> 设置为 <code>2</code> 时生效。</li></ul><h3 id="tidb_index_lookup_concurrency" style="position:relative"><a href="#tidb_index_lookup_concurrency" aria-label="tidb_index_lookup_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_index_lookup_concurrency</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>从 v5.0 版本开始,该变量被废弃。请使用 <a href="#tidb_executor_concurrency-%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_executor_concurrency</code></a> 进行设置。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>-1</code></li><li>范围:<code>[1, 256]</code></li><li>单位:线程</li><li>这个变量用来设置 index lookup 操作的并发度,AP 类应用适合较大的值,TP 类应用适合较小的值。</li><li>默认值 <code>-1</code> 表示使用 <code>tidb_executor_concurrency</code> 的值。</li></ul><h3 id="tidb_index_lookup_join_concurrency" style="position:relative"><a href="#tidb_index_lookup_join_concurrency" aria-label="tidb_index_lookup_join_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_index_lookup_join_concurrency</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>从 v5.0 版本开始,该变量被废弃。请使用 <a href="#tidb_executor_concurrency-%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_executor_concurrency</code></a> 进行设置。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>-1</code></li><li>范围:<code>[1, 256]</code></li><li>单位:线程</li><li>这个变量用来设置 index lookup join 算法的并发度。</li><li>默认值 <code>-1</code> 表示使用 <code>tidb_executor_concurrency</code> 的值。</li></ul><h3 id="tidb_index_merge_intersection_concurrency-span-classversion-mark从-v650-版本开始引入span" style="position:relative"><a href="#tidb_index_merge_intersection_concurrency-span-classversion-mark%E4%BB%8E-v650-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_index_merge_intersection_concurrency span classversion mark从 v650 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_index_merge_intersection_concurrency</code> <span class="version-mark">从 v6.5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>-1</code></li><li>范围:<code>[1, 256]</code></li><li>这个变量用来设置索引合并进行交集操作时的最大并发度,仅在以动态裁剪模式访问分区表时有效。实际并发度为 <code>tidb_index_merge_intersection_concurrency</code> 与分区表分区数目两者中较小的值。</li><li>默认值 <code>-1</code> 表示使用 <a href="#tidb_executor_concurrency-%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_executor_concurrency</code></a> 的值。</li></ul><h3 id="tidb_index_lookup_size" style="position:relative"><a href="#tidb_index_lookup_size" aria-label="tidb_index_lookup_size permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_index_lookup_size</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>20000</code></li><li>范围:<code>[1, 2147483647]</code></li><li>单位:行</li><li>这个变量用来设置 index lookup 操作的 batch 大小,AP 类应用适合较大的值,TP 类应用适合较小的值。</li></ul><h3 id="tidb_index_serial_scan_concurrency" style="position:relative"><a href="#tidb_index_serial_scan_concurrency" aria-label="tidb_index_serial_scan_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_index_serial_scan_concurrency</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1</code></li><li>范围:<code>[1, 256]</code></li><li>单位:线程</li><li>这个变量用来设置顺序 scan 操作的并发度,AP 类应用适合较大的值,TP 类应用适合较小的值。</li></ul><h3 id="tidb_init_chunk_size" style="position:relative"><a href="#tidb_init_chunk_size" aria-label="tidb_init_chunk_size permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_init_chunk_size</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>32</code></li><li>范围:<code>[1, 32]</code></li><li>单位:行</li><li>这个变量用来设置执行过程中初始 chunk 的行数。默认值是 32,可设置的范围是 1~32。</li></ul><h3 id="tidb_isolation_read_engines-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_isolation_read_engines-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_isolation_read_engines span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_isolation_read_engines</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>默认值:<code>tikv,tiflash,tidb</code></li><li>这个变量用于设置 TiDB 在读取数据时可以使用的存储引擎列表。</li></ul><h3 id="tidb_last_ddl_info-span-classversion-mark从-v600-版本开始引入span" style="position:relative"><a href="#tidb_last_ddl_info-span-classversion-mark%E4%BB%8E-v600-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_last_ddl_info span classversion mark从 v600 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_last_ddl_info</code> <span class="version-mark">从 v6.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>默认值:""</li><li>类型:字符串</li><li>该变量为只读变量,TiDB 内部使用该变量获取当前会话中上一个 DDL 操作的信息。<ul><li>"query":上一个 DDL 查询字符串。</li><li>"seq_num":每个 DDL 操作的序列号,用于标识 DDL 操作的顺序。</li></ul></li></ul><h3 id="tidb_last_query_info-span-classversion-mark从-v4014-版本开始引入span" style="position:relative"><a href="#tidb_last_query_info-span-classversion-mark%E4%BB%8E-v4014-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_last_query_info span classversion mark从 v4014 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_last_query_info</code> <span class="version-mark">从 v4.0.14 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>默认值:""</li><li>这是一个只读变量。用于在 TiDB 内部查询上一条 DML 语句的事务信息。查询的事务信息包括:<ul><li><code>txn_scope</code>:事务的作用域,可能为 <code>global</code> 或 <code>local</code>。</li><li><code>start_ts</code>:事务开始的时间戳。</li><li><code>for_update_ts</code>:先前执行的 DML 语句的 <code>for_update_ts</code> 信息。这是 TiDB 用于测试的内部术语。通常,你可以忽略此信息。</li><li><code>error</code>:错误消息(如果有)。</li></ul></li></ul><h3 id="tidb_last_txn_info-span-classversion-mark从-v409-版本开始引入span" style="position:relative"><a href="#tidb_last_txn_info-span-classversion-mark%E4%BB%8E-v409-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_last_txn_info span classversion mark从 v409 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_last_txn_info</code> <span class="version-mark">从 v4.0.9 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:字符串</li><li>此变量用于获取当前会话中最后一个事务的信息。这是一个只读变量。事务信息包括:<ul><li>事务的范围</li><li>开始时间戳和提交时间戳</li><li>事务的提交模式,可能是两阶段提交,一阶段提交,或者异步提交</li><li>事务从异步提交或一阶段提交到两阶段提交的回退信息</li><li>遇到的错误</li></ul></li></ul><h3 id="tidb_last_plan_replayer_token-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_last_plan_replayer_token-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_last_plan_replayer_token span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_last_plan_replayer_token</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:字符串</li><li>这个变量是一个只读变量,用于获取当前会话中最后一个 <code>PLAN REPLAYER dump</code> 的结果。</li></ul><h3 id="tidb_load_based_replica_read_threshold-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_load_based_replica_read_threshold-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_load_based_replica_read_threshold span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_load_based_replica_read_threshold</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>"1s"</code></li><li>范围:<code>[0s, 1h]</code></li><li>类型:字符串</li><li>这个变量用来设置基于负载的 replica read 的触发阈值。当 leader 节点的预估排队时间超过阈值时,TiDB 会优先从 follower 节点读取数据。格式为时间,例如 <code>"100ms"</code> 或 <code>"1s"</code>。详情见 <a href="/zh/tidb/stable/troubleshoot-hot-spot-issues#打散读热点">TiDB 热点问题处理</a>。</li></ul><h3 id="tidb_lock_unchanged_keys-span-classversion-mark从-v711-版本开始引入span" style="position:relative"><a href="#tidb_lock_unchanged_keys-span-classversion-mark%E4%BB%8E-v711-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_lock_unchanged_keys span classversion mark从 v711 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_lock_unchanged_keys</code> <span class="version-mark">从 v7.1.1 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>该变量控制在以下场景是否对某些 key 加锁。设置为 <code>ON</code> 时,都加锁,设置为 <code>OFF</code> 时,都不加锁。<ul><li>在 <code>INSERT IGNORE</code> 语句和 <code>REPLACE</code> 语句中值重复的 key。在 v6.1.6 之前版本中,这些 key 不加锁。这个问题已在 <a href="https://github.com/pingcap/tidb/issues/42121" target="_blank" referrerpolicy="no-referrer-when-downgrade">#42121</a> 修复。</li><li>在 <code>UPDATE</code> 语句中值没有改变的唯一索引 key。在 v6.5.2 之前版本中,这些 key 不加锁。这个问题已在 <a href="https://github.com/pingcap/tidb/issues/36438" target="_blank" referrerpolicy="no-referrer-when-downgrade">#36438</a> 修复。</li></ul></li><li>为保证事务行为的一致性和合理性,不推荐修改该值。如果在升级 TiDB 后因为这两项修复导致严重的性能问题,且可以接受不加锁的行为(见上述 Issue),可以将该变量设置为 <code>OFF</code>。</li></ul><h3 id="tidb_log_file_max_days-span-classversion-mark从-v530-版本开始引入span" style="position:relative"><a href="#tidb_log_file_max_days-span-classversion-mark%E4%BB%8E-v530-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_log_file_max_days span classversion mark从 v530 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_log_file_max_days</code> <span class="version-mark">从 v5.3.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 2147483647]</code></li><li>这个变量可以调整当前 TiDB 实例上日志的最大保留天数。默认值是实例配置文件中指定的值,见配置项 <a href="/zh/tidb/stable/tidb-configuration-file#max-days"><code>max-days</code></a>。此变量只影响当前 TiDB 实例上的配置,重启后丢失,且配置文件不受影响。</li></ul><h3 id="tidb_low_resolution_tso" style="position:relative"><a href="#tidb_low_resolution_tso" aria-label="tidb_low_resolution_tso permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_low_resolution_tso</code></h3><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来设置是否启用低精度 TSO 特性。开启该功能之后,新事务会使用一个每 2s 更新一次的 TS 来读取数据。</li><li>主要场景是在可以容忍读到旧数据的情况下,降低小的只读事务获取 TSO 的开销。</li></ul><h3 id="tidb_nontransactional_ignore_error-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_nontransactional_ignore_error-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_nontransactional_ignore_error span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_nontransactional_ignore_error</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来设置是否在非事务语句中立刻返回错误。当设为 <code>OFF</code> 时,在碰到第一个报错的 batch 时,非事务 DML 语句即中止,取消其后的所有 batch,返回错误。当设为 <code>ON</code> 时,当某个 batch 执行报错时,其后的 batch 会继续执行,直到所有 batch 执行完毕,返回结果时把这些错误合并后返回。</li></ul><h3 id="tidb_max_auto_analyze_time-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_max_auto_analyze_time-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_max_auto_analyze_time span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_max_auto_analyze_time</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>43200</code></li><li>范围:<code>[0, 2147483647]</code></li><li>单位:秒</li><li>这个变量用于指定自动 ANALYZE 的最大执行时间。当执行时间超出指定的时间时,自动 ANALYZE 会被终止。当该变量值为 0 时,自动 ANALYZE 没有最大执行时间的限制。</li></ul><h3 id="tidb_max_bytes_before_tiflash_external_group_by-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_max_bytes_before_tiflash_external_group_by-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_max_bytes_before_tiflash_external_group_by span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_max_bytes_before_tiflash_external_group_by</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>范围:<code>[-1, 9223372036854775807]</code></li><li>这个变量用于指定 TiFlash 中带有 <code>GROUP BY</code> 的 Hash Aggregation 算子的最大内存使用量,单位为 byte,超过该值之后 TiFlash 会触发 Hash Aggregation 算子的落盘。当该变量值为 -1 时,TiDB 不传递该变量给 TiFlash。只有该变量值大于等于 0 时,TiDB 才会传递该变量给 TiFlash。该变量为 0 时表示内存使用无限制,即 TiFlash Hash Aggregation 算子不会触发落盘。详情见 <a href="/zh/tidb/stable/tiflash-spill-disk">TiFlash 数据落盘</a>。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li>假设一个 TiDB 集群有多个 TiFlash 节点,Aggregation 通常会在多个 TiFlash 节点上分布式执行。该变量控制的是单个 TiFlash 节点中 Aggregation 算子的最大内存使用量。</li><li>当该变量设置为 -1 时,TiFlash 将根据自身配置项 <a href="/zh/tidb/stable/tiflash-configuration#tiflash-配置参数-1"><code>max_bytes_before_external_group_by</code></a> 的值来决定 Aggregation 算子的最大内存使用量。</li></ul></div></div></div><h3 id="tidb_max_bytes_before_tiflash_external_join-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_max_bytes_before_tiflash_external_join-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_max_bytes_before_tiflash_external_join span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_max_bytes_before_tiflash_external_join</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>范围:<code>[-1, 9223372036854775807]</code></li><li>这个变量用于指定 TiFlash 中带等值关联条件的 Hash Join 算子的最大内存使用量,单位为 byte,超过该值之后 TiFlash 会触发 Hash Join 算子的落盘。当该变量值为 -1 时,TiDB 不传递该变量给 TiFlash。只有该变量值大于等于 0 时,TiDB 才会传递该变量给 TiFlash。该变量为 0 时表示内存使用无限制,即 TiFlash Hash Join 算子不会触发落盘。详情见 <a href="/zh/tidb/stable/tiflash-spill-disk">TiFlash 数据落盘</a>。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li>假设一个 TiDB 集群有多个 TiFlash 节点,Join 通常会在多个 TiFlash 节点上分布式执行。该变量控制的是单个 TiFlash 节点中 Join 算子的最大内存使用量。</li><li>当该变量设置为 -1 时,TiFlash 将根据自身配置项 <a href="/zh/tidb/stable/tiflash-configuration#tiflash-配置参数-1"><code>max_bytes_before_external_join</code></a> 的值来决定 Join 算子的最大内存使用量。</li></ul></div></div></div><h3 id="tidb_max_bytes_before_tiflash_external_sort-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_max_bytes_before_tiflash_external_sort-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_max_bytes_before_tiflash_external_sort span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_max_bytes_before_tiflash_external_sort</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>范围:<code>[-1, 9223372036854775807]</code></li><li>这个变量用于指定 TiFlash 中带 topN 和 sort 算子的最大内存使用量,单位为 byte,超过该值之后 TiFlash 会触发 topN 和 sort 算子的落盘。当该变量值为 -1 时,TiDB 不传递该变量给 TiFlash。只有该变量值大于等于 0 时,TiDB 才会传递该变量给 TiFlash。该变量为 0 时表示内存使用无限制,即 TiFlash topN 和 sort 算子不会触发落盘。详情见 <a href="/zh/tidb/stable/tiflash-spill-disk">TiFlash 数据落盘</a>。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li>假设一个 TiDB 集群有多个 TiFlash 节点,TopN 和 Sort 通常会在多个 TiFlash 节点中分布式执行。该变量控制的是单个 TiFlash 节点中 TopN 和 Sort 算子的最大内存使用量。</li><li>当该变量设置为 -1 时,TiFlash 将根据自身配置项 <a href="/zh/tidb/stable/tiflash-configuration#tiflash-配置参数-1"><code>max_bytes_before_external_sort</code></a> 的值来决定 TopN 和 Sort 算子的最大内存使用量。</li></ul></div></div></div><h3 id="tidb_max_chunk_size" style="position:relative"><a href="#tidb_max_chunk_size" aria-label="tidb_max_chunk_size permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_max_chunk_size</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1024</code></li><li>范围:<code>[32, 2147483647]</code></li><li>单位:行</li><li>这个变量用来设置执行过程中一个 chunk 最大的行数,设置过大可能引起缓存局部性的问题。</li></ul><h3 id="tidb_max_delta_schema_count" style="position:relative"><a href="#tidb_max_delta_schema_count" aria-label="tidb_max_delta_schema_count permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_max_delta_schema_count</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1024</code></li><li>范围:<code>[100, 16384]</code></li><li>这个变量用来设置缓存 schema 版本信息(对应版本修改的相关 table IDs)的个数限制,可设置的范围 100 - 16384。此变量在 2.1.18 及之后版本支持。</li></ul><h3 id="tidb_max_paging_size-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_max_paging_size-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_max_paging_size span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_max_paging_size</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>50000</code></li><li>范围:<code>[1, 9223372036854775807]</code></li><li>单位:行</li><li>这个变量用来设置 coprocessor 协议中 paging size 的最大的行数。请合理设置该值,设置过小,TiDB 与 TiKV 的 RPC 交互会更频繁;设置过大,导数据和全表扫等特定场景会占用更多内存。该变量的默认值对于 OLTP 场景较友好,如果业务只使用了 TiKV 作为存储引擎,当执行偏 OLAP 的负载时,可以考虑将变量值调大,有可能获得更好的性能。</li></ul><h3 id="tidb_max_tiflash_threads-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_max_tiflash_threads-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_max_tiflash_threads span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_max_tiflash_threads</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>范围:<code>[-1, 256]</code></li><li>单位:线程</li><li>TiFlash 中 request 执行的最大并发度。默认值为 <code>-1</code>,表示该系统变量无效。<code>0</code> 表示由 TiFlash 系统自动设置该值。</li></ul><h3 id="tidb_mem_oom_action-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_mem_oom_action-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_mem_oom_action span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_mem_oom_action</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>CANCEL</code></li><li>可选值:<code>CANCEL</code>,<code>LOG</code></li><li>该变量控制当单个查询使用的内存超过限制 (<code>tidb_mem_quota_query</code>) 且不能再利用临时磁盘时,TiDB 所采取的操作。详情见 <a href="/zh/tidb/stable/configure-memory-usage">TiDB 内存控制</a>。</li><li>该变量默认值为 <code>CANCEL</code>,但在 TiDB v4.0.2 及之前的版本中,默认值为 <code>LOG</code>。</li><li>在 v6.1.0 之前这个开关通过 TiDB 配置文件 (<code>oom-action</code>) 进行配置,升级到 v6.1.0 时会自动继承原有设置。</li></ul><h3 id="tidb_mem_quota_analyze-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_mem_quota_analyze-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_mem_quota_analyze span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_mem_quota_analyze</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>目前限制 ANALYZE 的内存使用量为实验特性,在生产环境中使用时可能存在内存统计有误差的情况。</p></div></div></div><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>单位:字节</li><li>取值范围:<code>[-1, 9223372036854775807]</code></li><li>这个变量用来控制 TiDB 更新统计信息时的最大总内存占用,包括用户执行的 <a href="/zh/tidb/stable/sql-statement-analyze-table"><code>ANALYZE TABLE</code></a> 和 TiDB 后台自动执行的统计信息更新任务。当总的内存占用超过这个阈值时,用户执行的 <code>ANALYZE</code> 会被终止退出,并通过错误信息提示用户尝试更小的采样率或稍后重试。如果 TiDB 后台自动执行的统计信息更新任务因内存超限而退出,且使用的采样率高于默认值,则会使用默认采样率重试一次。当该变量值为负数或零时,TiDB 不对更新统计信息的前后台任务进行内存限制。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>只有在 TiDB 的启动配置文件中开启了 <code>run-auto-analyze</code> 选项,该 TiDB 集群才会触发 <code>auto_analyze</code>。</p></div></div></div><h3 id="tidb_mem_quota_apply_cache-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_mem_quota_apply_cache-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_mem_quota_apply_cache span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_mem_quota_apply_cache</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>33554432</code> (32 MiB)</li><li>范围:<code>[0, 9223372036854775807]</code></li><li>单位:字节</li><li>这个变量用来设置 <code>Apply</code> 算子中局部 Cache 的内存使用阈值。</li><li><code>Apply</code> 算子中局部 Cache 用来加速 <code>Apply</code> 算子的计算,该变量可以设置 <code>Apply</code> Cache 的内存使用阈值。设置变量值为 <code>0</code> 可以关闭 <code>Apply</code> Cache 功能。</li></ul><h3 id="tidb_mem_quota_binding_cache-span-classversion-mark从-v600-版本开始引入span" style="position:relative"><a href="#tidb_mem_quota_binding_cache-span-classversion-mark%E4%BB%8E-v600-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_mem_quota_binding_cache span classversion mark从 v600 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_mem_quota_binding_cache</code> <span class="version-mark">从 v6.0.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>67108864</code> (64 MiB)</li><li>范围:<code>[0, 2147483647]</code></li><li>单位:字节</li><li>这个变量用来设置存放 <code>binding</code> 的缓存的内存使用阈值。</li><li>如果一个系统创建或者捕获了过多的绑定,导致绑定所使用的内存空间超过该阈值,TiDB 会在日志中增加警告日志进行提示。这种情况下,缓存无法存放所有可用的绑定,并且无法保证哪些绑定存在于缓存中,因此,可能存在一些查询无法使用可用绑定的情况。此时,可以调大该变量的值,从而保证所有可用绑定都能正常使用。修改变量值以后,需要执行命令 <code>admin reload bindings</code> 重新加载绑定,确保变更生效。</li></ul><h3 id="tidb_mem_quota_query" style="position:relative"><a href="#tidb_mem_quota_query" aria-label="tidb_mem_quota_query permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_mem_quota_query</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1073741824</code> (1 GiB)</li><li>范围:<code>[-1, 9223372036854775807]</code></li><li>单位:字节</li><li>在 v6.1.0 之前的版本中,作用域为 <code>SESSION</code>。v6.1.0 及之后的版本,作用域变更为 <code>SESSION | GLOBAL</code>。</li><li>在 v6.5.0 之前的版本中,该变量用来设置单条查询的内存使用限制,如果单条查询执行过程中使用的内存量超过该阈值,会触发系统变量 <a href="#tidb_mem_oom_action-%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_mem_oom_action</code></a> 中指定的行为。</li><li>在 v6.5.0 及之后的版本中,该变量用来设置单个会话整体的内存使用限制,如果某个会话执行过程中使用的内存量超过该阈值,会触发系统变量 <a href="#tidb_mem_oom_action-%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_mem_oom_action</code></a> 中指定的行为。需要注意的是,自 v6.5.0 版本开始,会话的内存使用量包含会话中事务所消耗的内存。v6.5.0 及之后版本对事务内存的控制行为有所变化,详见 <a href="/zh/tidb/stable/tidb-configuration-file#txn-total-size-limit">txn-total-size-limit</a>。</li><li>当变量值为 <code>0</code> 或 <code>-1</code> 时,表示内存阈值为正无穷。此外,当变量值小于 128 时,将默认被设置为 <code>128</code>。</li></ul><h3 id="tidb_memory_debug_mode_alarm_ratio" style="position:relative"><a href="#tidb_memory_debug_mode_alarm_ratio" aria-label="tidb_memory_debug_mode_alarm_ratio permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_memory_debug_mode_alarm_ratio</code></h3><ul><li>作用域:SESSION</li><li>类型:浮点型</li><li>默认值:<code>0</code></li><li>该变量表示在 TiDB memory debug 模式下,允许的内存统计误差值。</li><li>该变量用于 TiDB 内部测试,<strong>不推荐修改该变量值</strong>。</li></ul><h3 id="tidb_memory_debug_mode_min_heap_inuse" style="position:relative"><a href="#tidb_memory_debug_mode_min_heap_inuse" aria-label="tidb_memory_debug_mode_min_heap_inuse permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_memory_debug_mode_min_heap_inuse</code></h3><ul><li>作用域:SESSION</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>该变量用于 TiDB 内部测试,<strong>不推荐修改该变量值</strong>,因为开启后会影响 TiDB 的性能。</li><li>配置此参数后,TiDB 会进入 memory debug 模式进行内存追踪准确度的分析。TiDB 会在后续执行 SQL 语句的过程中频繁触发 GC,并将实际内存使用和内存统计值做对比。若当前内存使用大于 <code>tidb_memory_debug_mode_min_heap_inuse</code> 且内存统计误差超过 <code>tidb_memory_debug_mode_alarm_ratio</code>,则会输出相关内存信息到日志和文件中。</li></ul><h3 id="tidb_memory_usage_alarm_ratio" style="position:relative"><a href="#tidb_memory_usage_alarm_ratio" aria-label="tidb_memory_usage_alarm_ratio permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_memory_usage_alarm_ratio</code></h3><ul><li><p>作用域:GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:浮点数</p></li><li><p>默认值:<code>0.7</code></p></li><li><p>范围:<code>[0.0, 1.0]</code></p></li><li><p>这个变量用于设置触发 tidb-server 内存告警的内存使用比率。默认情况下,当 TiDB 内存使用量超过总内存的 70% 且满足<a href="/zh/tidb/stable/configure-memory-usage#tidb-server-内存占用过高时的报警">报警条件</a>时,TiDB 会打印报警日志。</p></li><li><p>当配置该变量的值为 <code>0</code> 或 <code>1</code> 时,表示关闭内存阈值报警功能。</p></li><li><p>当配置该变量为 <code>0</code> 到 <code>1</code> 之间的值时,表示开启内存阈值报警功能:</p><ul><li>如果系统变量 <a href="/zh/tidb/stable/system-variables#tidb_server_memory_limit-从-v640-版本开始引入"><code>tidb_server_memory_limit</code></a> 等于 0,则内存报警阈值为 <code>tidb_memory_usage_alarm_ratio * 系统内存大小</code>。</li><li>如果系统变量 <code>tidb_server_memory_limit</code> 被设置为大于 0,则内存报警阈值为 <code>tidb_memory_usage_alarm_ratio * tidb_server_memory_limit</code>。</li></ul></li></ul><h3 id="tidb_memory_usage_alarm_keep_record_num-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_memory_usage_alarm_keep_record_num-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_memory_usage_alarm_keep_record_num span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_memory_usage_alarm_keep_record_num</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>5</code></li><li>范围:<code>[1, 10000]</code></li><li>当 tidb-server 内存占用超过内存报警阈值并触发报警时,TiDB 默认只保留最近 5 次报警时所生成的状态文件。你可以通过该变量调整该次数。</li></ul><h3 id="tidb_merge_join_concurrency" style="position:relative"><a href="#tidb_merge_join_concurrency" aria-label="tidb_merge_join_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_merge_join_concurrency</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1</code></li><li>取值范围:<code>[1, 256]</code></li><li>设置 <code>MergeJoin</code> 算子执行查询时的并发度。</li><li><strong>不推荐设置该变量</strong>,修改该变量值可能会造成数据正确性问题。</li></ul><h3 id="tidb_merge_partition_stats_concurrency" style="position:relative"><a href="#tidb_merge_partition_stats_concurrency" aria-label="tidb_merge_partition_stats_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_merge_partition_stats_concurrency</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>当前版本中该变量控制的功能尚未完全生效,请保留默认值。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>1</code></li><li>这个变量用于 TiDB analyze 分区表时,对分区表统计信息进行合并时的并发度。</li></ul><h3 id="tidb_metric_query_range_duration-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_metric_query_range_duration-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_metric_query_range_duration span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_metric_query_range_duration</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:整数型</li><li>默认值:<code>60</code></li><li>范围:<code>[10, 216000]</code></li><li>单位:秒</li><li>这个变量设置了查询 <code>METRIC_SCHEMA</code> 时生成的 Prometheus 语句的 range duration。</li></ul><h3 id="tidb_metric_query_step-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_metric_query_step-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_metric_query_step span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_metric_query_step</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:整数型</li><li>默认值:<code>60</code></li><li>范围:<code>[10, 216000]</code></li><li>单位:秒</li><li>这个变量设置了查询 <code>METRIC_SCHEMA</code> 时生成的 Prometheus 语句的 step。</li></ul><h3 id="tidb_min_paging_size-span-classversion-mark从-v620-版本开始引入span" style="position:relative"><a href="#tidb_min_paging_size-span-classversion-mark%E4%BB%8E-v620-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_min_paging_size span classversion mark从 v620 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_min_paging_size</code> <span class="version-mark">从 v6.2.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>128</code></li><li>范围:<code>[1, 9223372036854775807]</code></li><li>单位:行</li><li>这个变量用来设置 coprocessor 协议中 paging size 的最小的行数。请合理设置该值,设置过小,TiDB 与 TiKV 的 RPC 交互会更频繁;设置过大,IndexLookup 带 Limit 场景会出现性能下降。该变量的默认值对于 OLTP 场景较友好,如果业务只使用了 TiKV 作为存储引擎,当执行偏 OLAP 的负载时,可以考虑将变量值调大,有可能获得更好的性能。</li></ul><p><img src="https://download.pingcap.com/images/docs-cn/paging-size-impact-on-tpch.png" alt="Paging size impact on TPCH"/></p><p>开启 <a href="#tidb_enable_paging-%E4%BB%8E-v540-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_enable_paging</code></a> 时,<code>tidb_min_paging_size</code> 和 <a href="#tidb_max_paging_size-%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_max_paging_size</code></a> 对 TPCH 的性能影响如上图所示,纵轴是执行时间,越小越好。</p><h3 id="tidb_mpp_store_fail_ttl" style="position:relative"><a href="#tidb_mpp_store_fail_ttl" aria-label="tidb_mpp_store_fail_ttl permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_mpp_store_fail_ttl</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:Duration</li><li>默认值:<code>60s</code></li><li>刚重启的 TiFlash 可能不能正常提供服务。为了防止查询失败,TiDB 会限制 tidb-server 向刚重启的 TiFlash 节点发送查询。这个变量表示刚重启的 TiFlash 不被发送请求的时间范围。</li></ul><h3 id="tidb_multi_statement_mode-span-classversion-mark从-v4011-版本开始引入span" style="position:relative"><a href="#tidb_multi_statement_mode-span-classversion-mark%E4%BB%8E-v4011-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_multi_statement_mode span classversion mark从 v4011 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_multi_statement_mode</code> <span class="version-mark">从 v4.0.11 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>OFF</code></li><li>可选值:<code>OFF</code>,<code>ON</code>,<code>WARN</code></li><li>该变量用于控制是否在同一个 <code>COM_QUERY</code> 调用中执行多个查询。</li><li>为了减少 SQL 注入攻击的影响,TiDB 目前默认不允许在同一 <code>COM_QUERY</code> 调用中执行多个查询。该变量可用作早期 TiDB 版本的升级路径选项。该变量值与是否允许多语句行为的对照表如下:</li></ul><table><thead><tr><th>客户端设置</th><th><code>tidb_multi_statement_mode</code> 值</th><th>是否允许多语句</th></tr></thead><tbody><tr><td>Multiple Statements = ON</td><td>OFF</td><td>允许</td></tr><tr><td>Multiple Statements = ON</td><td>ON</td><td>允许</td></tr><tr><td>Multiple Statements = ON</td><td>WARN</td><td>允许</td></tr><tr><td>Multiple Statements = OFF</td><td>OFF</td><td>不允许</td></tr><tr><td>Multiple Statements = OFF</td><td>ON</td><td>允许</td></tr><tr><td>Multiple Statements = OFF</td><td>WARN</td><td>允许 + 警告提示</td></tr></tbody></table><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>只有默认值 <code>OFF</code> 才是安全的。如果用户业务是专为早期 TiDB 版本而设计的,那么需要将该变量值设为 <code>ON</code>。如果用户业务需要多语句支持,建议用户使用客户端提供的设置,不要使用 <code>tidb_multi_statement_mode</code> 变量进行设置。</p></div></div></div><blockquote><ul><li><a href="https://github.com/go-sql-driver/mysql#multistatements" target="_blank" referrerpolicy="no-referrer-when-downgrade">go-sql-driver</a> (<code>multiStatements</code>)</li><li><a href="https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html" target="_blank" referrerpolicy="no-referrer-when-downgrade">Connector/J</a> (<code>allowMultiQueries</code>)</li><li>PHP <a href="https://www.php.net/manual/en/mysqli.quickstart.multiple-statement.php" target="_blank" referrerpolicy="no-referrer-when-downgrade">mysqli</a> (<code>mysqli_multi_query</code>)</li></ul></blockquote><h3 id="tidb_opt_agg_push_down" style="position:relative"><a href="#tidb_opt_agg_push_down" aria-label="tidb_opt_agg_push_down permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_agg_push_down</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来设置优化器是否执行聚合函数下推到 Join,Projection 和 UnionAll 之前的优化操作。当查询中聚合操作执行很慢时,可以尝试设置该变量为 ON。</li></ul><h3 id="tidb_opt_broadcast_cartesian_join" style="position:relative"><a href="#tidb_opt_broadcast_cartesian_join" aria-label="tidb_opt_broadcast_cartesian_join permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_broadcast_cartesian_join</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1</code></li><li>范围:<code>[0, 2]</code></li><li>表示是否允许 Broadcast Cartesian Join 算法。</li><li>值为 <code>0</code> 时表示不允许使用 Broadcast Cartesian Join 算法。值为 <code>1</code> 时表示根据 <a href="#tidb_broadcast_join_threshold_count-%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_broadcast_join_threshold_count</code></a> 的行数阈值确定是否允许使用 Broadcast Cartesian Join 算法。值为 <code>2</code> 时表示总是允许 Broadcast Cartesian Join 算法,即使表的大小超过了该阈值。</li><li>该变量是 TiDB 内部使用的变量,<strong>不推荐</strong>修改该变量的值。</li></ul><h3 id="tidb_opt_concurrency_factor" style="position:relative"><a href="#tidb_opt_concurrency_factor" aria-label="tidb_opt_concurrency_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_concurrency_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>范围:<code>[0, 18446744073709551615]</code></li><li>默认值:<code>3.0</code></li><li>表示在 TiDB 中开启一个 Golang goroutine 的 CPU 开销。该变量是<a href="/zh/tidb/stable/cost-model">代价模型</a>内部使用的变量,<strong>不建议</strong>修改该变量的值。</li></ul><h3 id="tidb_opt_copcpu_factor" style="position:relative"><a href="#tidb_opt_copcpu_factor" aria-label="tidb_opt_copcpu_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_copcpu_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>范围:<code>[0, 18446744073709551615]</code></li><li>默认值:<code>3.0</code></li><li>表示 TiKV 协处理器处理一行数据的 CPU 开销。该变量是<a href="/zh/tidb/stable/cost-model">代价模型</a>内部使用的变量,<strong>不建议</strong>修改该变量的值。</li></ul><h3 id="tidb_opt_correlation_exp_factor" style="position:relative"><a href="#tidb_opt_correlation_exp_factor" aria-label="tidb_opt_correlation_exp_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_correlation_exp_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>1</code></li><li>范围:<code>[0, 2147483647]</code></li><li>当交叉估算方法不可用时,会采用启发式估算方法。这个变量用来控制启发式方法的行为。当值为 0 时不用启发式估算方法,大于 0 时,该变量值越大,启发式估算方法越倾向 index scan,越小越倾向 table scan。</li></ul><h3 id="tidb_opt_correlation_threshold" style="position:relative"><a href="#tidb_opt_correlation_threshold" aria-label="tidb_opt_correlation_threshold permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_correlation_threshold</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>默认值:<code>0.9</code></li><li>范围:<code>[0, 1]</code></li><li>这个变量用来设置优化器启用交叉估算 row count 方法的阈值。如果列和 handle 列之间的顺序相关性超过这个阈值,就会启用交叉估算方法。</li><li>交叉估算方法可以简单理解为,利用这个列的直方图来估算 handle 列需要扫的行数。</li></ul><h3 id="tidb_opt_cpu_factor" style="position:relative"><a href="#tidb_opt_cpu_factor" aria-label="tidb_opt_cpu_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_cpu_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>范围:<code>[0, 2147483647]</code></li><li>默认值:<code>3.0</code></li><li>表示 TiDB 处理一行数据的 CPU 开销。该变量是<a href="/zh/tidb/stable/cost-model">代价模型</a>内部使用的变量,不建议修改该变量的值。</li></ul><h3 id="tidb_opt_derive_topn-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_opt_derive_topn-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_derive_topn span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_derive_topn</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>表示是否开启<a href="/zh/tidb/stable/derive-topn-from-window">从窗口函数中推导 TopN 或 Limit</a> 的优化规则。</li></ul><h3 id="tidb_opt_desc_factor" style="position:relative"><a href="#tidb_opt_desc_factor" aria-label="tidb_opt_desc_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_desc_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>范围:<code>[0, 18446744073709551615]</code></li><li>默认值:<code>3.0</code></li><li>表示降序扫描时,TiKV 在磁盘上扫描一行数据的开销。该变量是<a href="/zh/tidb/stable/cost-model">代价模型</a>内部使用的变量,<strong>不建议</strong>修改该变量的值。</li></ul><h3 id="tidb_opt_disk_factor" style="position:relative"><a href="#tidb_opt_disk_factor" aria-label="tidb_opt_disk_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_disk_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>范围:<code>[0, 18446744073709551615]</code></li><li>默认值:<code>1.5</code></li><li>表示 TiDB 往临时磁盘读写一个字节数据的 I/O 开销。该变量是<a href="/zh/tidb/stable/cost-model">代价模型</a>内部使用的变量,<strong>不建议</strong>修改该变量的值。</li></ul><h3 id="tidb_opt_distinct_agg_push_down" style="position:relative"><a href="#tidb_opt_distinct_agg_push_down" aria-label="tidb_opt_distinct_agg_push_down permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_distinct_agg_push_down</code></h3><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来设置优化器是否执行带有 <code>Distinct</code> 的聚合函数(比如 <code>select count(distinct a) from t</code>)下推到 Coprocessor 的优化操作。当查询中带有 <code>Distinct</code> 的聚合操作执行很慢时,可以尝试设置该变量为 <code>1</code>。</li></ul><p>在以下示例中,<code>tidb_opt_distinct_agg_push_down</code> 开启前,TiDB 需要从 TiKV 读取所有数据,并在 TiDB 侧执行 <code>distinct</code>。<code>tidb_opt_distinct_agg_push_down</code> 开启后,<code>distinct a</code> 被下推到了 Coprocessor,在 <code>HashAgg_5</code> 里新增里一个 <code>group by</code> 列 <code>test.t.a</code>。</p><pre><code class="language-sql">mysql> desc select count(distinct a) from test.t; +-------------------------+----------+-----------+---------------+------------------------------------------+ | id | estRows | task | access object | operator info | +-------------------------+----------+-----------+---------------+------------------------------------------+ | StreamAgg_6 | 1.00 | root | | funcs:count(distinct test.t.a)->Column#4 | | └─TableReader_10 | 10000.00 | root | | data:TableFullScan_9 | | └─TableFullScan_9 | 10000.00 | cop[tikv] | table:t | keep order:false, stats:pseudo | +-------------------------+----------+-----------+---------------+------------------------------------------+ 3 rows in set (0.01 sec) mysql> set session tidb_opt_distinct_agg_push_down = 1; Query OK, 0 rows affected (0.00 sec) mysql> desc select count(distinct a) from test.t; +---------------------------+----------+-----------+---------------+------------------------------------------+ | id | estRows | task | access object | operator info | +---------------------------+----------+-----------+---------------+------------------------------------------+ | HashAgg_8 | 1.00 | root | | funcs:count(distinct test.t.a)->Column#3 | | └─TableReader_9 | 1.00 | root | | data:HashAgg_5 | | └─HashAgg_5 | 1.00 | cop[tikv] | | group by:test.t.a, | | └─TableFullScan_7 | 10000.00 | cop[tikv] | table:t | keep order:false, stats:pseudo | +---------------------------+----------+-----------+---------------+------------------------------------------+ 4 rows in set (0.00 sec) </code></pre><h3 id="tidb_opt_enable_correlation_adjustment" style="position:relative"><a href="#tidb_opt_enable_correlation_adjustment" aria-label="tidb_opt_enable_correlation_adjustment permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_enable_correlation_adjustment</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制优化器是否开启交叉估算。</li></ul><h3 id="tidb_opt_enable_late_materialization-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_opt_enable_late_materialization-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_enable_late_materialization span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_enable_late_materialization</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制是否启用 <a href="/zh/tidb/stable/tiflash-late-materialization">TiFlash 延迟物化</a>功能。注意在 TiFlash <a href="/zh/tidb/stable/use-fastscan">Fast Scan 模式</a>下,延迟物化功能暂不可用。</li><li>当设置该变量为 <code>OFF</code> 关闭 TiFlash 延迟物化功能时,如果 <code>SELECT</code> 语句中包含过滤条件(<code>WHERE</code> 子句),TiFlash 会先扫描查询所需列的全部数据后再进行过滤。当设置该变量为 <code>ON</code> 开启 TiFlash 延迟物化功能时,TiFlash 会先扫描下推到 TableScan 算子的过滤条件相关的列数据,过滤得到符合条件的行后,再扫描这些行的其他列数据,继续后续计算,从而减少 IO 扫描和数据处理的计算量。</li></ul><h3 id="tidb_opt_fix_control-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#tidb_opt_fix_control-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_fix_control span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_fix_control</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:字符串</li><li>默认值:<code>""</code></li><li>这个变量用来控制优化器的一些内部行为。</li><li>一部分优化器行为的选择依赖用户场景或 SQL 编写方式。通过设置该变量,你可以更细粒度地控制优化器的行为,并且避免集群升级后优化器行为变化导致的性能回退。</li><li>详细介绍请参考 <a href="/zh/tidb/stable/optimizer-fix-controls">Optimizer Fix Controls</a>。</li></ul><h3 id="tidb_opt_force_inline_cte-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_opt_force_inline_cte-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_force_inline_cte span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_force_inline_cte</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来控制是否强制 inline CTE。默认值为 <code>OFF</code>,即默认不强制 inline CTE。注意,此时依旧可以通过 <code>MERGE()</code> hint 来开启个别 CTE 的 inline。如果设置为 <code>ON</code>,则当前 session 中所有查询的 CTE(递归 CTE 除外)都会 inline。</li></ul><h3 id="tidb_opt_advanced_join_hint-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_opt_advanced_join_hint-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_advanced_join_hint span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_advanced_join_hint</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制包括 <a href="/zh/tidb/stable/optimizer-hints#hash_joint1_name--tl_name-"><code>HASH_JOIN()</code> Hint</a>、<a href="/zh/tidb/stable/optimizer-hints#merge_joint1_name--tl_name-"><code>MERGE_JOIN()</code> Hint</a> 等用于控制连接算法的 Join Method Hint 是否会影响 Join Reorder 的优化过程,包括 <a href="/zh/tidb/stable/optimizer-hints#leadingt1_name--tl_name-"><code>LEADING()</code> Hint</a> 的使用。默认值为 <code>ON</code>,即默认不影响。如果设置为 <code>OFF</code>,在一些同时使用 Join Method Hint 和 <code>LEADING()</code> Hint 的场景下可能会产生冲突。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>v7.0.0 之前的版本行为和将该变量设置为 <code>OFF</code> 的行为一致。为确保向前兼容,从旧版本升级到 v7.0.0 及之后版本的集群,该变量会被设置成 <code>OFF</code>。为了获取更灵活的 Hint 行为,强烈建议在确保无性能回退的情况下,将该变量切换为 <code>ON</code>。</p></div></div></div><h3 id="tidb_opt_insubq_to_join_and_agg" style="position:relative"><a href="#tidb_opt_insubq_to_join_and_agg" aria-label="tidb_opt_insubq_to_join_and_agg permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_insubq_to_join_and_agg</code></h3><ul><li><p>作用域:SESSION | GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:布尔型</p></li><li><p>默认值:<code>ON</code></p></li><li><p>这个变量用来设置是否开启优化规则:将子查询转成 join 和 aggregation。</p><p> 例如,打开这个优化规则后,会将下面子查询做如下变化:</p><pre><code class="language-sql">select * from t where t.a in (select aa from t1); </code></pre><p> 将子查询转成如下 join:</p><pre><code class="language-sql">select t.* from t, (select aa from t1 group by aa) tmp_t where t.a = tmp_t.aa; </code></pre><p> 如果 t1 在列 <code>aa</code> 上有 unique 且 not null 的限制,可以直接改写为如下,不需要添加 aggregation。</p><pre><code class="language-sql">select t.* from t, t1 where t.a=t1.aa; </code></pre></li></ul><h3 id="tidb_opt_join_reorder_threshold" style="position:relative"><a href="#tidb_opt_join_reorder_threshold" aria-label="tidb_opt_join_reorder_threshold permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_join_reorder_threshold</code></h3><ul><li>作用域: SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 2147483647]</code></li><li>这个变量用来控制 TiDB Join Reorder 算法的选择。当参与 Join Reorder 的节点个数大于该阈值时,TiDB 选择贪心算法,小于该阈值时 TiDB 选择动态规划 (dynamic programming) 算法。</li><li>目前对于 OLTP 的查询,推荐保持默认值。对于 OLAP 的查询,推荐将变量值设为 10~15 来获得 AP 场景下更好的连接顺序。</li></ul><h3 id="tidb_opt_limit_push_down_threshold" style="position:relative"><a href="#tidb_opt_limit_push_down_threshold" aria-label="tidb_opt_limit_push_down_threshold permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_limit_push_down_threshold</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>100</code></li><li>范围:<code>[0, 2147483647]</code></li><li>这个变量用来设置将 Limit 和 TopN 算子下推到 TiKV 的阈值。</li><li>如果 Limit 或者 TopN 的取值小于等于这个阈值,则 Limit 和 TopN 算子会被强制下推到 TiKV。该变量可以解决部分由于估算误差导致 Limit 或者 TopN 无法被下推的问题。</li></ul><h3 id="tidb_opt_memory_factor" style="position:relative"><a href="#tidb_opt_memory_factor" aria-label="tidb_opt_memory_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_memory_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>范围:<code>[0, 2147483647]</code></li><li>默认值:<code>0.001</code></li><li>表示 TiDB 存储一行数据的内存开销。该变量是<a href="/zh/tidb/stable/cost-model">代价模型</a>内部使用的变量,<strong>不建议</strong>修改该变量的值。</li></ul><h3 id="tidb_opt_mpp_outer_join_fixed_build_side-span-classversion-mark从-v510-版本开始引入span" style="position:relative"><a href="#tidb_opt_mpp_outer_join_fixed_build_side-span-classversion-mark%E4%BB%8E-v510-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_mpp_outer_join_fixed_build_side span classversion mark从 v510 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_mpp_outer_join_fixed_build_side</code> <span class="version-mark">从 v5.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>当该变量值为 <code>ON</code> 时,左连接始终使用内表作为构建端,右连接始终使用外表作为构建端。将该变量值设为 <code>OFF</code> 后,外连接可以灵活选择任意一边表作为构建端。</li></ul><h3 id="tidb_opt_network_factor" style="position:relative"><a href="#tidb_opt_network_factor" aria-label="tidb_opt_network_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_network_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化</li><li>类型:浮点数</li><li>范围:<code>[0, 2147483647]</code></li><li>默认值:<code>1.0</code></li><li>表示传输 1 比特数据的网络净开销。该变量是<a href="/zh/tidb/stable/cost-model">代价模型</a>内部使用的变量,<strong>不建议</strong>修改该变量的值。</li></ul><h3 id="tidb_opt_ordering_index_selectivity_threshold-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_opt_ordering_index_selectivity_threshold-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_ordering_index_selectivity_threshold span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_ordering_index_selectivity_threshold</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 1]</code></li><li>用于当 SQL 中存在 <code>ORDER BY</code> 和 <code>LIMIT</code> 子句且带有过滤条件时,控制优化器选择索引的行为。</li><li>对于此类查询,优化器会考虑选择对应的索引来满足 <code>ORDER BY</code> 和 <code>LIMIT</code> 子句(即使这个索引并不满足任何过滤条件)。但是由于数据分布的复杂性,优化器在这种场景下可能会选择不优的索引。</li><li>该变量表示一个阈值。当存在索引能满足过滤条件,且其选择率估算值低于该阈值时,优化器会避免选择用于满足 <code>ORDER BY</code> 和 <code>LIMIT</code> 的索引,而优先选择用于满足过滤条件的索引。</li><li>例如,当把该变量设为 <code>0</code> 时,优化器保持默认行为;当设为 <code>1</code> 时,优化器总是优先选择满足过滤条件的索引,避免选择满足 <code>ORDER BY</code> 和 <code>LIMIT</code> 的索引。</li><li>在以下示例中,<code>t</code> 表共有 1,000,000 行数据。使用 <code>b</code> 列上的索引时,其估算行数是大约 8,748 行,因此其选择率估算值大约是 0.0087。默认情况下,优化器选择了 <code>a</code> 列上的索引。而将该变量设为 <code>0.01</code> 之后,由于 <code>b</code> 列上的索引的选择率 (0.0087) 低于 0.01,优化器选择了 <code>b</code> 列上的索引。</li></ul><pre><code class="language-sql">> EXPLAIN SELECT * FROM t WHERE b <= 9000 ORDER BY a LIMIT 1; +-----------------------------------+---------+-----------+----------------------+--------------------+ | id | estRows | task | access object | operator info | +-----------------------------------+---------+-----------+----------------------+--------------------+ | Limit_12 | 1.00 | root | | offset:0, count:1 | | └─Projection_25 | 1.00 | root | | test.t.a, test.t.b | | └─IndexLookUp_24 | 1.00 | root | | | | ├─IndexFullScan_21(Build) | 114.30 | cop[tikv] | table:t, index:ia(a) | keep order:true | | └─Selection_23(Probe) | 1.00 | cop[tikv] | | le(test.t.b, 9000) | | └─TableRowIDScan_22 | 114.30 | cop[tikv] | table:t | keep order:false | +-----------------------------------+---------+-----------+----------------------+--------------------+ > SET SESSION tidb_opt_ordering_index_selectivity_threshold = 0.01; > EXPLAIN SELECT * FROM t WHERE b <= 9000 ORDER BY a LIMIT 1; +----------------------------------+---------+-----------+----------------------+-------------------------------------+ | id | estRows | task | access object | operator info | +----------------------------------+---------+-----------+----------------------+-------------------------------------+ | TopN_9 | 1.00 | root | | test.t.a, offset:0, count:1 | | └─IndexLookUp_20 | 1.00 | root | | | | ├─IndexRangeScan_17(Build) | 8748.62 | cop[tikv] | table:t, index:ib(b) | range:[-inf,9000], keep order:false | | └─TopN_19(Probe) | 1.00 | cop[tikv] | | test.t.a, offset:0, count:1 | | └─TableRowIDScan_18 | 8748.62 | cop[tikv] | table:t | keep order:false | +----------------------------------+---------+-----------+----------------------+-------------------------------------+ </code></pre><h3 id="tidb_opt_prefer_range_scan-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_opt_prefer_range_scan-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_prefer_range_scan span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_prefer_range_scan</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>将该变量值设为 <code>ON</code> 后,优化器总是偏好区间扫描而不是全表扫描。</li><li>在以下示例中,<code>tidb_opt_prefer_range_scan</code> 开启前,TiDB 优化器需要执行全表扫描。<code>tidb_opt_prefer_range_scan</code> 开启后,优化器选择了索引区间扫描。</li></ul><pre><code class="language-sql">explain select * from t where age=5; +-------------------------+------------+-----------+---------------+-------------------+ | id | estRows | task | access object | operator info | +-------------------------+------------+-----------+---------------+-------------------+ | TableReader_7 | 1048576.00 | root | | data:Selection_6 | | └─Selection_6 | 1048576.00 | cop[tikv] | | eq(test.t.age, 5) | | └─TableFullScan_5 | 1048576.00 | cop[tikv] | table:t | keep order:false | +-------------------------+------------+-----------+---------------+-------------------+ 3 rows in set (0.00 sec) set session tidb_opt_prefer_range_scan = 1; explain select * from t where age=5; +-------------------------------+------------+-----------+-----------------------------+-------------------------------+ | id | estRows | task | access object | operator info | +-------------------------------+------------+-----------+-----------------------------+-------------------------------+ | IndexLookUp_7 | 1048576.00 | root | | | | ├─IndexRangeScan_5(Build) | 1048576.00 | cop[tikv] | table:t, index:idx_age(age) | range:[5,5], keep order:false | | └─TableRowIDScan_6(Probe) | 1048576.00 | cop[tikv] | table:t | keep order:false | +-------------------------------+------------+-----------+-----------------------------+-------------------------------+ 3 rows in set (0.00 sec) </code></pre><h3 id="tidb_opt_projection_push_down-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_opt_projection_push_down-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_projection_push_down span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_projection_push_down</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>指定是否允许优化器将 <code>Projection</code> 算子下推到 TiKV 或者 TiFlash。</li></ul><h3 id="tidb_opt_range_max_size-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_opt_range_max_size-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_range_max_size span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_range_max_size</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>67108864</code> (64 MiB)</li><li>取值范围:<code>[0, 9223372036854775807]</code></li><li>单位:字节</li><li>该变量用于指定优化器构造扫描范围的内存用量上限。当该变量为 <code>0</code> 时,表示对扫描范围没有内存限制。如果构造精确的扫描范围会超出内存用量限制,优化器会使用更宽松的扫描范围(例如 <code>[[NULL,+inf]]</code>)。如果执行计划中未使用精确的扫描范围,可以调大该变量的值让优化器构造精确的扫描范围。</li></ul><p>该变量的使用示例如下:</p><details><summary><code>tidb_opt_range_max_size</code> 使用示例</summary><p>查看该变量的默认值,即优化器构造扫描范围最多使用 64 MiB 内存。</p><pre><code class="language-sql">SELECT @@tidb_opt_range_max_size; </code></pre><pre><code class="language-sql">+----------------------------+ | @@tidb_opt_range_max_size | +----------------------------+ | 67108864 | +----------------------------+ 1 row in set (0.01 sec) </code></pre><pre><code class="language-sql">EXPLAIN SELECT * FROM t use index (idx) WHERE a IN (10,20,30) AND b IN (40,50,60); </code></pre><p>在 64 MiB 的内存最大限制约束下,优化器构造出精确的扫描范围 <code>[10 40,10 40], [10 50,10 50], [10 60,10 60], [20 40,20 40], [20 50,20 50], [20 60,20 60], [30 40,30 40], [30 50,30 50], [30 60,30 60]</code>,见如下执行计划返回结果。</p><pre><code class="language-sql">+-------------------------------+---------+-----------+--------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | id | estRows | task | access object | operator info | +-------------------------------+---------+-----------+--------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | IndexLookUp_7 | 0.90 | root | | | | ├─IndexRangeScan_5(Build) | 0.90 | cop[tikv] | table:t, index:idx(a, b) | range:[10 40,10 40], [10 50,10 50], [10 60,10 60], [20 40,20 40], [20 50,20 50], [20 60,20 60], [30 40,30 40], [30 50,30 50], [30 60,30 60], keep order:false, stats:pseudo | | └─TableRowIDScan_6(Probe) | 0.90 | cop[tikv] | table:t | keep order:false, stats:pseudo | +-------------------------------+---------+-----------+--------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 3 rows in set (0.00 sec) </code></pre><p>现将优化器构造扫描范围的内存用量上限设为 1500 字节。</p><pre><code class="language-sql">SET @@tidb_opt_range_max_size = 1500; </code></pre><pre><code class="language-sql">Query OK, 0 rows affected (0.00 sec) </code></pre><pre><code class="language-sql">EXPLAIN SELECT * FROM t USE INDEX (idx) WHERE a IN (10,20,30) AND b IN (40,50,60); </code></pre><p>在 1500 字节内存的最大限制约束下,优化器构造出了更宽松的扫描范围 <code>[10,10], [20,20], [30,30]</code>,并用 warning 提示用户构造精确的扫描范围所需的内存用量超出了 <code>tidb_opt_range_max_size</code> 的限制。</p><pre><code class="language-sql">+-------------------------------+---------+-----------+--------------------------+-----------------------------------------------------------------+ | id | estRows | task | access object | operator info | +-------------------------------+---------+-----------+--------------------------+-----------------------------------------------------------------+ | IndexLookUp_8 | 0.09 | root | | | | ├─Selection_7(Build) | 0.09 | cop[tikv] | | in(test.t.b, 40, 50, 60) | | │ └─IndexRangeScan_5 | 30.00 | cop[tikv] | table:t, index:idx(a, b) | range:[10,10], [20,20], [30,30], keep order:false, stats:pseudo | | └─TableRowIDScan_6(Probe) | 0.09 | cop[tikv] | table:t | keep order:false, stats:pseudo | +-------------------------------+---------+-----------+--------------------------+-----------------------------------------------------------------+ 4 rows in set, 1 warning (0.00 sec) </code></pre><pre><code class="language-sql">SHOW WARNINGS; </code></pre><pre><code class="language-sql">+---------+------+---------------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +---------+------+---------------------------------------------------------------------------------------------------------------------------------------------+ | Warning | 1105 | Memory capacity of 1500 bytes for 'tidb_opt_range_max_size' exceeded when building ranges. Less accurate ranges such as full range are chosen | +---------+------+---------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) </code></pre><p>再将优化器构造扫描范围的内存用量上限设为 100 字节。</p><pre><code class="language-sql">set @@tidb_opt_range_max_size = 100; </code></pre><pre><code class="language-sql">Query OK, 0 rows affected (0.00 sec) </code></pre><pre><code class="language-sql">EXPLAIN SELECT * FROM t USE INDEX (idx) WHERE a IN (10,20,30) AND b IN (40,50,60); </code></pre><p>在 100 字节的内存最大限制约束下,优化器选择了 <code>IndexFullScan</code>,并用 warning 提示用户构造精确的扫描范围所需的内存超出了 <code>tidb_opt_range_max_size</code> 的限制。</p><pre><code class="language-sql">+-------------------------------+----------+-----------+--------------------------+----------------------------------------------------+ | id | estRows | task | access object | operator info | +-------------------------------+----------+-----------+--------------------------+----------------------------------------------------+ | IndexLookUp_8 | 8000.00 | root | | | | ├─Selection_7(Build) | 8000.00 | cop[tikv] | | in(test.t.a, 10, 20, 30), in(test.t.b, 40, 50, 60) | | │ └─IndexFullScan_5 | 10000.00 | cop[tikv] | table:t, index:idx(a, b) | keep order:false, stats:pseudo | | └─TableRowIDScan_6(Probe) | 8000.00 | cop[tikv] | table:t | keep order:false, stats:pseudo | +-------------------------------+----------+-----------+--------------------------+----------------------------------------------------+ 4 rows in set, 1 warning (0.00 sec) </code></pre><pre><code class="language-sql">SHOW WARNINGS; </code></pre><pre><code class="language-sql">+---------+------+---------------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +---------+------+---------------------------------------------------------------------------------------------------------------------------------------------+ | Warning | 1105 | Memory capacity of 100 bytes for 'tidb_opt_range_max_size' exceeded when building ranges. Less accurate ranges such as full range are chosen | +---------+------+---------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) </code></pre></details><h3 id="tidb_opt_scan_factor" style="position:relative"><a href="#tidb_opt_scan_factor" aria-label="tidb_opt_scan_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_scan_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>范围:<code>[0, 2147483647]</code></li><li>默认值:<code>1.5</code></li><li>表示升序扫描时,TiKV 在磁盘上扫描一行数据的开销。该变量是<a href="/zh/tidb/stable/cost-model">代价模型</a>内部使用的变量,<strong>不建议</strong>修改该变量的值。</li></ul><h3 id="tidb_opt_seek_factor" style="position:relative"><a href="#tidb_opt_seek_factor" aria-label="tidb_opt_seek_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_seek_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>范围:<code>[0, 2147483647]</code></li><li>默认值:<code>20</code></li><li>表示 TiDB 从 TiKV 请求数据的初始开销。该变量是<a href="/zh/tidb/stable/cost-model">代价模型</a>内部使用的变量,<strong>不建议</strong>修改该变量的值。</li></ul><h3 id="tidb_opt_skew_distinct_agg-span-classversion-mark从-v620-版本开始引入span" style="position:relative"><a href="#tidb_opt_skew_distinct_agg-span-classversion-mark%E4%BB%8E-v620-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_skew_distinct_agg span classversion mark从 v620 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_skew_distinct_agg</code> <span class="version-mark">从 v6.2.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><p>开启该变量带来的查询性能优化仅对 TiFlash 有效。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来设置优化器是否将带有 <code>DISTINCT</code> 的聚合函数(例如 <code>SELECT b, count(DISTINCT a) FROM t GROUP BY b</code>)改写为两层聚合函数(例如 <code>SELECT b, count(a) FROM (SELECT b, a FROM t GROUP BY b, a) t GROUP BY b</code>)。当聚合列有严重的数据倾斜,且 <code>DISTINCT</code> 列有很多不同的值时,这种改写能够避免查询执行过程中的数据倾斜,从而提升查询性能。</li></ul><h3 id="tidb_opt_three_stage_distinct_agg-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_opt_three_stage_distinct_agg-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_three_stage_distinct_agg span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_three_stage_distinct_agg</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>该变量用于控制在 MPP 模式下是否将 <code>COUNT(DISTINCT)</code> 聚合改写为三阶段分布式执行的聚合。</li><li>该变量目前仅对只有一个 <code>COUNT(DISTINCT)</code> 的聚合生效。</li></ul><h3 id="tidb_opt_tiflash_concurrency_factor" style="position:relative"><a href="#tidb_opt_tiflash_concurrency_factor" aria-label="tidb_opt_tiflash_concurrency_factor permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_tiflash_concurrency_factor</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>范围:<code>[0, 2147483647]</code></li><li>默认值:<code>24.0</code></li><li>表示 TiFlash 计算的并发数。该变量是<a href="/zh/tidb/stable/cost-model">代价模型</a>内部使用的变量,<strong>不建议</strong>修改该变量的值。</li></ul><h3 id="tidb_opt_write_row_id" style="position:relative"><a href="#tidb_opt_write_row_id" aria-label="tidb_opt_write_row_id permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_write_row_id</code></h3><ul><li>作用域:SESSION</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来设置是否允许 <code>INSERT</code>、<code>REPLACE</code> 和 <code>UPDATE</code> 操作 <code>_tidb_rowid</code> 列,默认是不允许操作。该选项仅用于 TiDB 工具导数据时使用。</li></ul><h3 id="tidb_optimizer_selectivity_level" style="position:relative"><a href="#tidb_optimizer_selectivity_level" aria-label="tidb_optimizer_selectivity_level permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_optimizer_selectivity_level</code></h3><ul><li>作用域:SESSION</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 2147483647]</code></li><li>控制优化器估算逻辑的更迭。更改该变量值后,优化器的估算逻辑会产生较大的改变。目前该变量的有效值只有 <code>0</code>,不建议设为其它值。</li></ul><h3 id="tidb_partition_prune_mode-span-classversion-mark从-v51-版本开始引入span" style="position:relative"><a href="#tidb_partition_prune_mode-span-classversion-mark%E4%BB%8E-v51-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_partition_prune_mode span classversion mark从 v51 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_partition_prune_mode</code> <span class="version-mark">从 v5.1 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>dynamic</code></li><li>可选值:<code>static</code>、<code>dynamic</code>、<code>static-only</code>、<code>dynamic-only</code></li><li>这个变量用来设置是否开启分区表动态裁剪模式。默认值为 <code>dynamic</code>。但是注意,<code>dynamic</code> 模式仅在表级别汇总统计信息(即 GlobalStats)收集完成的情况下生效。如果选择了 <code>dynamic</code> 但 GlobalStats 未收集完成,TiDB 会仍采用 <code>static</code> 模式。关于 GlobalStats 更多信息,请参考<a href="/zh/tidb/stable/statistics#动态裁剪模式下的分区表统计信息">动态裁剪模式下的分区表统计信息</a>。关于动态裁剪模式更多信息,请参考<a href="/zh/tidb/stable/partitioned-table#动态裁剪模式">分区表动态裁剪模式</a>。</li></ul><h3 id="tidb_persist_analyze_options-span-classversion-mark从-v540-版本开始引入span" style="position:relative"><a href="#tidb_persist_analyze_options-span-classversion-mark%E4%BB%8E-v540-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_persist_analyze_options span classversion mark从 v540 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_persist_analyze_options</code> <span class="version-mark">从 v5.4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于控制是否开启 <a href="/zh/tidb/stable/statistics#analyze-配置持久化">ANALYZE 配置持久化</a>特性。</li></ul><h3 id="tidb_pessimistic_txn_fair_locking-span-classversion-mark从-v700-版本开始引入span" style="position:relative"><a href="#tidb_pessimistic_txn_fair_locking-span-classversion-mark%E4%BB%8E-v700-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_pessimistic_txn_fair_locking span classversion mark从 v700 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_pessimistic_txn_fair_locking</code> <span class="version-mark">从 v7.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>是否对悲观锁启用加强的悲观锁唤醒模型。该模型可严格控制悲观锁单点冲突场景下事务的唤醒顺序,避免无效唤醒,大大降低原有唤醒机制中的随机性对事务延迟带来的不确定性。如果业务场景中遇到了单点悲观锁冲突频繁的情况(如高频更新同一行数据等),并进而引起语句重试频繁、尾延迟高,甚至偶尔发生 <code>pessimistic lock retry limit reached</code> 错误,可以尝试开启该变量来解决问题。</li><li>对于从 v7.0.0 以前的版本升级到 v7.0.0 或更新版本的 TiDB 集群,该选项默认关闭。</li></ul><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardInfo MuiAlert-standard css-152gid5" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="InfoOutlinedIcon"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">注意</div><ul><li>视具体业务场景的不同,启用该选项可能对存在频繁锁冲突的事务造成一定程度的吞吐下降(平均延迟上升)。</li><li>该选项目前仅对需要上锁单个 key 的语句有效。如果一个语句需要对多行同时上锁,则该选项不会对此类语句生效。</li><li>该功能从 v6.6.0 版本引入。在 v6.6.0 版本中,该功能由变量 <a href="https://docs.pingcap.com/zh/tidb/v6.6/system-variables#tidb_pessimistic_txn_aggressive_locking-%E4%BB%8E-v660-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5" target="_blank" referrerpolicy="no-referrer-when-downgrade"><code>tidb_pessimistic_txn_aggressive_locking</code></a> 控制,默认关闭。</li></ul></div></div></div><h3 id="tidb_placement_mode-span-classversion-mark从-v600-版本开始引入span" style="position:relative"><a href="#tidb_placement_mode-span-classversion-mark%E4%BB%8E-v600-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_placement_mode span classversion mark从 v600 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_placement_mode</code> <span class="version-mark">从 v6.0.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>STRICT</code></li><li>可选值:<code>STRICT</code>,<code>IGNORE</code></li><li>该变量用于控制 DDL 语句是否忽略 <a href="/zh/tidb/stable/placement-rules-in-sql">Placement Rules in SQL</a> 指定的放置规则。变量值为 <code>IGNORE</code> 时将忽略所有放置规则选项。</li><li>该变量可由逻辑转储或逻辑恢复工具使用,确保即使绑定了不合适的放置规则,也始终可以成功创建表。这类似于 mysqldump 将 <code>SET FOREIGN_KEY_CHECKS=0;</code> 写入每个转储文件的开头部分。</li></ul><h3 id="tidb_plan_cache_invalidation_on_fresh_stats-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#tidb_plan_cache_invalidation_on_fresh_stats-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_plan_cache_invalidation_on_fresh_stats span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_plan_cache_invalidation_on_fresh_stats</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>该变量用于控制当某张表上的统计信息更新后,与该表相关的 Plan Cache 是否自动失效。</li><li>开启此变量有助于 Plan Cache 更有效地利用可用的统计信息生成执行计划,例如:<ul><li>有时 Plan Cache 会在统计信息尚不可用时生成执行计划。开启此变量后,Plan Cache 会在统计信息可用时重新生成执行计划。</li><li>当表上数据分布发生变化时,之前的最优执行计划可能对于现在不再是最优的。开启此变量后,Plan Cache 会在重新收集统计信息后重新生成执行计划。</li></ul></li><li>对于从 v7.1.0 以前的版本升级到 v7.1.0 及以上版本的 TiDB 集群,该选项默认关闭 (<code>OFF</code>)。</li></ul><h3 id="tidb_plan_cache_max_plan_size-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#tidb_plan_cache_max_plan_size-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_plan_cache_max_plan_size span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_plan_cache_max_plan_size</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>2097152</code>(即 2 MB)</li><li>取值范围:<code>[0, 9223372036854775807]</code>,单位为 Byte。支持带单位的内存格式“KB|MB|GB|TB”。<code>0</code> 表示表示不设限制。</li><li>这个变量用来控制可以缓存的 Prepare 或非 Prepare 语句执行计划的最大大小。超过该值的执行计划将不会被缓存到 Plan Cache 中。详情请参考 <a href="/zh/tidb/stable/sql-prepared-plan-cache#prepared-plan-cache-的内存管理">Prepare 语句执行计划缓存</a>和<a href="/zh/tidb/stable/sql-non-prepared-plan-cache#使用方法">非 Prepare 语句执行计划缓存</a>。</li></ul><h3 id="tidb_pprof_sql_cpu-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_pprof_sql_cpu-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_pprof_sql_cpu span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_pprof_sql_cpu</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围:<code>[0, 1]</code></li><li>这个变量用来控制是否在 profile 输出中标记出对应的 SQL 语句,用于定位和排查性能问题。</li></ul><h3 id="tidb_opt_prefix_index_single_scan-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_opt_prefix_index_single_scan-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_opt_prefix_index_single_scan span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_opt_prefix_index_single_scan</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于控制 TiDB 优化器是否将某些过滤条件下推到前缀索引,尽量避免不必要的回表,从而提高查询性能。</li><li>将该变量设置为 <code>ON</code> 时,会将过滤条件下推到前缀索引。此时,假设一张表中 <code>col</code> 列是索引前缀列,查询语句中的 <code>col is null</code> 或者 <code>col is not null</code> 条件会被归为索引上的过滤条件,而不是回表时的过滤条件,从而避免不必要的回表。</li></ul><details><summary>该变量的使用示例</summary><p>创建一张带前缀索引的表:</p><pre><code class="language-sql">CREATE TABLE t (a INT, b VARCHAR(10), c INT, INDEX idx_a_b(a, b(5))); </code></pre><p>此时关闭 <code>tidb_opt_prefix_index_single_scan</code>:</p><pre><code class="language-sql">SET tidb_opt_prefix_index_single_scan = 'OFF'; </code></pre><p>对于以下查询,执行计划使用了前缀索引 <code>idx_a_b</code> 但需要回表(出现了 <code>IndexLookUp</code> 算子)。</p><pre><code class="language-sql">EXPLAIN FORMAT='brief' SELECT COUNT(1) FROM t WHERE a = 1 AND b IS NOT NULL; +-------------------------------+---------+-----------+------------------------------+-------------------------------------------------------+ | id | estRows | task | access object | operator info | +-------------------------------+---------+-----------+------------------------------+-------------------------------------------------------+ | HashAgg | 1.00 | root | | funcs:count(Column#8)->Column#5 | | └─IndexLookUp | 1.00 | root | | | | ├─IndexRangeScan(Build) | 99.90 | cop[tikv] | table:t, index:idx_a_b(a, b) | range:[1 -inf,1 +inf], keep order:false, stats:pseudo | | └─HashAgg(Probe) | 1.00 | cop[tikv] | | funcs:count(1)->Column#8 | | └─Selection | 99.90 | cop[tikv] | | not(isnull(test.t.b)) | | └─TableRowIDScan | 99.90 | cop[tikv] | table:t | keep order:false, stats:pseudo | +-------------------------------+---------+-----------+------------------------------+-------------------------------------------------------+ 6 rows in set (0.00 sec) </code></pre><p>此时打开 <code>tidb_opt_prefix_index_single_scan</code>:</p><pre><code class="language-sql">SET tidb_opt_prefix_index_single_scan = 'ON'; </code></pre><p>开启该变量后,对于以下查询,执行计划使用了前缀索引 <code>idx_a_b</code> 且不需要回表。</p><pre><code class="language-sql">EXPLAIN FORMAT='brief' SELECT COUNT(1) FROM t WHERE a = 1 AND b IS NOT NULL; +--------------------------+---------+-----------+------------------------------+-------------------------------------------------------+ | id | estRows | task | access object | operator info | +--------------------------+---------+-----------+------------------------------+-------------------------------------------------------+ | StreamAgg | 1.00 | root | | funcs:count(Column#7)->Column#5 | | └─IndexReader | 1.00 | root | | index:StreamAgg | | └─StreamAgg | 1.00 | cop[tikv] | | funcs:count(1)->Column#7 | | └─IndexRangeScan | 99.90 | cop[tikv] | table:t, index:idx_a_b(a, b) | range:[1 -inf,1 +inf], keep order:false, stats:pseudo | +--------------------------+---------+-----------+------------------------------+-------------------------------------------------------+ 4 rows in set (0.00 sec) </code></pre></details><h3 id="tidb_prefer_broadcast_join_by_exchange_data_size-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#tidb_prefer_broadcast_join_by_exchange_data_size-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_prefer_broadcast_join_by_exchange_data_size span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_prefer_broadcast_join_by_exchange_data_size</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于设定 TiDB 选择 <a href="/zh/tidb/stable/use-tiflash-mpp-mode#mpp-模式的算法支持">MPP Hash Join 算法</a>时,是否使用最小网络交换的数据量策略。开启该变量后,TiDB 会估算 Broadcast Hash Join 和 Shuffled Hash Join 两种算法所需进行网络交换的数据量,并选择网络交换数据量较小的算法。</li><li>该功能开启后 <a href="#tidb_broadcast_join_threshold_count-%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_broadcast_join_threshold_count</code></a> 和 <a href="#tidb_broadcast_join_threshold_size-%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_broadcast_join_threshold_size</code></a> 将不再生效。</li></ul><h3 id="tidb_prepared_plan_cache_memory_guard_ratio-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_prepared_plan_cache_memory_guard_ratio-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_prepared_plan_cache_memory_guard_ratio span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_prepared_plan_cache_memory_guard_ratio</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:浮点数</li><li>默认值:<code>0.1</code></li><li>范围:<code>[0, 1]</code></li><li>这个变量用来控制 Prepared Plan Cache 触发内存保护机制的阈值,具体可见 <a href="/zh/tidb/stable/sql-prepared-plan-cache#prepared-plan-cache-的内存管理">Prepared Plan Cache 的内存管理</a>。</li><li>在 v6.1.0 之前这个开关通过 TiDB 配置文件 (<code>prepared-plan-cache.memory-guard-ratio</code>) 进行配置,升级到 v6.1.0 时会自动继承原有设置。</li></ul><h3 id="tidb_prepared_plan_cache_size-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_prepared_plan_cache_size-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_prepared_plan_cache_size span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_prepared_plan_cache_size</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>从 v7.1.0 开始,该变量被废弃。请使用 <a href="#tidb_session_plan_cache_size-%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_session_plan_cache_size</code></a> 进行设置。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>100</code></li><li>范围:<code>[1, 100000]</code></li><li>这个变量用来控制单个 <code>SESSION</code> 的 Prepared Plan Cache 最多能够缓存的计划数量,具体可见 <a href="/zh/tidb/stable/sql-prepared-plan-cache#prepared-plan-cache-的内存管理">Prepared Plan Cache 的内存管理</a>。</li><li>在 v6.1.0 之前这个开关通过 TiDB 配置文件 (<code>prepared-plan-cache.capacity</code>) 进行配置,升级到 v6.1.0 时会自动继承原有设置。</li></ul><h3 id="tidb_projection_concurrency" style="position:relative"><a href="#tidb_projection_concurrency" aria-label="tidb_projection_concurrency permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_projection_concurrency</code></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>从 v5.0 版本开始,该变量被废弃。请使用 <a href="#tidb_executor_concurrency-%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_executor_concurrency</code></a> 进行设置。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>-1</code></li><li>范围:<code>[-1, 256]</code></li><li>单位:线程</li><li>这个变量用来设置 <code>Projection</code> 算子的并发度。</li><li>默认值 <code>-1</code> 表示使用 <code>tidb_executor_concurrency</code> 的值。</li></ul><h3 id="tidb_query_log_max_len" style="position:relative"><a href="#tidb_query_log_max_len" aria-label="tidb_query_log_max_len permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_query_log_max_len</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>4096</code> (4 KiB)</li><li>范围:<code>[0, 1073741824]</code></li><li>单位:字节</li><li>该变量控制 SQL 语句输出的最大长度。当一条 SQL 语句的输出长度大于 <code>tidb_query_log_max_len</code> 时,输出将会被截断。</li><li>在 v6.1.0 之前这个开关也可以通过 TiDB 配置文件 (<code>log.query-log-max-len</code>) 进行配置,升级到 v6.1.0 后仅可通过系统变量配置。</li></ul><h3 id="tidb_rc_read_check_ts-span-classversion-mark从-v600-版本开始引入span" style="position:relative"><a href="#tidb_rc_read_check_ts-span-classversion-mark%E4%BB%8E-v600-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_rc_read_check_ts span classversion mark从 v600 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_rc_read_check_ts</code> <span class="version-mark">从 v6.0.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><ul><li>该特性与 <a href="#tidb_replica_read-%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>replica-read</code></a> 尚不兼容,开启 <code>tidb_rc_read_check_ts</code> 的读请求无法使用 <a href="#tidb_replica_read-%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>replica-read</code></a>,请勿同时开启两项特性。</li><li>如果客户端使用游标操作,建议不开启 <code>tidb_rc_read_check_ts</code> 这一特性,避免前一批返回数据已经被客户端使用而语句最终会报错的情况。</li><li>自 v7.0.0 版本开始,该变量对于使用 prepared statement 协议下 cursor fetch read 游标模式不再生效。</li></ul></div></div></div><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量用于优化时间戳的获取,适用于悲观事务 <code>READ-COMMITTED</code> 隔离级别下读写冲突较少的场景,开启此变量可以避免获取全局 timestamp 带来的延迟和开销,并优化事务内读语句延迟。</li><li>如果读写冲突较为严重,开启此功能会增加额外开销和延迟,造成性能回退。更详细的说明,请参考<a href="/zh/tidb/stable/transaction-isolation-levels#读已提交隔离级别-read-committed">读已提交隔离级别 (Read Committed) 文档</a>。</li></ul><h3 id="tidb_rc_write_check_ts-span-classversion-mark从-v630-版本开始引入span" style="position:relative"><a href="#tidb_rc_write_check_ts-span-classversion-mark%E4%BB%8E-v630-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_rc_write_check_ts span classversion mark从 v630 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_rc_write_check_ts</code> <span class="version-mark">从 v6.3.0 版本开始引入</span></h3><div class="MuiBox-root css-1weqspv"><div class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardError MuiAlert-standard css-21rxh6" role="alert"><div class="MuiAlert-icon css-1l54tgj"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ErrorOutlineIcon"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg></div><div class="MuiAlert-message css-1xsto0d"><div class="MuiTypography-root MuiTypography-body1 MuiTypography-gutterBottom MuiAlertTitle-root css-17ioyuk">警告</div><p>该特性与 <a href="#tidb_replica_read-%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>replica-read</code></a> 尚不兼容。开启本变量后,客户端发送的所有请求都将无法使用 <code>replica-read</code>,因此请勿同时开启 <code>tidb_rc_write_check_ts</code> 和 <code>replica-read</code>。</p></div></div></div><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量用于优化时间戳的获取,适用于悲观事务 <code>READ-COMMITTED</code> 隔离级别下点写冲突较少的场景。开启此变量可以避免点写语句获取全局时间戳带来的延迟和开销。目前该变量适用的点写语句包括 <code>UPDATE</code>、<code>DELETE</code>、<code>SELECT ...... FOR UPDATE</code> 三种类型。点写语句是指将主键或者唯一键作为过滤条件且最终执行算子包含 <code>POINT-GET</code> 的写语句。</li><li>如果点写冲突较为严重,开启此变量会增加额外开销和延迟,造成性能回退。更详细的说明,请参考<a href="/zh/tidb/stable/transaction-isolation-levels#读已提交隔离级别-read-committed">读已提交隔离级别 (Read Committed) 文档</a>。</li></ul><h3 id="tidb_read_consistency-span-classversion-marknew-in-v540span" style="position:relative"><a href="#tidb_read_consistency-span-classversion-marknew-in-v540span" aria-label="tidb_read_consistency span classversion marknew in v540span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_read_consistency</code> <span class="version-mark">New in v5.4.0</span></h3><ul><li>作用域:SESSION</li><li>类型:字符串</li><li>默认值:<code>strict</code></li><li>此变量用于控制自动提交的读语句的读一致性。</li><li>如果将变量值设置为 <code>weak</code>,则直接跳过读语句遇到的锁,读的执行可能会更快,这就是弱一致性读模式。但在该模式下,事务语义(例如原子性)和分布式一致性(线性一致性)并不能得到保证。</li><li>如果用户场景中需要快速返回自动提交的读语句,并且可接受弱一致性的读取结果,则可以使用弱一致性读取模式。</li></ul><h3 id="tidb_read_staleness-span-classversion-mark从-v540-版本开始引入span" style="position:relative"><a href="#tidb_read_staleness-span-classversion-mark%E4%BB%8E-v540-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_read_staleness span classversion mark从 v540 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_read_staleness</code> <span class="version-mark">从 v5.4.0 版本开始引入</span></h3><ul><li>作用域:SESSION</li><li>类型:整数型</li><li>默认值:<code>0</code></li><li>范围 <code>[-2147483648, 0]</code></li><li>这个变量用于设置当前会话允许读取的历史数据范围。设置后,TiDB 会从参数允许的范围内选出一个尽可能新的时间戳,并影响后继的所有读操作。比如,如果该变量的值设置为 <code>-5</code>,TiDB 会在 5 秒时间范围内,保证 TiKV 拥有对应历史版本数据的情况下,选择尽可能新的一个时间戳。</li></ul><h3 id="tidb_record_plan_in_slow_log" style="position:relative"><a href="#tidb_record_plan_in_slow_log" aria-label="tidb_record_plan_in_slow_log permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_record_plan_in_slow_log</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:否,仅作用于当前连接的 TiDB 实例</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用于控制是否在 slow log 里包含慢查询的执行计划。</li></ul><h3 id="tidb_redact_log" style="position:relative"><a href="#tidb_redact_log" aria-label="tidb_redact_log permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_redact_log</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用于控制在记录 TiDB 日志和慢日志时,是否将 SQL 中的用户信息遮蔽。</li><li>将该变量设置为 <code>1</code> 即开启后,假设执行的 SQL 为 <code>insert into t values (1,2)</code>,在日志中记录的 SQL 会是 <code>insert into t values (?,?)</code>,即用户输入的信息被遮蔽。</li></ul><h3 id="tidb_regard_null_as_point-span-classversion-mark从-v540-版本开始引入span" style="position:relative"><a href="#tidb_regard_null_as_point-span-classversion-mark%E4%BB%8E-v540-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_regard_null_as_point span classversion mark从 v540 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_regard_null_as_point</code> <span class="version-mark">从 v5.4.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>ON</code></li><li>这个变量用来控制优化器是否可以将包含 null 的等值条件作为前缀条件来访问索引。</li><li>该变量默认开启。开启后,该变量可以使优化器减少需要访问的索引数据量,从而提高查询的执行速度。例如,在有多列索引 <code>index(a, b)</code> 且查询条件为 <code>a<=>null and b=1</code> 的情况下,优化器可以同时使用查询条件中的 <code>a<=>null</code> 和 <code>b=1</code> 进行索引访问。如果关闭该变量,因为 <code>a<=>null and b=1</code> 包含 null 的等值条件,优化器不会使用 <code>b=1</code> 进行索引访问。</li></ul><h3 id="tidb_remove_orderby_in_subquery-span-classversion-mark从-v610-版本开始引入span" style="position:relative"><a href="#tidb_remove_orderby_in_subquery-span-classversion-mark%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_remove_orderby_in_subquery span classversion mark从 v610 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_remove_orderby_in_subquery</code> <span class="version-mark">从 v6.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>指定是否在子查询中移除 <code>ORDER BY</code> 子句。</li></ul><h3 id="tidb_replica_read-span-classversion-mark从-v40-版本开始引入span" style="position:relative"><a href="#tidb_replica_read-span-classversion-mark%E4%BB%8E-v40-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_replica_read span classversion mark从 v40 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_replica_read</code> <span class="version-mark">从 v4.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:枚举型</li><li>默认值:<code>leader</code></li><li>可选值:<code>leader</code>、<code>follower</code>、<code>leader-and-follower</code>、<code>prefer-leader</code>、<code>closest-replicas</code>、<code>closest-adaptive</code> 和 <code>learner</code>。其中,<code>learner</code> 从 v6.6.0 开始引入。</li><li>这个变量用于控制 TiDB 的 Follower Read 功能的行为。</li><li>关于使用方式与实现原理,见 <a href="/zh/tidb/stable/follower-read">Follower Read</a>。</li></ul><h3 id="tidb_retry_limit" style="position:relative"><a href="#tidb_retry_limit" aria-label="tidb_retry_limit permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_retry_limit</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>10</code></li><li>范围:<code>[-1, 9223372036854775807]</code></li><li>这个变量用来设置乐观事务的最大重试次数。一个事务执行中遇到可重试的错误(例如事务冲突、事务提交过慢或表结构变更)时,会根据该变量的设置进行重试。注意当 <code>tidb_retry_limit = 0</code> 时,也会禁用自动重试。该变量仅适用于乐观事务,不适用于悲观事务。</li></ul><h3 id="tidb_row_format_version" style="position:relative"><a href="#tidb_row_format_version" aria-label="tidb_row_format_version permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_row_format_version</code></h3><ul><li><p>作用域:SESSION | GLOBAL</p></li><li><p>是否持久化到集群:是</p></li><li><p>类型:整数型</p></li><li><p>默认值:<code>2</code></p></li><li><p>范围:<code>[1, 2]</code></p></li><li><p>控制新保存数据的表数据格式版本。TiDB v4.0 中默认使用版本号为 2 的<a href="https://github.com/pingcap/tidb/blob/master/docs/design/2018-07-19-row-format.md" target="_blank" referrerpolicy="no-referrer-when-downgrade">新表数据格式</a>保存新数据。</p></li><li><p>但如果从 4.0.0 之前的版本升级到 4.0.0,不会改变表数据格式版本,TiDB 会继续使用版本为 1 的旧格式写入表中,即<strong>只有新创建的集群才会默认使用新表数据格式</strong>。</p></li><li><p>需要注意的是修改该变量不会对已保存的老数据产生影响,只会对修改变量后的新写入数据使用对应版本格式保存。</p></li></ul><h3 id="tidb_scatter_region" style="position:relative"><a href="#tidb_scatter_region" aria-label="tidb_scatter_region permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_scatter_region</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>TiDB 默认会在建表时为新表分裂 Region。开启该变量后,会在建表语句执行时,同步打散刚分裂出的 Region。适用于批量建表后紧接着批量写入数据,能让刚分裂出的 Region 先在 TiKV 分散而不用等待 PD 进行调度。为了保证后续批量写入数据的稳定性,建表语句会等待打散 Region 完成后再返回建表成功,建表语句执行时间会是该变量关闭时的数倍。</li><li>如果建表时设置了 <code>SHARD_ROW_ID_BITS</code> 和 <code>PRE_SPLIT_REGIONS</code>,建表成功后会均匀切分出指定数量的 Region。</li></ul><h3 id="tidb_server_memory_limit-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_server_memory_limit-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_server_memory_limit span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_server_memory_limit</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>80%</code></li><li>取值范围:<ul><li>你可以将该变量值设为百分比格式,表示内存用量占总内存的百分比,取值范围为 <code>[1%, 99%]</code>。</li><li>你还可以将变量值设为内存大小,取值范围为 <code>0</code> 以及 <code>[536870912, 9223372036854775807]</code>,单位为 Byte。支持带单位的内存格式 "KB|MB|GB|TB"。<code>0</code> 值表示不设内存限制。</li><li>当设置的内存值小于 512 MB 且不为 0 时,TiDB 将会使用 512 MB 作为替代。</li></ul></li><li>该变量指定 TiDB 实例的内存限制。TiDB 会在内存用量达到该限制时,对当前内存用量最高的 SQL 语句进行取消 (Cancel) 操作。在该 SQL 语句被成功 Cancel 掉后,TiDB 会尝试调用 Golang GC 立刻回收内存,以最快速度缓解内存压力。</li><li>只有内存使用大于 <code>tidb_server_memory_limit_sess_min_size</code> 的 SQL 语句会被选定为最优先被 Cancel 的 SQL 语句。</li><li>目前 TiDB 一次只能 Cancel 一条 SQL 语句。如果 TiDB 完全 Cancel 掉一条 SQL 语句并回收资源后,内存使用仍然大于该变量所设限制,TiDB 会开始下一次 Cancel 操作。</li></ul><h3 id="tidb_server_memory_limit_gc_trigger-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_server_memory_limit_gc_trigger-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_server_memory_limit_gc_trigger span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_server_memory_limit_gc_trigger</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>70%</code></li><li>取值范围:<code>[50%, 99%]</code></li><li>TiDB 尝试触发 GC 的阈值。当 TiDB 的内存使用达到 <code>tidb_server_memory_limit</code> 值 <!-- -->*<!-- --> <code>tidb_server_memory_limit_gc_trigger</code> 值时,则会主动触发一次 Golang GC。在一分钟之内只会主动触发一次 GC。</li></ul><h3 id="tidb_server_memory_limit_sess_min_size-span-classversion-mark从-v640-版本开始引入span" style="position:relative"><a href="#tidb_server_memory_limit_sess_min_size-span-classversion-mark%E4%BB%8E-v640-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_server_memory_limit_sess_min_size span classversion mark从 v640 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_server_memory_limit_sess_min_size</code> <span class="version-mark">从 v6.4.0 版本开始引入</span></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>默认值:<code>134217728</code>(即 128 MB)</li><li>取值范围:<code>[128, 9223372036854775807]</code>,单位为 Byte。支持带单位的内存格式“KB|MB|GB|TB”。</li><li>开启内存限制后,TiDB 会终止当前实例上内存用量最高的 SQL 语句。本变量指定此情况下 SQL 语句被终止的最小内存用量。如果 TiDB 实例的内存超限是由许多内存使用量不明显的会话导致的,可以适当调小该变量值,使得更多会话成为 Cancel 的对象。</li></ul><h3 id="tidb_session_plan_cache_size-span-classversion-mark从-v710-版本开始引入span" style="position:relative"><a href="#tidb_session_plan_cache_size-span-classversion-mark%E4%BB%8E-v710-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_session_plan_cache_size span classversion mark从 v710 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_session_plan_cache_size</code> <span class="version-mark">从 v7.1.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>100</code></li><li>范围:<code>[1, 100000]</code></li><li>这个变量用来控制 Plan Cache 最多能够缓存的计划数量。其中,<a href="/zh/tidb/stable/sql-prepared-plan-cache">Prepare 语句执行计划缓存</a>和<a href="/zh/tidb/stable/sql-non-prepared-plan-cache">非 Prepare 语句执行计划缓存</a>共用一个缓存。</li><li>从旧版本升级到 v7.1.0 及之后的版本,<code>tidb_session_plan_cache_size</code> 的值与 <a href="#tidb_prepared_plan_cache_size-%E4%BB%8E-v610-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5"><code>tidb_prepared_plan_cache_size</code></a> 保持一致。</li></ul><h3 id="tidb_shard_allocate_step-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_shard_allocate_step-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_shard_allocate_step span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_shard_allocate_step</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:整数型</li><li>默认值:<code>9223372036854775807</code></li><li>范围:<code>[1, 9223372036854775807]</code></li><li>该变量设置为 <a href="/zh/tidb/stable/auto-random"><code>AUTO_RANDOM</code></a> 或 <a href="/zh/tidb/stable/shard-row-id-bits"><code>SHARD_ROW_ID_BITS</code></a> 属性列分配的最大连续 ID 数。通常,<code>AUTO_RANDOM</code> ID 或带有 <code>SHARD_ROW_ID_BITS</code> 属性的行 ID 在一个事务中是增量和连续的。你可以使用该变量来解决大事务场景下的热点问题。</li></ul><h3 id="tidb_simplified_metrics" style="position:relative"><a href="#tidb_simplified_metrics" aria-label="tidb_simplified_metrics permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_simplified_metrics</code></h3><ul><li>作用域:GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>该变量开启后,TiDB 将不会收集或记录 Grafana 面板未使用到的 metrics。</li></ul><h3 id="tidb_skip_ascii_check-span-classversion-mark从-v50-版本开始引入span" style="position:relative"><a href="#tidb_skip_ascii_check-span-classversion-mark%E4%BB%8E-v50-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5span" aria-label="tidb_skip_ascii_check span classversion mark从 v50 版本开始引入span permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_skip_ascii_check</code> <span class="version-mark">从 v5.0 版本开始引入</span></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>这个变量用来设置是否校验 ASCII 字符的合法性。</li><li>校验 ASCII 字符会损耗些许性能。当你确认输入的字符串为有效的 ASCII 字符时,可以将其设置为 <code>ON</code>。</li></ul><h3 id="tidb_skip_isolation_level_check" style="position:relative"><a href="#tidb_skip_isolation_level_check" aria-label="tidb_skip_isolation_level_check permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a><code>tidb_skip_isolation_level_check</code></h3><ul><li>作用域:SESSION | GLOBAL</li><li>是否持久化到集群:是</li><li>类型:布尔型</li><li>默认值:<code>OFF</code></li><li>开启这个开关之后,如果对 <code>tx_isolation</code> 赋值一个 TiDB 不支持的隔离级别,不会报错,有助于兼容其他设置了(但不依赖于)不同隔离级别的应用。</li></ul><pre><code class="language-sql">tidb> set tx_isolation='serializable'; ERROR 8048 (HY000): The isolation level 'serializable' is not supported. Set tidb_skip_isolation_level_check=1 to skip this error
推荐文章
刚毅的单杠
·
python爬取网易云音乐排行榜实例代码_python_脚本之家
1 年前
淡定的跑步鞋
·
windows10 - Microsoft Community
1 年前
神勇威武的楼梯
·
python 过滤特殊字符 (emoji) - 知乎
1 年前