相关文章推荐
爱跑步的感冒药
·
犬之岛讽刺社会 _大公网
·
6 月前
·
豪爽的皮带
·
申请建行大山白需要什么条件? - 知乎
·
7 月前
·
体贴的板凳
·
坦克700最新图片最近信息大曝光…|越野车| ...
·
1 年前
·
踏实的风衣
·
《地沟油去哪儿了?起底京畿地沟油黑色产业链》 ...
·
1 年前
·
跑龙套的圣诞树
·
笑傲江湖 - 🌈️包子漫畫
·
1 年前
·
Code
›
TiFlash 性能调优 | TiDB 文档中心
tidb
num
https://docs.pingcap.com/zh/tidb/stable/tune-tiflash-performance/
不羁的打火机
1 月前
</noscript><noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TPX49SBK" height="0" width="0" style="display: none; visibility: hidden" aria-hidden="true"/></noscript><div id="___gatsby"><div style="outline:none" tabindex="-1" id="gatsby-focus-wrapper"><header class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation4 MuiAppBar-root MuiAppBar-colorPrimary MuiAppBar-positionFixed doc-site-header mui-fixed css-r4hqpc"><div class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-11fgfqk"><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-iuftj9" tabindex="0" type="button" aria-label="menu"><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><div class="MuiBox-root css-13tqxrv"><a style="text-decoration:none" href="/zh"><svg width="152" height="36" viewbox="0 0 152 36" fill="none"><g clip-path="url(#clip0_789_1365)"><path d="M0 26.9605V9.04959C0 9.01208 0.0187549 8.98395 0.0468872 8.96519L15.5478 0.00973267C15.5759 -0.00902222 15.6134 -0.00902222 15.6416 0.00973267L31.1425 8.95581C31.1706 8.97457 31.1894 9.0027 31.1894 9.04021V26.9511C31.1894 26.9886 31.1706 27.0168 31.1425 27.0355L15.6416 35.991C15.6134 36.0097 15.5759 36.0097 15.5478 35.991L0.0468872 27.0355C0.0187549 27.0168 0 26.9886 0 26.9605Z" fill="#DC150B"/><path d="M10.3808 15.0336C10.3714 15.0242 10.3527 15.0149 10.3433 15.0242L5.25136 17.9688H5.2326C5.21384 17.9688 5.20447 17.9594 5.20447 17.9406V12.0047C5.20447 11.9953 5.21384 11.986 5.22322 11.9766L5.22322 11.9766L15.5572 6.01253C15.5665 6.00315 15.5759 6.00315 15.5853 6.01253L20.7241 8.9758L20.7335 8.98518C20.7429 8.99455 20.7335 9.01331 20.7241 9.02268L15.5759 11.9953C15.5665 12.0047 15.5572 12.0141 15.5572 12.0235V29.9625V29.9813C15.5478 29.9906 15.529 30 15.5197 29.9906L10.3902 27.0368C10.3902 27.0274 10.3808 27.018 10.3808 27.0086V15.0524V15.0336Z" fill="white"/><path d="M20.7992 26.9992C20.7804 26.9992 20.7616 26.9805 20.7616 26.9617V15.0336C20.7616 15.0149 20.771 15.0055 20.7804 14.9961L25.9286 12.0235L25.9286 12.0235C25.938 12.0141 25.938 12.0141 25.9474 12.0141C25.9661 12.0141 25.9849 12.0328 25.9849 12.0516V23.9797C25.9849 23.9985 25.9755 24.0078 25.9661 24.0172L20.8179 26.9899C20.8085 26.9992 20.8085 26.9992 20.7992 26.9992Z" fill="white"/></g><path d="M37.1894 12.4971H42.0242V26.9998H45.4248V12.4971H50.2596V9.37683H37.1894V12.4971Z" fill="black"/><path d="M53.6372 9C53.1197 9 52.6672 9.18709 52.2887 9.55826C51.9102 9.92943 51.7151 10.3941 51.7151 10.9373C51.7151 11.4503 51.9073 11.8999 52.2858 12.2802C52.6643 12.6574 53.1167 12.8505 53.6342 12.8505C54.1517 12.8505 54.5775 12.6574 54.9501 12.2802C55.3227 11.903 55.509 11.4503 55.509 10.9373C55.509 10.3941 55.3257 9.93245 54.9619 9.56128C54.5982 9.19011 54.1517 9.00302 53.6372 9.00302V9Z" fill="black"/><path d="M55.2895 14.3592H51.9864V27H55.2895V14.3592Z" fill="black"/><path d="M64.3322 9.37683H58.2613V26.9998H64.3322C66.9492 26.9998 69.028 26.2031 70.5124 24.6309C71.9939 23.0587 72.748 20.8921 72.748 18.1883C72.748 15.4845 71.9969 13.2967 70.5124 11.7336C69.028 10.1705 66.9492 9.37683 64.3322 9.37683ZM61.6619 12.4971H64.2109C65.9024 12.4971 67.1798 12.998 68.0137 13.9847C68.8506 14.9775 69.2734 16.3566 69.2734 18.0857C69.2734 19.8148 68.8476 21.2512 68.0108 22.3013C67.1769 23.3454 65.8994 23.8765 64.208 23.8765H61.659V12.494L61.6619 12.4971Z" fill="black"/><path d="M86.5964 19.1388C86.0346 18.4418 85.3663 17.9409 84.6152 17.6512V17.621C86.1883 16.8424 86.9838 15.566 86.9838 13.8278C86.9838 12.479 86.5461 11.3866 85.6856 10.5839C84.8251 9.78421 83.5566 9.37683 81.9154 9.37683H74.7948V26.9998H81.8681C83.6068 26.9998 84.9907 26.5652 85.9784 25.7082C86.972 24.8482 87.4747 23.6261 87.4747 22.075C87.4747 20.8468 87.179 19.8601 86.5994 19.1388H86.5964ZM78.1185 16.5256V12.1953H81.4718C82.1105 12.1953 82.628 12.3884 83.0095 12.7686C83.388 13.1489 83.5802 13.68 83.5802 14.3499C83.5802 15.0198 83.3909 15.5569 83.0184 15.9432C82.6458 16.3294 82.1105 16.5256 81.4216 16.5256H78.1156H78.1185ZM83.9972 21.8245C83.9972 22.5276 83.7872 23.101 83.3762 23.5295C82.9651 23.958 82.356 24.1753 81.5724 24.1753H78.1215V19.3471H81.5724C82.3235 19.3471 82.9237 19.5794 83.3525 20.0411C83.7813 20.5028 84.0001 21.1033 84.0001 21.8215L83.9972 21.8245Z" fill="black"/><path d="M97.3306 26.5V9.7H102.299C107.771 9.7 111.083 12.868 111.083 18.1C111.083 23.332 107.771 26.5 102.299 26.5H97.3306ZM102.299 24.364C106.331 24.364 108.659 22.06 108.659 18.1C108.659 14.14 106.331 11.836 102.299 11.836H99.7066V24.364H102.299ZM118.968 26.764C115.464 26.764 112.824 24.052 112.824 20.5C112.824 16.948 115.464 14.236 118.968 14.236C122.472 14.236 125.112 16.948 125.112 20.5C125.112 24.052 122.472 26.764 118.968 26.764ZM118.968 24.628C121.152 24.628 122.736 22.876 122.736 20.5C122.736 18.124 121.152 16.372 118.968 16.372C116.784 16.372 115.2 18.124 115.2 20.5C115.2 22.876 116.784 24.628 118.968 24.628ZM132.772 26.764C129.22 26.764 126.7 24.124 126.7 20.5C126.7 16.876 129.22 14.236 132.772 14.236C135.652 14.236 137.884 15.964 138.244 18.532H135.844C135.532 17.236 134.332 16.372 132.772 16.372C130.588 16.372 129.076 18.076 129.076 20.5C129.076 22.9 130.588 24.628 132.772 24.628C134.332 24.628 135.532 23.764 135.844 22.468H138.244C137.884 25.036 135.652 26.764 132.772 26.764ZM144.557 26.764C141.677 26.764 139.781 25.108 139.709 22.732H142.085C142.229 23.956 142.973 24.724 144.581 24.724C145.733 24.724 146.765 24.34 146.765 23.332C146.765 22.588 146.333 22.06 145.157 21.7L143.333 21.172C141.173 20.548 140.093 19.3 140.093 17.716C140.093 15.604 141.965 14.236 144.413 14.236C146.885 14.236 148.685 15.7 148.829 17.74H146.453C146.285 16.828 145.445 16.204 144.341 16.204C143.261 16.204 142.469 16.804 142.469 17.716C142.469 18.412 142.925 18.868 144.245 19.228L146.069 19.732C148.109 20.308 149.141 21.556 149.141 23.188C149.141 25.396 147.197 26.764 144.557 26.764Z" fill="black"/><defs><clippath id="clip0_789_1365"><rect width="31.1894" height="36" fill="white"/></clippath></defs></svg></a></div><div class="css-2iqpys"><div class="MuiBox-root css-irbys9"><a style="text-decoration:none" hreflang="zh" href="/zh/tidb/stable"><div class="MuiTypography-root MuiTypography-body1 css-195ggqq">TiDB</div></a></div><div class="MuiBox-root css-kiou0g"><a class="MuiTypography-root MuiTypography-body1 css-ae3kd9" target="_blank" href="https://asktug.com/" style="text-decoration:none"><div class="MuiTypography-root MuiTypography-body1 css-195ggqq">社区</div></a></div><div class="MuiBox-root css-kiou0g"><a class="MuiTypography-root MuiTypography-body1 css-ae3kd9" target="_blank" href="https://cn.pingcap.com/contact/" style="text-decoration:none"><div class="MuiTypography-root MuiTypography-body1 css-195ggqq">联系我们</div></a></div><div class="MuiBox-root css-kiou0g"><a class="MuiTypography-root MuiTypography-body1 css-ae3kd9" target="_blank" href="https://cn.pingcap.com/product/#SelectProduct" style="text-decoration:none"><div class="MuiTypography-root MuiTypography-body1 css-195ggqq"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" 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><div class="MuiBox-root css-1vn3uc0"><button class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textInherit MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorInherit MuiButton-disableElevation css-tjg32r" tabindex="0" type="button" id="header-nav-items" aria-haspopup="true"><span class="MuiButton-startIcon MuiButton-iconSizeMedium css-1l6c7y9"><svg width="152" height="36" viewbox="0 0 152 36" fill="none"><g clip-path="url(#clip0_789_1365)"><path d="M0 26.9605V9.04959C0 9.01208 0.0187549 8.98395 0.0468872 8.96519L15.5478 0.00973267C15.5759 -0.00902222 15.6134 -0.00902222 15.6416 0.00973267L31.1425 8.95581C31.1706 8.97457 31.1894 9.0027 31.1894 9.04021V26.9511C31.1894 26.9886 31.1706 27.0168 31.1425 27.0355L15.6416 35.991C15.6134 36.0097 15.5759 36.0097 15.5478 35.991L0.0468872 27.0355C0.0187549 27.0168 0 26.9886 0 26.9605Z" fill="#DC150B"/><path d="M10.3808 15.0336C10.3714 15.0242 10.3527 15.0149 10.3433 15.0242L5.25136 17.9688H5.2326C5.21384 17.9688 5.20447 17.9594 5.20447 17.9406V12.0047C5.20447 11.9953 5.21384 11.986 5.22322 11.9766L5.22322 11.9766L15.5572 6.01253C15.5665 6.00315 15.5759 6.00315 15.5853 6.01253L20.7241 8.9758L20.7335 8.98518C20.7429 8.99455 20.7335 9.01331 20.7241 9.02268L15.5759 11.9953C15.5665 12.0047 15.5572 12.0141 15.5572 12.0235V29.9625V29.9813C15.5478 29.9906 15.529 30 15.5197 29.9906L10.3902 27.0368C10.3902 27.0274 10.3808 27.018 10.3808 27.0086V15.0524V15.0336Z" fill="white"/><path d="M20.7992 26.9992C20.7804 26.9992 20.7616 26.9805 20.7616 26.9617V15.0336C20.7616 15.0149 20.771 15.0055 20.7804 14.9961L25.9286 12.0235L25.9286 12.0235C25.938 12.0141 25.938 12.0141 25.9474 12.0141C25.9661 12.0141 25.9849 12.0328 25.9849 12.0516V23.9797C25.9849 23.9985 25.9755 24.0078 25.9661 24.0172L20.8179 26.9899C20.8085 26.9992 20.8085 26.9992 20.7992 26.9992Z" fill="white"/></g><path d="M37.1894 12.4971H42.0242V26.9998H45.4248V12.4971H50.2596V9.37683H37.1894V12.4971Z" fill="black"/><path d="M53.6372 9C53.1197 9 52.6672 9.18709 52.2887 9.55826C51.9102 9.92943 51.7151 10.3941 51.7151 10.9373C51.7151 11.4503 51.9073 11.8999 52.2858 12.2802C52.6643 12.6574 53.1167 12.8505 53.6342 12.8505C54.1517 12.8505 54.5775 12.6574 54.9501 12.2802C55.3227 11.903 55.509 11.4503 55.509 10.9373C55.509 10.3941 55.3257 9.93245 54.9619 9.56128C54.5982 9.19011 54.1517 9.00302 53.6372 9.00302V9Z" fill="black"/><path d="M55.2895 14.3592H51.9864V27H55.2895V14.3592Z" fill="black"/><path d="M64.3322 9.37683H58.2613V26.9998H64.3322C66.9492 26.9998 69.028 26.2031 70.5124 24.6309C71.9939 23.0587 72.748 20.8921 72.748 18.1883C72.748 15.4845 71.9969 13.2967 70.5124 11.7336C69.028 10.1705 66.9492 9.37683 64.3322 9.37683ZM61.6619 12.4971H64.2109C65.9024 12.4971 67.1798 12.998 68.0137 13.9847C68.8506 14.9775 69.2734 16.3566 69.2734 18.0857C69.2734 19.8148 68.8476 21.2512 68.0108 22.3013C67.1769 23.3454 65.8994 23.8765 64.208 23.8765H61.659V12.494L61.6619 12.4971Z" fill="black"/><path d="M86.5964 19.1388C86.0346 18.4418 85.3663 17.9409 84.6152 17.6512V17.621C86.1883 16.8424 86.9838 15.566 86.9838 13.8278C86.9838 12.479 86.5461 11.3866 85.6856 10.5839C84.8251 9.78421 83.5566 9.37683 81.9154 9.37683H74.7948V26.9998H81.8681C83.6068 26.9998 84.9907 26.5652 85.9784 25.7082C86.972 24.8482 87.4747 23.6261 87.4747 22.075C87.4747 20.8468 87.179 19.8601 86.5994 19.1388H86.5964ZM78.1185 16.5256V12.1953H81.4718C82.1105 12.1953 82.628 12.3884 83.0095 12.7686C83.388 13.1489 83.5802 13.68 83.5802 14.3499C83.5802 15.0198 83.3909 15.5569 83.0184 15.9432C82.6458 16.3294 82.1105 16.5256 81.4216 16.5256H78.1156H78.1185ZM83.9972 21.8245C83.9972 22.5276 83.7872 23.101 83.3762 23.5295C82.9651 23.958 82.356 24.1753 81.5724 24.1753H78.1215V19.3471H81.5724C82.3235 19.3471 82.9237 19.5794 83.3525 20.0411C83.7813 20.5028 84.0001 21.1033 84.0001 21.8215L83.9972 21.8245Z" fill="black"/><path d="M97.3306 26.5V9.7H102.299C107.771 9.7 111.083 12.868 111.083 18.1C111.083 23.332 107.771 26.5 102.299 26.5H97.3306ZM102.299 24.364C106.331 24.364 108.659 22.06 108.659 18.1C108.659 14.14 106.331 11.836 102.299 11.836H99.7066V24.364H102.299ZM118.968 26.764C115.464 26.764 112.824 24.052 112.824 20.5C112.824 16.948 115.464 14.236 118.968 14.236C122.472 14.236 125.112 16.948 125.112 20.5C125.112 24.052 122.472 26.764 118.968 26.764ZM118.968 24.628C121.152 24.628 122.736 22.876 122.736 20.5C122.736 18.124 121.152 16.372 118.968 16.372C116.784 16.372 115.2 18.124 115.2 20.5C115.2 22.876 116.784 24.628 118.968 24.628ZM132.772 26.764C129.22 26.764 126.7 24.124 126.7 20.5C126.7 16.876 129.22 14.236 132.772 14.236C135.652 14.236 137.884 15.964 138.244 18.532H135.844C135.532 17.236 134.332 16.372 132.772 16.372C130.588 16.372 129.076 18.076 129.076 20.5C129.076 22.9 130.588 24.628 132.772 24.628C134.332 24.628 135.532 23.764 135.844 22.468H138.244C137.884 25.036 135.652 26.764 132.772 26.764ZM144.557 26.764C141.677 26.764 139.781 25.108 139.709 22.732H142.085C142.229 23.956 142.973 24.724 144.581 24.724C145.733 24.724 146.765 24.34 146.765 23.332C146.765 22.588 146.333 22.06 145.157 21.7L143.333 21.172C141.173 20.548 140.093 19.3 140.093 17.716C140.093 15.604 141.965 14.236 144.413 14.236C146.885 14.236 148.685 15.7 148.829 17.74H146.453C146.285 16.828 145.445 16.204 144.341 16.204C143.261 16.204 142.469 16.804 142.469 17.716C142.469 18.412 142.925 18.868 144.245 19.228L146.069 19.732C148.109 20.308 149.141 21.556 149.141 23.188C149.141 25.396 147.197 26.764 144.557 26.764Z" fill="black"/><defs><clippath id="clip0_789_1365"><rect width="31.1894" height="36" fill="white"/></clippath></defs></svg></span><span class="MuiButton-endIcon MuiButton-iconSizeMedium css-pt151d"><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><div class="css-1w2hxsf"><div class="MuiBox-root css-19itmc6"><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="TranslateIcon"><path d="m12.87 15.07-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7 1.62-4.33L19.12 17h-3.24z"/></svg></button><button class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textInherit MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-colorInherit MuiButton-disableElevation css-1r5wmim" tabindex="0" type="button" id="header-lang-switch" aria-haspopup="true"><span class="MuiButton-startIcon MuiButton-iconSizeMedium css-1l6c7y9"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1msahp5" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="TranslateIcon"><path d="m12.87 15.07-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7 1.62-4.33L19.12 17h-3.24z"/></svg></span><span class="MuiButton-endIcon MuiButton-iconSizeMedium css-pt151d"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1msahp5" 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><div class="css-1iegyem"><div class="MuiBox-root css-0"><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><form class="MuiBox-root css-1dl8tgy" novalidate="" autocomplete="off"><div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-7omol5"><div class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedStart css-10r6rap"><div class="MuiInputAdornment-root MuiInputAdornment-positionStart MuiInputAdornment-outlined MuiInputAdornment-sizeSmall css-1a6giau"><span class="notranslate"></span><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-1k33q06" 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><input type="search" aria-invalid="false" id="doc-search" placeholder="搜索文档" value="" class="MuiInputBase-input MuiOutlinedInput-input MuiInputBase-inputTypeSearch MuiInputBase-inputSizeSmall MuiInputBase-inputAdornedStart css-1a7iucg"/><fieldset aria-hidden="true" class="MuiOutlinedInput-notchedOutline css-igs3ac"><legend class="css-hdw1oc"><span class="notranslate"></span></legend></fieldset></div></div></form></div></div></div></div></header><div class="PingCAP-Doc MuiBox-root css-s1brf2"><div class="MuiBox-root css-hboir5"><aside class="MuiBox-root css-2tzg8"><div class="MuiBox-root css-ysaqso"><button class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-disableElevation css-1q0sqyi" tabindex="0" type="button" id="version-select-button" aria-haspopup="true"><div class="MuiTypography-root MuiTypography-body1 css-1alj0g7">v8.1</div><span class="MuiButton-endIcon MuiButton-iconSizeMedium css-pt151d"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1rrdqpg" 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><ul role="tree" id="left-nav-treeview" aria-multiselectable="false" class="MuiTreeView-root css-12mehxg" tabindex="0" aria-label="left navigation"><a class="MuiTypography-root MuiTypography-body1 css-ae3kd9" target="_blank" href="https://docs.pingcap.com/zh" style="text-decoration:none;width:100%;color:inherit"><li class="MuiTreeItem-root css-14t19hb" role="treeitem" id="left-nav-treeview-0-0" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><div class="MuiBox-root css-3o0h5k"/><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">文档中心</div></div></div></div></div></li></a><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">关于 TiDB</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">快速上手</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">应用开发</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">部署标准集群</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">数据迁移</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">数据集成</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">运维操作</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">监控与告警</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">故障诊断</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" role="treeitem" aria-expanded="true" id="left-nav-treeview-0-10" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content Mui-expanded" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-13dmm4z" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">性能调优</div></div></div></div></div><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-14t19hb" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-10-0" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-2jyri7"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">优化手册</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" role="treeitem" aria-expanded="true" id="left-nav-treeview-0-10-1" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content Mui-expanded" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-2jyri7"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-13dmm4z" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">配置调优</div></div></div></div></div><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"><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/tune-operating-system"><li class="MuiTreeItem-root css-14t19hb" role="treeitem" id="left-nav-treeview-0-10-1-0" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-xeut16"><div class="MuiBox-root css-3o0h5k"/><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">操作系统性能参数调优</div></div></div></div></div></li></a><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/configure-memory-usage"><li class="MuiTreeItem-root css-14t19hb" role="treeitem" id="left-nav-treeview-0-10-1-1" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-xeut16"><div class="MuiBox-root css-3o0h5k"/><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">TiDB 内存调优</div></div></div></div></div></li></a><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/tune-tikv-thread-performance"><li class="MuiTreeItem-root css-14t19hb" role="treeitem" id="left-nav-treeview-0-10-1-2" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-xeut16"><div class="MuiBox-root css-3o0h5k"/><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">TiKV 线程调优</div></div></div></div></div></li></a><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/tune-tikv-memory-performance"><li class="MuiTreeItem-root css-14t19hb" role="treeitem" id="left-nav-treeview-0-10-1-3" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-xeut16"><div class="MuiBox-root css-3o0h5k"/><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">TiKV 内存调优</div></div></div></div></div></li></a><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/follower-read"><li class="MuiTreeItem-root css-14t19hb" role="treeitem" id="left-nav-treeview-0-10-1-4" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-xeut16"><div class="MuiBox-root css-3o0h5k"/><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">TiKV Follower Read</div></div></div></div></div></li></a><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/tune-region-performance"><li class="MuiTreeItem-root css-14t19hb" role="treeitem" id="left-nav-treeview-0-10-1-5" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-xeut16"><div class="MuiBox-root css-3o0h5k"/><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">Region 性能调优</div></div></div></div></div></li></a><a aria-current="page" style="text-decoration:none;width:100%;color:inherit" class="" href="/zh/tidb/stable/tune-tiflash-performance"><li class="MuiTreeItem-root css-14t19hb" role="treeitem" aria-selected="true" id="left-nav-treeview-0-10-1-6" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content Mui-expanded Mui-selected" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-xeut16"><div class="MuiBox-root css-3o0h5k"/><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">TiFlash 调优</div></div></div></div></div></li></a><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/coprocessor-cache"><li class="MuiTreeItem-root css-14t19hb" role="treeitem" id="left-nav-treeview-0-10-1-7" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-xeut16"><div class="MuiBox-root css-3o0h5k"/><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">下推计算结果缓存</div></div></div></div></div></li></a><li class="MuiTreeItem-root css-14t19hb" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-10-1-8" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-xeut16"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">垃圾回收 (GC)</div></div></div></div></div></li></div></div></ul></li><li class="MuiTreeItem-root css-14t19hb" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-10-2" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-2jyri7"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">SQL 性能调优</div></div></div></div></div></li></div></div></ul></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">教程</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">TiDB 工具</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" role="treeitem" aria-expanded="false" id="left-nav-treeview-0-13" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">参考指南</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">常见问题解答 (FAQ)</div></div></div></div></div></li><li class="MuiTreeItem-root css-14t19hb" 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-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTreeItem-ChevronRightIcon css-hkir54" 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 class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">版本发布历史</div></div></div></div></div></li><a style="text-decoration:none;width:100%;color:inherit" href="/zh/tidb/stable/glossary"><li class="MuiTreeItem-root css-14t19hb" role="treeitem" id="left-nav-treeview-0-16" tabindex="-1" style="margin-top:0.1875rem;margin-bottom:0.1875rem"><div class="css-fhn3dm MuiTreeItem-content" style="width:inherit"><div class="MuiTreeItem-iconContainer"/><div class="MuiTreeItem-label"><div class="css-w8t2sr"><div class="MuiBox-root css-3o0h5k"/><div class="MuiBox-root css-8atqhb"><div class="MuiTypography-root MuiTypography-body1 css-1drfgi3">术语表</div></div></div></div></div></li></a></ul></div></aside><main class="MuiBox-root css-sb2sd0"><div class="MuiBox-root css-w0vdto"><div class="css-1q5cbag"><div class="MuiBox-root css-was4pq"><div class="MuiContainer-root MuiContainer-maxWidthLg MuiContainer-disableGutters doc-content css-5csqms"><div class="markdown-body MuiBox-root css-0"><h1 id="tiflash-性能调优" style="position:relative">TiFlash 性能调优<a href="#tiflash-%E6%80%A7%E8%83%BD%E8%B0%83%E4%BC%98" aria-label="tiflash 性能调优 permalink" class="anchor after"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-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>本文介绍了 TiFlash 性能调优的几种方式,包括机器资源规划和 TiDB 参数调优,通过这些方式,TiFlash 性能可以达到最优状态。</p><h2 id="资源规划" style="position:relative">资源规划<a href="#%E8%B5%84%E6%BA%90%E8%A7%84%E5%88%92" aria-label="资源规划 permalink" class="anchor after"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-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><p>对于希望节省机器资源,并且完全没有隔离要求的场景,可以使用 TiKV 和 TiFlash 联合部署。建议为 TiKV 与 TiFlash 分别留够资源,同时避免共享磁盘。</p><h2 id="tidb-相关参数调优" style="position:relative">TiDB 相关参数调优<a href="#tidb-%E7%9B%B8%E5%85%B3%E5%8F%82%E6%95%B0%E8%B0%83%E4%BC%98" aria-label="tidb 相关参数调优 permalink" class="anchor after"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-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><p>本部分介绍如何通过调整 TiDB 相关参数来提升 TiFlash 性能,具体包括如下几个方面:</p><ul><li><a href="#%E5%BC%BA%E5%88%B6%E5%BC%80%E5%90%AF-mpp-%E6%A8%A1%E5%BC%8F">强制开启 MPP 模式</a></li><li><a href="#%E8%81%9A%E5%90%88%E4%B8%8B%E6%8E%A8-join-%E6%88%96-union">聚合下推 <code>Join</code> 或 <code>Union</code></a></li><li><a href="#%E5%BC%80%E5%90%AF-distinct-%E4%BC%98%E5%8C%96">开启 <code>Distinct</code> 优化</a></li><li><a href="#%E4%BD%BF%E7%94%A8-alter-tablecompact-%E6%95%B4%E7%90%86%E6%95%B0%E6%8D%AE">使用 <code>ALTER TABLE...COMPACT</code> 整理数据</a></li><li><a href="#%E4%BD%BF%E7%94%A8-broadcast-hash-join-%E4%BB%A3%E6%9B%BF-shuffled-hash-join">使用 Broadcast Hash Join 代替 Shuffled Hash Join</a></li><li><a href="#%E8%AE%BE%E7%BD%AE%E6%9B%B4%E5%A4%A7%E7%9A%84%E6%89%A7%E8%A1%8C%E5%B9%B6%E5%8F%91%E5%BA%A6">设置更大的执行并发度</a></li><li><a href="#%E8%AE%BE%E7%BD%AE%E7%BB%86%E7%B2%92%E5%BA%A6-shuffle-%E5%8F%82%E6%95%B0">设置细粒度 Shuffle 参数</a></li></ul><h3 id="强制开启-mpp-模式" style="position:relative">强制开启 MPP 模式<a href="#%E5%BC%BA%E5%88%B6%E5%BC%80%E5%90%AF-mpp-%E6%A8%A1%E5%BC%8F" aria-label="强制开启 mpp 模式 permalink" class="anchor after"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a></h3><p>MPP 执行计划可以充分利用分布式计算资源,从而显著提高批量数据查询的效率。当查询没有生成 MPP 执行计划的时候,你可以强制开启 MPP:</p><p><a href="/zh/tidb/stable/system-variables#tidb_enforce_mpp-从-v51-版本开始引入"><code>tidb_enforce_mpp</code></a> 变量用于控制是否忽略优化器代价估算,强制使用 TiFlash 的 MPP 模式执行查询。要开启 MPP 模式查询,执行如下命令:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia"><span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_enforce_mpp <span class="hljs-operator">=</span> <span class="hljs-keyword">ON</span>; </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>在以下示例中,<code>tidb_enforce_mpp</code> 开启前,TiDB 需要从 TiKV 读取数据,并在 TiDB 侧执行 <code>Join</code> 和 <code>Aggregation</code>。<code>tidb_enforce_mpp</code> 开启后,<code>Join</code> 和 <code>Aggregation</code> 被下推到了 TiFlash。需要注意的是,有时候优化器生成的执行计划并不稳定,可能生成 <code>MPP</code>,也可能不生成,这时候可以开启 <code>tidb_enforce_mpp</code>,强制优化器生成 <code>MPP</code> 计划。</p><p>MPP 模式开启前:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> o_orderpriority, <span class="hljs-built_in">count</span>(<span class="hljs-operator">*</span>) <span class="hljs-keyword">as</span> order_count <span class="hljs-keyword">from</span> orders <span class="hljs-keyword">where</span> o_orderdate <span class="hljs-operator">>=</span> <span class="hljs-string">'1995-01-01'</span> <span class="hljs-keyword">and</span> o_orderdate <span class="hljs-operator"><</span> date_add(<span class="hljs-string">'1995-01-01'</span>, <span class="hljs-type">interval</span> <span class="hljs-string">'3'</span> <span class="hljs-keyword">month</span>) <span class="hljs-keyword">and</span> <span class="hljs-keyword">exists</span> (<span class="hljs-keyword">select</span> <span class="hljs-operator">*</span> <span class="hljs-keyword">from</span> lineitem <span class="hljs-keyword">where</span> l_orderkey <span class="hljs-operator">=</span> o_orderkey <span class="hljs-keyword">and</span> l_commitdate <span class="hljs-operator"><</span> l_receiptdate) <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span> o_orderpriority; <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------+--------------+-----------+-----------+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------+--------------+-----------+-----------+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------+</span> <span class="hljs-operator">|</span> Projection_9 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">5</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">22.8</span>s, loops:<span class="hljs-number">5</span>, Concurrency:OFF <span class="hljs-operator">|</span> tpch_100.orders.o_orderpriority, <span class="hljs-keyword">Column</span>#<span class="hljs-number">27</span> <span class="hljs-operator">|</span> <span class="hljs-number">1016</span> Bytes <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_10 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">5</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">22.8</span>s, loops:<span class="hljs-number">5</span>, partial_worker:{wall_time:<span class="hljs-number">22.817403422</span>s, concurrency:<span class="hljs-number">5</span>, task_num:<span class="hljs-number">5027</span>, tot_wait:<span class="hljs-number">1</span>m52<span class="hljs-number">.560509138</span>s, tot_exec:<span class="hljs-number">1.523754659</span>s, tot_time:<span class="hljs-number">1</span>m54<span class="hljs-number">.086196522</span>s, max:<span class="hljs-number">22.817363394</span>s, p95:<span class="hljs-number">22.817363394</span>s}, final_worker:{wall_time:<span class="hljs-number">22.817416046</span>s, concurrency:<span class="hljs-number">5</span>, task_num:<span class="hljs-number">20</span>, tot_wait:<span class="hljs-number">1</span>m54<span class="hljs-number">.086784741</span>s, tot_exec:<span class="hljs-number">155.94</span>µs, tot_time:<span class="hljs-number">1</span>m54<span class="hljs-number">.086948982</span>s, max:<span class="hljs-number">22.817396284</span>s, p95:<span class="hljs-number">22.817396284</span>s} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:tpch_100.orders.o_orderpriority, funcs:<span class="hljs-built_in">count</span>(<span class="hljs-number">1</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">27</span>, funcs:firstrow(tpch_100.orders.o_orderpriority)<span class="hljs-operator">-</span><span class="hljs-operator">></span>tpch_100.orders.o_orderpriority <span class="hljs-operator">|</span> <span class="hljs-number">511.7</span> KB <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─IndexHashJoin_18 <span class="hljs-operator">|</span> <span class="hljs-number">4429262.13</span> <span class="hljs-operator">|</span> <span class="hljs-number">5145138</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">22.8</span>s, loops:<span class="hljs-number">5028</span>, <span class="hljs-keyword">inner</span>:{total:<span class="hljs-number">1</span>m52<span class="hljs-number">.6</span>s, concurrency:<span class="hljs-number">5</span>, task:<span class="hljs-number">227</span>, construct:<span class="hljs-number">5.17</span>s, <span class="hljs-keyword">fetch</span>:<span class="hljs-number">1</span>m40s, build:<span class="hljs-number">1.22</span>s, <span class="hljs-keyword">join</span>:<span class="hljs-number">7.49</span>s} <span class="hljs-operator">|</span> semi <span class="hljs-keyword">join</span>, <span class="hljs-keyword">inner</span>:IndexLookUp_15, <span class="hljs-keyword">outer</span> key:tpch_100.orders.o_orderkey, <span class="hljs-keyword">inner</span> key:tpch_100.lineitem.l_orderkey, equal cond:eq(tpch_100.orders.o_orderkey, tpch_100.lineitem.l_orderkey) <span class="hljs-operator">|</span> <span class="hljs-number">46.8</span> MB <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> ├─TableReader_37(Build) <span class="hljs-operator">|</span> <span class="hljs-number">5536577.67</span> <span class="hljs-operator">|</span> <span class="hljs-number">5610951</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">4.89</span>s, loops:<span class="hljs-number">5467</span>, cop_task: {num: <span class="hljs-number">2127</span>, max: <span class="hljs-number">408.7</span>ms, min: <span class="hljs-number">277.5</span>µs, avg: <span class="hljs-number">81.6</span>ms, p95: <span class="hljs-number">249.7</span>ms, max_proc_keys: <span class="hljs-number">226272</span>, p95_proc_keys: <span class="hljs-number">220128</span>, tot_proc: <span class="hljs-number">2</span>m50<span class="hljs-number">.2</span>s, tot_wait: <span class="hljs-number">40</span>ms, rpc_num: <span class="hljs-number">2127</span>, rpc_time: <span class="hljs-number">2</span>m53<span class="hljs-number">.6</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.02</span>, distsql_concurrency: <span class="hljs-number">15</span>} <span class="hljs-operator">|</span> data:Selection_36 <span class="hljs-operator">|</span> <span class="hljs-number">3.42</span> MB <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─Selection_36 <span class="hljs-operator">|</span> <span class="hljs-number">5536577.67</span> <span class="hljs-operator">|</span> <span class="hljs-number">5610951</span> <span class="hljs-operator">|</span> cop[tikv] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tikv_task:{proc max:<span class="hljs-number">402</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">79.7</span>ms, p80:<span class="hljs-number">151</span>ms, p95:<span class="hljs-number">245</span>ms, iters:<span class="hljs-number">155122</span>, tasks:<span class="hljs-number">2127</span>}, scan_detail: {total_process_keys: <span class="hljs-number">149478336</span>, total_process_keys_size: <span class="hljs-number">22705157593</span>, total_keys: <span class="hljs-number">149480413</span>, get_snapshot_time: <span class="hljs-number">187.9</span>ms, rocksdb: {key_skipped_count: <span class="hljs-number">149478336</span>, block: {cache_hit_count: <span class="hljs-number">393690</span>}}} <span class="hljs-operator">|</span> ge(tpch_100.orders.o_orderdate, <span class="hljs-number">1995</span><span class="hljs-number">-01</span><span class="hljs-number">-01</span> <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00.000000</span>), lt(tpch_100.orders.o_orderdate, <span class="hljs-number">1995</span><span class="hljs-number">-04</span><span class="hljs-number">-01</span> <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00.000000</span>) <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─TableFullScan_35 <span class="hljs-operator">|</span> <span class="hljs-number">150000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">150000000</span> <span class="hljs-operator">|</span> cop[tikv] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:orders <span class="hljs-operator">|</span> tikv_task:{proc max:<span class="hljs-number">382</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">74.6</span>ms, p80:<span class="hljs-number">141</span>ms, p95:<span class="hljs-number">229</span>ms, iters:<span class="hljs-number">155122</span>, tasks:<span class="hljs-number">2127</span>} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─IndexLookUp_15(Probe) <span class="hljs-operator">|</span> <span class="hljs-number">22018496.89</span> <span class="hljs-operator">|</span> <span class="hljs-number">14185840</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">1</span>m33<span class="hljs-number">.4</span>s, loops:<span class="hljs-number">14204</span>, index_task: {total_time: <span class="hljs-number">1</span>m10<span class="hljs-number">.8</span>s, fetch_handle: <span class="hljs-number">1</span>m10<span class="hljs-number">.7</span>s, build: <span class="hljs-number">3.9</span>ms, wait: <span class="hljs-number">13.3</span>ms}, table_task: {total_time: <span class="hljs-number">1</span>m44<span class="hljs-number">.4</span>s, num: <span class="hljs-number">1989</span>, concurrency: <span class="hljs-number">5</span>} <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-number">17.9</span> KB <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> ├─IndexRangeScan_12(Build) <span class="hljs-operator">|</span> <span class="hljs-number">27523121.11</span> <span class="hljs-operator">|</span> <span class="hljs-number">22441356</span> <span class="hljs-operator">|</span> cop[tikv] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:lineitem, index:<span class="hljs-keyword">PRIMARY</span>(L_ORDERKEY, L_LINENUMBER) <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">1</span>m8<span class="hljs-number">.8</span>s, loops:<span class="hljs-number">23635</span>, cop_task: {num: <span class="hljs-number">12537</span>, max: <span class="hljs-number">179.3</span>ms, min: <span class="hljs-number">331.4</span>µs, avg: <span class="hljs-number">22.7</span>ms, p95: <span class="hljs-number">66.9</span>ms, max_proc_keys: <span class="hljs-number">13755</span>, p95_proc_keys: <span class="hljs-number">5088</span>, tot_proc: <span class="hljs-number">3</span>m44s, tot_wait: <span class="hljs-number">129</span>ms, rpc_num: <span class="hljs-number">12537</span>, rpc_time: <span class="hljs-number">4</span>m44s, copr_cache_hit_ratio: <span class="hljs-number">0.06</span>, distsql_concurrency: <span class="hljs-number">15</span>}, tikv_task:{proc max:<span class="hljs-number">170</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">18.8</span>ms, p80:<span class="hljs-number">29</span>ms, p95:<span class="hljs-number">62</span>ms, iters:<span class="hljs-number">68823</span>, tasks:<span class="hljs-number">12537</span>}, scan_detail: {total_process_keys: <span class="hljs-number">21985403</span>, total_process_keys_size: <span class="hljs-number">1165226359</span>, total_keys: <span class="hljs-number">27492546</span>, get_snapshot_time: <span class="hljs-number">563.1</span>ms, rocksdb: {key_skipped_count: <span class="hljs-number">21985403</span>, block: {cache_hit_count: <span class="hljs-number">44004354</span>}}} <span class="hljs-operator">|</span> <span class="hljs-keyword">range</span>: decided <span class="hljs-keyword">by</span> [eq(tpch_100.lineitem.l_orderkey, tpch_100.orders.o_orderkey)], keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Selection_14(Probe) <span class="hljs-operator">|</span> <span class="hljs-number">22018496.89</span> <span class="hljs-operator">|</span> <span class="hljs-number">14185840</span> <span class="hljs-operator">|</span> cop[tikv] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">1</span>m34<span class="hljs-number">.8</span>s, loops:<span class="hljs-number">16882</span>, cop_task: {num: <span class="hljs-number">12057</span>, max: <span class="hljs-number">240.4</span>ms, min: <span class="hljs-number">328.5</span>µs, avg: <span class="hljs-number">20.4</span>ms, p95: <span class="hljs-number">73.1</span>ms, max_proc_keys: <span class="hljs-number">15005</span>, p95_proc_keys: <span class="hljs-number">6118</span>, tot_proc: <span class="hljs-number">3</span>m39<span class="hljs-number">.8</span>s, tot_wait: <span class="hljs-number">300</span>ms, rpc_num: <span class="hljs-number">12057</span>, rpc_time: <span class="hljs-number">4</span>m5<span class="hljs-number">.7</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.28</span>, distsql_concurrency: <span class="hljs-number">15</span>}, tikv_task:{proc max:<span class="hljs-number">230</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">27.5</span>ms, p80:<span class="hljs-number">45</span>ms, p95:<span class="hljs-number">82</span>ms, iters:<span class="hljs-number">74165</span>, tasks:<span class="hljs-number">12057</span>}, scan_detail: {total_process_keys: <span class="hljs-number">19916937</span>, total_process_keys_size: <span class="hljs-number">3957799619</span>, total_keys: <span class="hljs-number">24053143</span>, get_snapshot_time: <span class="hljs-number">1.07</span>s, rocksdb: {key_skipped_count: <span class="hljs-number">19254567</span>, block: {cache_hit_count: <span class="hljs-number">37816908</span>}}} <span class="hljs-operator">|</span> lt(tpch_100.lineitem.l_commitdate, tpch_100.lineitem.l_receiptdate) <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableRowIDScan_13 <span class="hljs-operator">|</span> <span class="hljs-number">27523121.11</span> <span class="hljs-operator">|</span> <span class="hljs-number">22441356</span> <span class="hljs-operator">|</span> cop[tikv] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:lineitem <span class="hljs-operator">|</span> tikv_task:{proc max:<span class="hljs-number">230</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">27.2</span>ms, p80:<span class="hljs-number">45</span>ms, p95:<span class="hljs-number">81</span>ms, iters:<span class="hljs-number">74165</span>, tasks:<span class="hljs-number">12057</span>} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------+--------------+-----------+-----------+---------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------+</span> <span class="hljs-number">10</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span> (<span class="hljs-number">22.82</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>开启 MPP 模式:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> <span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_enforce_mpp <span class="hljs-operator">=</span> <span class="hljs-keyword">ON</span>; Query OK, <span class="hljs-number">0</span> <span class="hljs-keyword">rows</span> affected (<span class="hljs-number">0.00</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>MPP 模式开启后:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> o_orderpriority, <span class="hljs-built_in">count</span>(<span class="hljs-operator">*</span>) <span class="hljs-keyword">as</span> order_count <span class="hljs-keyword">from</span> orders <span class="hljs-keyword">where</span> o_orderdate <span class="hljs-operator">>=</span> <span class="hljs-string">'1995-01-01'</span> <span class="hljs-keyword">and</span> o_orderdate <span class="hljs-operator"><</span> date_add(<span class="hljs-string">'1995-01-01'</span>, <span class="hljs-type">interval</span> <span class="hljs-string">'3'</span> <span class="hljs-keyword">month</span>) <span class="hljs-keyword">and</span> <span class="hljs-keyword">exists</span> (<span class="hljs-keyword">select</span> <span class="hljs-operator">*</span> <span class="hljs-keyword">from</span> lineitem <span class="hljs-keyword">where</span> l_orderkey <span class="hljs-operator">=</span> o_orderkey <span class="hljs-keyword">and</span> l_commitdate <span class="hljs-operator"><</span> l_receiptdate) <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span> o_orderpriority; <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------------------+--------------+-----------+--------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------------------+--------------+-----------+--------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> TableReader_59 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">5</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">5.97</span>s, loops:<span class="hljs-number">2</span>, cop_task: {num: <span class="hljs-number">8</span>, max: <span class="hljs-number">0</span>s, min: <span class="hljs-number">0</span>s, avg: <span class="hljs-number">0</span>s, p95: <span class="hljs-number">0</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>} <span class="hljs-operator">|</span> data:ExchangeSender_58 <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_58 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">5</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">5.97</span>s, min:<span class="hljs-number">5.97</span>s, avg: <span class="hljs-number">5.97</span>s, p80:<span class="hljs-number">5.97</span>s, p95:<span class="hljs-number">5.97</span>s, iters:<span class="hljs-number">5</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: PassThrough <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Projection_10 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">5</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">5.97</span>s, min:<span class="hljs-number">5.96</span>s, avg: <span class="hljs-number">5.97</span>s, p80:<span class="hljs-number">5.97</span>s, p95:<span class="hljs-number">5.97</span>s, iters:<span class="hljs-number">5</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> tpch_100.orders.o_orderpriority, <span class="hljs-keyword">Column</span>#<span class="hljs-number">27</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Projection_54 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">5</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">5.97</span>s, min:<span class="hljs-number">5.96</span>s, avg: <span class="hljs-number">5.97</span>s, p80:<span class="hljs-number">5.97</span>s, p95:<span class="hljs-number">5.97</span>s, iters:<span class="hljs-number">5</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">Column</span>#<span class="hljs-number">27</span>, tpch_100.orders.o_orderpriority <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_55 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">5</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">5.97</span>s, min:<span class="hljs-number">5.96</span>s, avg: <span class="hljs-number">5.97</span>s, p80:<span class="hljs-number">5.97</span>s, p95:<span class="hljs-number">5.97</span>s, iters:<span class="hljs-number">5</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:tpch_100.orders.o_orderpriority, funcs:<span class="hljs-built_in">sum</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">32</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">27</span>, funcs:firstrow(tpch_100.orders.o_orderpriority)<span class="hljs-operator">-</span><span class="hljs-operator">></span>tpch_100.orders.o_orderpriority, stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeReceiver_57 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">15</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">5.97</span>s, min:<span class="hljs-number">5.96</span>s, avg: <span class="hljs-number">5.97</span>s, p80:<span class="hljs-number">5.97</span>s, p95:<span class="hljs-number">5.97</span>s, iters:<span class="hljs-number">5</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_56 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">15</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">5.96</span>s, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">1.99</span>s, p80:<span class="hljs-number">5.96</span>s, p95:<span class="hljs-number">5.96</span>s, iters:<span class="hljs-number">768</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: tpch_100.orders.o_orderpriority, <span class="hljs-keyword">collate</span>: utf8mb4_bin], stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_52 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">15</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">5.96</span>s, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">1.99</span>s, p80:<span class="hljs-number">5.96</span>s, p95:<span class="hljs-number">5.96</span>s, iters:<span class="hljs-number">768</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:tpch_100.orders.o_orderpriority, funcs:<span class="hljs-built_in">count</span>(<span class="hljs-number">1</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">32</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashJoin_41 <span class="hljs-operator">|</span> <span class="hljs-number">4429262.13</span> <span class="hljs-operator">|</span> <span class="hljs-number">5145138</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">5.95</span>s, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">1.98</span>s, p80:<span class="hljs-number">5.95</span>s, p95:<span class="hljs-number">5.95</span>s, iters:<span class="hljs-number">118</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> semi <span class="hljs-keyword">join</span>, equal:[eq(tpch_100.orders.o_orderkey, tpch_100.lineitem.l_orderkey)], stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> ├─ExchangeReceiver_26(Build) <span class="hljs-operator">|</span> <span class="hljs-number">480030321.60</span> <span class="hljs-operator">|</span> <span class="hljs-number">379356474</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">3.26</span>s, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">1.09</span>s, p80:<span class="hljs-number">3.26</span>s, p95:<span class="hljs-number">3.26</span>s, iters:<span class="hljs-number">42469</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─ExchangeSender_25 <span class="hljs-operator">|</span> <span class="hljs-number">480030321.60</span> <span class="hljs-operator">|</span> <span class="hljs-number">379356474</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">3.37</span>s, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">1.12</span>s, p80:<span class="hljs-number">3.37</span>s, p95:<span class="hljs-number">3.37</span>s, iters:<span class="hljs-number">9292</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: tpch_100.lineitem.l_orderkey, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>], stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─Projection_60 <span class="hljs-operator">|</span> <span class="hljs-number">480030321.60</span> <span class="hljs-operator">|</span> <span class="hljs-number">379356474</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">819.1</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">273</span>ms, p80:<span class="hljs-number">819.1</span>ms, p95:<span class="hljs-number">819.1</span>ms, iters:<span class="hljs-number">9292</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> tpch_100.lineitem.l_orderkey <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─Selection_24 <span class="hljs-operator">|</span> <span class="hljs-number">480030321.60</span> <span class="hljs-operator">|</span> <span class="hljs-number">379356474</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">817.1</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">272.4</span>ms, p80:<span class="hljs-number">817.1</span>ms, p95:<span class="hljs-number">817.1</span>ms, iters:<span class="hljs-number">9292</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> lt(tpch_100.lineitem.l_commitdate, tpch_100.lineitem.l_receiptdate) <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─TableFullScan_23 <span class="hljs-operator">|</span> <span class="hljs-number">600037902.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600037902</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:lineitem <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">328.1</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">109.4</span>ms, p80:<span class="hljs-number">328.1</span>ms, p95:<span class="hljs-number">328.1</span>ms, iters:<span class="hljs-number">9292</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">73475</span>, total_skipped_packs:<span class="hljs-number">13452</span>, total_scanned_rows:<span class="hljs-number">600230532</span>, total_skipped_rows:<span class="hljs-number">109887612</span>, total_rs_index_load_time: <span class="hljs-number">35</span>ms, total_read_time: <span class="hljs-number">34065</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeReceiver_22(Probe) <span class="hljs-operator">|</span> <span class="hljs-number">5536577.67</span> <span class="hljs-operator">|</span> <span class="hljs-number">5610951</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2.5</span>s, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">833.7</span>ms, p80:<span class="hljs-number">2.5</span>s, p95:<span class="hljs-number">2.5</span>s, iters:<span class="hljs-number">669</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_21 <span class="hljs-operator">|</span> <span class="hljs-number">5536577.67</span> <span class="hljs-operator">|</span> <span class="hljs-number">5610951</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">5.93</span>s, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">1.98</span>s, p80:<span class="hljs-number">5.93</span>s, p95:<span class="hljs-number">5.93</span>s, iters:<span class="hljs-number">2336</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: tpch_100.orders.o_orderkey, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>] <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Selection_20 <span class="hljs-operator">|</span> <span class="hljs-number">5536577.67</span> <span class="hljs-operator">|</span> <span class="hljs-number">5610951</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">325.5</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">108.5</span>ms, p80:<span class="hljs-number">325.5</span>ms, p95:<span class="hljs-number">325.5</span>ms, iters:<span class="hljs-number">2336</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ge(tpch_100.orders.o_orderdate, <span class="hljs-number">1995</span><span class="hljs-number">-01</span><span class="hljs-number">-01</span> <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00.000000</span>), lt(tpch_100.orders.o_orderdate, <span class="hljs-number">1995</span><span class="hljs-number">-04</span><span class="hljs-number">-01</span> <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00.000000</span>) <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableFullScan_19 <span class="hljs-operator">|</span> <span class="hljs-number">150000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">150000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:orders <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">238.5</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">79.5</span>ms, p80:<span class="hljs-number">238.5</span>ms, p95:<span class="hljs-number">238.5</span>ms, iters:<span class="hljs-number">2336</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">18541</span>, total_skipped_packs:<span class="hljs-number">186</span>, total_scanned_rows:<span class="hljs-number">150000611</span>, total_skipped_rows:<span class="hljs-number">1513328</span>, total_rs_index_load_time: <span class="hljs-number">75</span>ms, total_read_time: <span class="hljs-number">11454</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------------------+--------------+-----------+--------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-number">18</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span> (<span class="hljs-number">6.00</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><h3 id="聚合下推-join-或-union" style="position:relative">聚合下推 <code>Join</code> 或 <code>Union</code><a href="#%E8%81%9A%E5%90%88%E4%B8%8B%E6%8E%A8-join-%E6%88%96-union" aria-label="聚合下推 join 或 union permalink" class="anchor after"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a></h3><p>将聚合操作下推到 <code>Join</code> 或 <code>Union</code> 之前执行,有可能能显著减少 <code>Join</code> 或 <code>Union</code> 需要处理的数据量,从而提升性能。</p><p><a href="/zh/tidb/stable/system-variables#tidb_opt_agg_push_down"><code>tidb_opt_agg_push_down</code></a> 变量用来设置优化器是否执行聚合函数下推到 Join 之前的优化操作。当查询中聚合操作执行很慢时,可以尝试设置该变量为 <code>ON</code>。</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia"><span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_opt_agg_push_down <span class="hljs-operator">=</span> <span class="hljs-keyword">ON</span>; </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>在以下示例中,<code>tidb_opt_agg_push_down</code> 开启前,<code>HashAgg_58</code> 在 <code>HashJoin_41</code> 之后执行。<code>tidb_opt_agg_push_down</code> 开启后,新生成的 <code>HashAgg_21</code> 和 <code>HashAgg_32</code> 在 <code>HashJoin_76</code> 之前执行,显著减少了 <code>Join</code> 需要处理的数据量。</p><p><code>tidb_opt_agg_push_down</code> 开启前:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> <span class="hljs-built_in">count</span>(<span class="hljs-operator">*</span>) <span class="hljs-keyword">from</span> t1 <span class="hljs-keyword">join</span> t2 <span class="hljs-keyword">where</span> t1.a <span class="hljs-operator">=</span> t2.b <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span> t1.a; <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------+--------------+-----------+--------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------+--------------+-----------+--------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> TableReader_66 <span class="hljs-operator">|</span> <span class="hljs-number">100450000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">2.13</span>s, loops:<span class="hljs-number">2</span>, cop_task: {num: <span class="hljs-number">21</span>, max: <span class="hljs-number">0</span>s, min: <span class="hljs-number">0</span>s, avg: <span class="hljs-number">0</span>s, p95: <span class="hljs-number">0</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>} <span class="hljs-operator">|</span> data:ExchangeSender_65 <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_65 <span class="hljs-operator">|</span> <span class="hljs-number">100450000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2.13</span>s, min:<span class="hljs-number">2.08</span>s, avg: <span class="hljs-number">2.11</span>s, p80:<span class="hljs-number">2.13</span>s, p95:<span class="hljs-number">2.13</span>s, iters:<span class="hljs-number">768</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: PassThrough <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Projection_60 <span class="hljs-operator">|</span> <span class="hljs-number">100450000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2.13</span>s, min:<span class="hljs-number">2.08</span>s, avg: <span class="hljs-number">2.11</span>s, p80:<span class="hljs-number">2.13</span>s, p95:<span class="hljs-number">2.13</span>s, iters:<span class="hljs-number">768</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">Column</span>#<span class="hljs-number">43</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_58 <span class="hljs-operator">|</span> <span class="hljs-number">100450000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2.13</span>s, min:<span class="hljs-number">2.08</span>s, avg: <span class="hljs-number">2.11</span>s, p80:<span class="hljs-number">2.13</span>s, p95:<span class="hljs-number">2.13</span>s, iters:<span class="hljs-number">768</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:test.t1.a, funcs:<span class="hljs-built_in">count</span>(<span class="hljs-number">1</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">43</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashJoin_41 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">1.77</span>s, min:<span class="hljs-number">1.67</span>s, avg: <span class="hljs-number">1.73</span>s, p80:<span class="hljs-number">1.77</span>s, p95:<span class="hljs-number">1.77</span>s, iters:<span class="hljs-number">10955</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">inner</span> <span class="hljs-keyword">join</span>, equal:[eq(test.t1.a, test.t2.b)], stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> ├─ExchangeReceiver_22(Build) <span class="hljs-operator">|</span> <span class="hljs-number">100450000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">99980000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">171</span>ms, min:<span class="hljs-number">127</span>ms, avg: <span class="hljs-number">154.5</span>ms, p80:<span class="hljs-number">171</span>ms, p95:<span class="hljs-number">171</span>ms, iters:<span class="hljs-number">10440</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─ExchangeSender_21 <span class="hljs-operator">|</span> <span class="hljs-number">100450000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">99980000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">498.7</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">166.2</span>ms, p80:<span class="hljs-number">498.7</span>ms, p95:<span class="hljs-number">498.7</span>ms, iters:<span class="hljs-number">1653</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: test.t1.a, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>], stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─Selection_20 <span class="hljs-operator">|</span> <span class="hljs-number">100450000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">99980000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">83.7</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">27.9</span>ms, p80:<span class="hljs-number">83.7</span>ms, p95:<span class="hljs-number">83.7</span>ms, iters:<span class="hljs-number">1653</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">not</span>(isnull(test.t1.a)) <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─TableFullScan_19 <span class="hljs-operator">|</span> <span class="hljs-number">100450000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">99980000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:t1 <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">41.7</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">13.9</span>ms, p80:<span class="hljs-number">41.7</span>ms, p95:<span class="hljs-number">41.7</span>ms, iters:<span class="hljs-number">1653</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">12336</span>, total_skipped_packs:<span class="hljs-number">5759</span>, total_scanned_rows:<span class="hljs-number">100083566</span>, total_skipped_rows:<span class="hljs-number">46786721</span>, total_rs_index_load_time: <span class="hljs-number">5</span>ms, total_read_time: <span class="hljs-number">1105</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeReceiver_26(Probe) <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">373</span>ms, min:<span class="hljs-number">71</span>ms, avg: <span class="hljs-number">253.2</span>ms, p80:<span class="hljs-number">373</span>ms, p95:<span class="hljs-number">373</span>ms, iters:<span class="hljs-number">28135</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_25 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2.07</span>s, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">689.6</span>ms, p80:<span class="hljs-number">2.07</span>s, p95:<span class="hljs-number">2.07</span>s, iters:<span class="hljs-number">9388</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: test.t2.b, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>] <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Selection_24 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">146.9</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">49</span>ms, p80:<span class="hljs-number">146.9</span>ms, p95:<span class="hljs-number">146.9</span>ms, iters:<span class="hljs-number">9388</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">not</span>(isnull(test.t2.b)) <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableFullScan_23 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:t2 <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">63.8</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">21.3</span>ms, p80:<span class="hljs-number">63.8</span>ms, p95:<span class="hljs-number">63.8</span>ms, iters:<span class="hljs-number">9388</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">73834</span>, total_skipped_packs:<span class="hljs-number">439</span>, total_scanned_rows:<span class="hljs-number">600007458</span>, total_skipped_rows:<span class="hljs-number">3553131</span>, total_rs_index_load_time: <span class="hljs-number">12</span>ms, total_read_time: <span class="hljs-number">270</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------+--------------+-----------+--------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-number">13</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span> (<span class="hljs-number">2.15</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>开启 <code>tidb_opt_agg_push_down</code>:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> <span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_opt_agg_push_down <span class="hljs-operator">=</span> <span class="hljs-keyword">ON</span>; Query OK, <span class="hljs-number">0</span> <span class="hljs-keyword">rows</span> affected (<span class="hljs-number">0.00</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>开启 <code>tidb_opt_agg_push_down</code> 后:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> <span class="hljs-built_in">count</span>(<span class="hljs-operator">*</span>) <span class="hljs-keyword">from</span> t1 <span class="hljs-keyword">join</span> t2 <span class="hljs-keyword">where</span> t1.a <span class="hljs-operator">=</span> t2.b <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span> t1.a; <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------------------+--------------+-----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------------------+--------------+-----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> TableReader_85 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">432.4</span>ms, loops:<span class="hljs-number">2</span>, cop_task: {num: <span class="hljs-number">19</span>, max: <span class="hljs-number">0</span>s, min: <span class="hljs-number">0</span>s, avg: <span class="hljs-number">0</span>s, p95: <span class="hljs-number">0</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>} <span class="hljs-operator">|</span> data:ExchangeSender_84 <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_84 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">431.1</span>ms, min:<span class="hljs-number">429.3</span>ms, avg: <span class="hljs-number">430.4</span>ms, p80:<span class="hljs-number">431.1</span>ms, p95:<span class="hljs-number">431.1</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: PassThrough <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Projection_83 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">430.1</span>ms, min:<span class="hljs-number">429.3</span>ms, avg: <span class="hljs-number">429.7</span>ms, p80:<span class="hljs-number">430.1</span>ms, p95:<span class="hljs-number">430.1</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">Column</span>#<span class="hljs-number">43</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_82 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">430.1</span>ms, min:<span class="hljs-number">429.3</span>ms, avg: <span class="hljs-number">429.7</span>ms, p80:<span class="hljs-number">430.1</span>ms, p95:<span class="hljs-number">430.1</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:test.t1.a, funcs:<span class="hljs-built_in">count</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">44</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">43</span>, stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeReceiver_78 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">430.1</span>ms, min:<span class="hljs-number">429.3</span>ms, avg: <span class="hljs-number">429.7</span>ms, p80:<span class="hljs-number">430.1</span>ms, p95:<span class="hljs-number">430.1</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_77 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">427</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">142.3</span>ms, p80:<span class="hljs-number">427</span>ms, p95:<span class="hljs-number">427</span>ms, iters:<span class="hljs-number">60</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: test.t1.a, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>], stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashJoin_76 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">426</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">142</span>ms, p80:<span class="hljs-number">426</span>ms, p95:<span class="hljs-number">426</span>ms, iters:<span class="hljs-number">60</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">inner</span> <span class="hljs-keyword">join</span>, equal:[eq(test.t1.a, test.t2.b)] <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> ├─ExchangeReceiver_36(Build) <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">60</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">374</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">124.7</span>ms, p80:<span class="hljs-number">374</span>ms, p95:<span class="hljs-number">374</span>ms, iters:<span class="hljs-number">46</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─ExchangeSender_35 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">373.7</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">124.6</span>ms, p80:<span class="hljs-number">373.7</span>ms, p95:<span class="hljs-number">373.7</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: Broadcast <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─Projection_31 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">373.7</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">124.6</span>ms, p80:<span class="hljs-number">373.7</span>ms, p95:<span class="hljs-number">373.7</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">Column</span>#<span class="hljs-number">44</span>, test.t2.b <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─HashAgg_32 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">373.7</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">124.6</span>ms, p80:<span class="hljs-number">373.7</span>ms, p95:<span class="hljs-number">373.7</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:test.t2.b, funcs:<span class="hljs-built_in">sum</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">45</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">44</span>, funcs:firstrow(test.t2.b)<span class="hljs-operator">-</span><span class="hljs-operator">></span>test.t2.b, stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─ExchangeReceiver_34 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">60</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">373.7</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">124.6</span>ms, p80:<span class="hljs-number">373.7</span>ms, p95:<span class="hljs-number">373.7</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─ExchangeSender_33 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">60</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">368.3</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">122.8</span>ms, p80:<span class="hljs-number">368.3</span>ms, p95:<span class="hljs-number">368.3</span>ms, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: test.t2.b, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>], stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─HashAgg_21 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">60</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">367.3</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">122.4</span>ms, p80:<span class="hljs-number">367.3</span>ms, p95:<span class="hljs-number">367.3</span>ms, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:test.t2.b, funcs:<span class="hljs-built_in">count</span>(<span class="hljs-number">1</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">45</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─Selection_30 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">77.2</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">25.7</span>ms, p80:<span class="hljs-number">77.2</span>ms, p95:<span class="hljs-number">77.2</span>ms, iters:<span class="hljs-number">9389</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">not</span>(isnull(test.t2.b)) <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─TableFullScan_29 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:t2 <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">37.2</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">12.4</span>ms, p80:<span class="hljs-number">37.2</span>ms, p95:<span class="hljs-number">37.2</span>ms, iters:<span class="hljs-number">9389</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">73834</span>, total_skipped_packs:<span class="hljs-number">412</span>, total_scanned_rows:<span class="hljs-number">600002896</span>, total_skipped_rows:<span class="hljs-number">3342145</span>, total_rs_index_load_time: <span class="hljs-number">0</span>ms, total_read_time: <span class="hljs-number">45</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Selection_19(Probe) <span class="hljs-operator">|</span> <span class="hljs-number">100450000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">99980000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">30</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">10</span>ms, p80:<span class="hljs-number">30</span>ms, p95:<span class="hljs-number">30</span>ms, iters:<span class="hljs-number">1645</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">not</span>(isnull(test.t1.a)) <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableFullScan_18 <span class="hljs-operator">|</span> <span class="hljs-number">100450000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">99980000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:t1 <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">22</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">7.34</span>ms, p80:<span class="hljs-number">22</span>ms, p95:<span class="hljs-number">22</span>ms, iters:<span class="hljs-number">1645</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">12326</span>, total_skipped_packs:<span class="hljs-number">4762</span>, total_scanned_rows:<span class="hljs-number">100045535</span>, total_skipped_rows:<span class="hljs-number">38651216</span>, total_rs_index_load_time: <span class="hljs-number">4</span>ms, total_read_time: <span class="hljs-number">355</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------------------+--------------+-----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-number">18</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span> (<span class="hljs-number">0.46</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><h3 id="开启-distinct-优化" style="position:relative">开启 <code>Distinct</code> 优化<a href="#%E5%BC%80%E5%90%AF-distinct-%E4%BC%98%E5%8C%96" aria-label="开启 distinct 优化 permalink" class="anchor after"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a></h3><p>TiFlash 暂时还不支持部分可接受 <code>Distinct</code> 列的聚合函数,比如 <code>Sum</code> 。默认情况下,整个聚合函数运算都会在 TiDB 端执行。通过开启 <code>Distinct</code> 优化,部分操作可以下推到 TiFlash,从而提升查询性能:</p><p><a href="/zh/tidb/stable/system-variables#tidb_opt_distinct_agg_push_down"><code>tidb_opt_distinct_agg_push_down</code></a> 变量用来设置优化器是否执行带有 <code>Distinct</code> 的聚合函数(比如 <code>select sum(distinct a) from t</code>)下推到 Coprocessor 的优化操作。当查询中带有 <code>Distinct</code> 的聚合操作执行很慢时,可以尝试设置该变量为 <code>ON</code>。</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia"><span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_opt_distinct_agg_push_down <span class="hljs-operator">=</span> <span class="hljs-keyword">ON</span>; </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>在以下示例中,<code>tidb_opt_distinct_agg_push_down</code> 开启前,TiDB 需要从 TiFlash 读取所有数据,并在 TiDB 侧执行 <code>distinct</code>。<code>tidb_opt_distinct_agg_push_down</code> 开启后,<code>distinct a</code> 被下推到了 TiFlash,在 <code>HashAgg_6</code> 里新增里一个 <code>group by</code> 列 <code>test.t.a</code>。这边查询结果里面的两个 warnings 是警告聚合函数不能完全下推。</p><p><code>tidb_opt_distinct_agg_push_down</code> 开启前:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> <span class="hljs-built_in">count</span>(<span class="hljs-keyword">distinct</span> a) <span class="hljs-keyword">from</span> test.t; <span class="hljs-operator">+</span><span class="hljs-comment">----------------------------+--------------+-----------+--------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------+----------+---------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">----------------------------+--------------+-----------+--------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------+----------+---------+</span> <span class="hljs-operator">|</span> HashAgg_6 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">1</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">2</span>m23<span class="hljs-number">.2</span>s, loops:<span class="hljs-number">2</span> <span class="hljs-operator">|</span> funcs:<span class="hljs-built_in">sum</span>(<span class="hljs-keyword">distinct</span> <span class="hljs-keyword">Column</span>#<span class="hljs-number">23</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">22</span> <span class="hljs-operator">|</span> <span class="hljs-number">41.3</span> KB <span class="hljs-operator">|</span> <span class="hljs-number">0</span> Bytes <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Projection_16 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">2.51</span>s, loops:<span class="hljs-number">586548</span>, Concurrency:<span class="hljs-number">5</span> <span class="hljs-operator">|</span> <span class="hljs-built_in">cast</span>(test.t.a, <span class="hljs-type">decimal</span>(<span class="hljs-number">10</span>,<span class="hljs-number">0</span>) <span class="hljs-type">BINARY</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">23</span> <span class="hljs-operator">|</span> <span class="hljs-number">243.2</span> KB <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableReader_11 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">1.6</span>s, loops:<span class="hljs-number">586548</span>, cop_task: {num: <span class="hljs-number">1173</span>, max: <span class="hljs-number">256.2</span>ms, min: <span class="hljs-number">25.1</span>ms, avg: <span class="hljs-number">46.9</span>ms, p95: <span class="hljs-number">63.5</span>ms, rpc_num: <span class="hljs-number">1173</span>, rpc_time: <span class="hljs-number">55</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>, distsql_concurrency: <span class="hljs-number">15</span>} <span class="hljs-operator">|</span> data:TableFullScan_10 <span class="hljs-operator">|</span> <span class="hljs-number">70.2</span> MB <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableFullScan_10 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> cop[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:t <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">9</span>ms, min:<span class="hljs-number">531</span>µs, avg: <span class="hljs-number">4.49</span>ms, p80:<span class="hljs-number">5.55</span>ms, p95:<span class="hljs-number">6.74</span>ms, iters:<span class="hljs-number">9390</span>, tasks:<span class="hljs-number">1173</span>, threads:<span class="hljs-number">1173</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">73834</span>, total_skipped_packs:<span class="hljs-number">1231</span>, total_scanned_rows:<span class="hljs-number">600010914</span>, total_skipped_rows:<span class="hljs-number">9988978</span>, total_rs_index_load_time: <span class="hljs-number">0</span>ms, total_read_time: <span class="hljs-number">16</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">----------------------------+--------------+-----------+--------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------+----------+---------+</span> <span class="hljs-number">4</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span>, <span class="hljs-number">2</span> warnings (<span class="hljs-number">2</span> min <span class="hljs-number">23.21</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>开启 <code>tidb_opt_distinct_agg_push_down</code>:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> <span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_opt_distinct_agg_push_down <span class="hljs-operator">=</span> <span class="hljs-keyword">ON</span>; Query OK, <span class="hljs-number">0</span> <span class="hljs-keyword">rows</span> affected (<span class="hljs-number">0.00</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p><code>tidb_opt_distinct_agg_push_down</code> 开启后:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> <span class="hljs-built_in">count</span>(<span class="hljs-keyword">distinct</span> a) <span class="hljs-keyword">from</span> test.t; <span class="hljs-operator">+</span><span class="hljs-comment">-----------------------------+--------------+-----------+-------------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------+-----------+---------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">-----------------------------+--------------+-----------+-------------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------+-----------+---------+</span> <span class="hljs-operator">|</span> HashAgg_10 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">1</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">233.8</span>ms, loops:<span class="hljs-number">2</span> <span class="hljs-operator">|</span> funcs:<span class="hljs-built_in">sum</span>(<span class="hljs-keyword">distinct</span> <span class="hljs-keyword">Column</span>#<span class="hljs-number">23</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">22</span> <span class="hljs-operator">|</span> <span class="hljs-number">2.42</span> KB <span class="hljs-operator">|</span> <span class="hljs-number">0</span> Bytes <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Projection_12 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">3</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">233.7</span>ms, loops:<span class="hljs-number">2</span>, Concurrency:OFF <span class="hljs-operator">|</span> <span class="hljs-built_in">cast</span>(test.c.a, <span class="hljs-type">decimal</span>(<span class="hljs-number">10</span>,<span class="hljs-number">0</span>) <span class="hljs-type">BINARY</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">23</span> <span class="hljs-operator">|</span> <span class="hljs-number">380</span> Bytes <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableReader_11 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">3</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">233.7</span>ms, loops:<span class="hljs-number">2</span>, cop_task: {num: <span class="hljs-number">6</span>, max: <span class="hljs-number">0</span>s, min: <span class="hljs-number">0</span>s, avg: <span class="hljs-number">0</span>s, p95: <span class="hljs-number">0</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>, distsql_concurrency: <span class="hljs-number">15</span>} <span class="hljs-operator">|</span> data:HashAgg_6 <span class="hljs-operator">|</span> <span class="hljs-number">100</span> Bytes <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_6 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">3</span> <span class="hljs-operator">|</span> batchCop[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">225.8</span>ms, min:<span class="hljs-number">210.7</span>ms, avg: <span class="hljs-number">216.9</span>ms, p80:<span class="hljs-number">225.8</span>ms, p95:<span class="hljs-number">225.8</span>ms, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:test.t.a, <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableFullScan_9 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> batchCop[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:t <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">50.3</span>ms, min:<span class="hljs-number">33.7</span>ms, avg: <span class="hljs-number">44.6</span>ms, p80:<span class="hljs-number">50.3</span>ms, p95:<span class="hljs-number">50.3</span>ms, iters:<span class="hljs-number">9387</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">73833</span>, total_skipped_packs:<span class="hljs-number">475</span>, total_scanned_rows:<span class="hljs-number">600000000</span>, total_skipped_rows:<span class="hljs-number">3852098</span>, total_rs_index_load_time: <span class="hljs-number">0</span>ms, total_read_time: <span class="hljs-number">84</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">-----------------------------+--------------+-----------+-------------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------+-----------+---------+</span> <span class="hljs-number">5</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span>, <span class="hljs-number">2</span> warnings (<span class="hljs-number">0.24</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><h3 id="使用-alter-tablecompact-整理数据" style="position:relative">使用 <code>ALTER TABLE...COMPACT</code> 整理数据<a href="#%E4%BD%BF%E7%94%A8-alter-tablecompact-%E6%95%B4%E7%90%86%E6%95%B0%E6%8D%AE" aria-label="使用 alter tablecompact 整理数据 permalink" class="anchor after"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a></h3><p><a href="/zh/tidb/stable/sql-statement-alter-table-compact"><code>ALTER TABLE ... COMPACT</code></a> 可以触发 TiFlash 节点对某个表或者某个分区进行数据整理。数据整理时,表中的物理数据会被重写,如清理已删除的数据、合并多版本数据等,从而可以获得更高的访问性能,并减少磁盘空间占用。</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> employees COMPACT TIFLASH REPLICA; </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> employees COMPACT <span class="hljs-keyword">PARTITION</span> pNorth, pEast TIFLASH REPLICA; </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><h3 id="使用-broadcast-hash-join-代替-shuffled-hash-join" style="position:relative">使用 Broadcast Hash Join 代替 Shuffled Hash Join<a href="#%E4%BD%BF%E7%94%A8-broadcast-hash-join-%E4%BB%A3%E6%9B%BF-shuffled-hash-join" aria-label="使用 broadcast hash join 代替 shuffled hash join permalink" class="anchor after"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a></h3><p>对于有小表的 <code>Join</code> 算子,Broadcast Hash Join 可以避免大表的网络传输,从而提升计算性能。</p><ul><li><p><a href="/zh/tidb/stable/system-variables#tidb_broadcast_join_threshold_count-从-v50-版本开始引入"><code>tidb_broadcast_join_threshold_size</code></a>,单位为 bytes。如果表大小(字节数)小于该值,则选择 Broadcast Hash Join 算法。否则选择 Shuffled Hash Join 算法。</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia"><span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_broadcast_join_threshold_size <span class="hljs-operator">=</span> <span class="hljs-number">2000000</span>; </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre></li><li><p><a href="/zh/tidb/stable/system-variables#tidb_broadcast_join_threshold_count-从-v50-版本开始引入"><code>tidb_broadcast_join_threshold_count</code></a>,单位为行数。如果 join 的对象为子查询,优化器无法估计子查询结果集大小,在这种情况下通过结果集行数判断。如果子查询的行数估计值小于该变量,则选择 Broadcast Hash Join 算法。否则选择 Shuffled Hash Join 算法。</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia"><span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_broadcast_join_threshold_count <span class="hljs-operator">=</span> <span class="hljs-number">100000</span>; </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre></li></ul><p>在以下示例中,<code>tidb_broadcast_join_threshold_size</code> 设置前,<code>ExchangeSender_29</code> 的 <code>ExchangeType</code> 是 <code>HashPartition</code>。<code>tidb_broadcast_join_threshold_size</code> 设置后,<code>ExchangeSender_29</code> 的 <code>ExchangeType</code> 改变为 <code>Broadcast</code>。</p><p><code>tidb_broadcast_join_threshold_size</code> 设置前:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> <span class="hljs-built_in">max</span>(l_shipdate), <span class="hljs-built_in">max</span>(l_commitdate), <span class="hljs-built_in">max</span>(l_receiptdate) <span class="hljs-keyword">from</span> supplier,lineitem <span class="hljs-keyword">where</span> s_suppkey <span class="hljs-operator">=</span> l_suppkey; <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------+--------------+-----------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------+--------------+-----------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+------+</span> <span class="hljs-operator">|</span> HashAgg_45 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">1</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">3.8</span>s, loops:<span class="hljs-number">2</span>, partial_worker:{wall_time:<span class="hljs-number">3.798284809</span>s, concurrency:<span class="hljs-number">5</span>, task_num:<span class="hljs-number">1</span>, tot_wait:<span class="hljs-number">18.99079929</span>s, tot_exec:<span class="hljs-number">8.193</span>µs, tot_time:<span class="hljs-number">18.990819019</span>s, max:<span class="hljs-number">3.798181723</span>s, p95:<span class="hljs-number">3.798181723</span>s}, final_worker:{wall_time:<span class="hljs-number">0</span>s, concurrency:<span class="hljs-number">5</span>, task_num:<span class="hljs-number">1</span>, tot_wait:<span class="hljs-number">18.991291379</span>s, tot_exec:<span class="hljs-number">197.45</span>µs, tot_time:<span class="hljs-number">18.991494363</span>s, max:<span class="hljs-number">3.798334972</span>s, p95:<span class="hljs-number">3.798334972</span>s} <span class="hljs-operator">|</span> funcs:<span class="hljs-built_in">max</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">28</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">25</span>, funcs:<span class="hljs-built_in">max</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">29</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">26</span>, funcs:<span class="hljs-built_in">max</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">30</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">27</span> <span class="hljs-operator">|</span> <span class="hljs-number">17.3</span> KB <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableReader_47 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">3</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">3.8</span>s, loops:<span class="hljs-number">2</span>, cop_task: {num: <span class="hljs-number">6</span>, max: <span class="hljs-number">0</span>s, min: <span class="hljs-number">0</span>s, avg: <span class="hljs-number">0</span>s, p95: <span class="hljs-number">0</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>} <span class="hljs-operator">|</span> data:ExchangeSender_46 <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_46 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">3</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">3.79</span>s, min:<span class="hljs-number">3.78</span>s, avg: <span class="hljs-number">3.78</span>s, p80:<span class="hljs-number">3.79</span>s, p95:<span class="hljs-number">3.79</span>s, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: PassThrough <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_13 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">3</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">3.79</span>s, min:<span class="hljs-number">3.78</span>s, avg: <span class="hljs-number">3.78</span>s, p80:<span class="hljs-number">3.79</span>s, p95:<span class="hljs-number">3.79</span>s, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> funcs:<span class="hljs-built_in">max</span>(tpch_100.lineitem.l_shipdate)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">28</span>, funcs:<span class="hljs-built_in">max</span>(tpch_100.lineitem.l_commitdate)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">29</span>, funcs:<span class="hljs-built_in">max</span>(tpch_100.lineitem.l_receiptdate)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">30</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashJoin_44 <span class="hljs-operator">|</span> <span class="hljs-number">600845438.27</span> <span class="hljs-operator">|</span> <span class="hljs-number">600037902</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">3.17</span>s, min:<span class="hljs-number">3.12</span>s, avg: <span class="hljs-number">3.14</span>s, p80:<span class="hljs-number">3.17</span>s, p95:<span class="hljs-number">3.17</span>s, iters:<span class="hljs-number">11143</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">inner</span> <span class="hljs-keyword">join</span>, equal:[eq(tpch_100.supplier.s_suppkey, tpch_100.lineitem.l_suppkey)], stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> ├─ExchangeReceiver_30(Build) <span class="hljs-operator">|</span> <span class="hljs-number">1000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">1000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">23.3</span>ms, min:<span class="hljs-number">21</span>ms, avg: <span class="hljs-number">22.5</span>ms, p80:<span class="hljs-number">23.3</span>ms, p95:<span class="hljs-number">23.3</span>ms, iters:<span class="hljs-number">120</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─ExchangeSender_29 <span class="hljs-operator">|</span> <span class="hljs-number">1000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">1000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">22.7</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">7.57</span>ms, p80:<span class="hljs-number">22.7</span>ms, p95:<span class="hljs-number">22.7</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">2</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: tpch_100.supplier.s_suppkey, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>], stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─TableFullScan_28 <span class="hljs-operator">|</span> <span class="hljs-number">1000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">1000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:supplier <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">9.71</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">3.24</span>ms, p80:<span class="hljs-number">9.71</span>ms, p95:<span class="hljs-number">9.71</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">2</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">123</span>, total_skipped_packs:<span class="hljs-number">0</span>, total_scanned_rows:<span class="hljs-number">1000000</span>, total_skipped_rows:<span class="hljs-number">0</span>, total_rs_index_load_time: <span class="hljs-number">0</span>ms, total_read_time: <span class="hljs-number">2</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeReceiver_33(Probe) <span class="hljs-operator">|</span> <span class="hljs-number">600037902.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600037902</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">564.3</span>ms, min:<span class="hljs-number">340</span>ms, avg: <span class="hljs-number">438.5</span>ms, p80:<span class="hljs-number">564.3</span>ms, p95:<span class="hljs-number">564.3</span>ms, iters:<span class="hljs-number">27583</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_32 <span class="hljs-operator">|</span> <span class="hljs-number">600037902.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600037902</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">3.69</span>s, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">1.23</span>s, p80:<span class="hljs-number">3.69</span>s, p95:<span class="hljs-number">3.69</span>s, iters:<span class="hljs-number">9298</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: tpch_100.lineitem.l_suppkey, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>] <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableFullScan_31 <span class="hljs-operator">|</span> <span class="hljs-number">600037902.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600037902</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:lineitem <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">62.8</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">20.9</span>ms, p80:<span class="hljs-number">62.8</span>ms, p95:<span class="hljs-number">62.8</span>ms, iters:<span class="hljs-number">9298</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">73465</span>, total_skipped_packs:<span class="hljs-number">13060</span>, total_scanned_rows:<span class="hljs-number">600168663</span>, total_skipped_rows:<span class="hljs-number">106699256</span>, total_rs_index_load_time: <span class="hljs-number">16</span>ms, total_read_time: <span class="hljs-number">27979</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------+--------------+-----------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+------+</span> <span class="hljs-number">11</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span> (<span class="hljs-number">3.83</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>设置 <code>tidb_broadcast_join_threshold_size</code>:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> <span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_broadcast_join_threshold_size <span class="hljs-operator">=</span> <span class="hljs-number">10000000</span>; Query OK, <span class="hljs-number">0</span> <span class="hljs-keyword">rows</span> affected (<span class="hljs-number">0.00</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p><code>tidb_broadcast_join_threshold_size</code> 设置后:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> <span class="hljs-built_in">max</span>(l_shipdate), <span class="hljs-built_in">max</span>(l_commitdate), <span class="hljs-built_in">max</span>(l_receiptdate) <span class="hljs-keyword">from</span> supplier,lineitem <span class="hljs-keyword">where</span> s_suppkey <span class="hljs-operator">=</span> l_suppkey; <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------+--------------+-----------+--------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------+--------------+-----------+--------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+------+</span> <span class="hljs-operator">|</span> HashAgg_43 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">1</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">2.75</span>s, loops:<span class="hljs-number">2</span>, partial_worker:{wall_time:<span class="hljs-number">2.748445779</span>s, concurrency:<span class="hljs-number">5</span>, task_num:<span class="hljs-number">1</span>, tot_wait:<span class="hljs-number">13.74202679</span>s, tot_exec:<span class="hljs-number">8.012</span>µs, tot_time:<span class="hljs-number">13.742045721</span>s, max:<span class="hljs-number">2.748414915</span>s, p95:<span class="hljs-number">2.748414915</span>s}, final_worker:{wall_time:<span class="hljs-number">2.74848039</span>s, concurrency:<span class="hljs-number">5</span>, task_num:<span class="hljs-number">1</span>, tot_wait:<span class="hljs-number">13.742157526</span>s, tot_exec:<span class="hljs-number">53.191</span>µs, tot_time:<span class="hljs-number">13.742214417</span>s, max:<span class="hljs-number">2.748462393</span>s, p95:<span class="hljs-number">2.748462393</span>s} <span class="hljs-operator">|</span> funcs:<span class="hljs-built_in">max</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">28</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">25</span>, funcs:<span class="hljs-built_in">max</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">29</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">26</span>, funcs:<span class="hljs-built_in">max</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">30</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">27</span> <span class="hljs-operator">|</span> <span class="hljs-number">17.3</span> KB <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableReader_45 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">3</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">2.75</span>s, loops:<span class="hljs-number">2</span>, cop_task: {num: <span class="hljs-number">6</span>, max: <span class="hljs-number">0</span>s, min: <span class="hljs-number">0</span>s, avg: <span class="hljs-number">0</span>s, p95: <span class="hljs-number">0</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>} <span class="hljs-operator">|</span> data:ExchangeSender_44 <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_44 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">3</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2.74</span>s, min:<span class="hljs-number">2.65</span>s, avg: <span class="hljs-number">2.7</span>s, p80:<span class="hljs-number">2.74</span>s, p95:<span class="hljs-number">2.74</span>s, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: PassThrough <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_13 <span class="hljs-operator">|</span> <span class="hljs-number">1.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">3</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2.74</span>s, min:<span class="hljs-number">2.65</span>s, avg: <span class="hljs-number">2.7</span>s, p80:<span class="hljs-number">2.74</span>s, p95:<span class="hljs-number">2.74</span>s, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> funcs:<span class="hljs-built_in">max</span>(tpch_100.lineitem.l_shipdate)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">28</span>, funcs:<span class="hljs-built_in">max</span>(tpch_100.lineitem.l_commitdate)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">29</span>, funcs:<span class="hljs-built_in">max</span>(tpch_100.lineitem.l_receiptdate)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">30</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashJoin_42 <span class="hljs-operator">|</span> <span class="hljs-number">600845438.27</span> <span class="hljs-operator">|</span> <span class="hljs-number">600037902</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2.15</span>s, min:<span class="hljs-number">2.06</span>s, avg: <span class="hljs-number">2.11</span>s, p80:<span class="hljs-number">2.15</span>s, p95:<span class="hljs-number">2.15</span>s, iters:<span class="hljs-number">9286</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">inner</span> <span class="hljs-keyword">join</span>, equal:[eq(tpch_100.supplier.s_suppkey, tpch_100.lineitem.l_suppkey)] <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> ├─ExchangeReceiver_30(Build) <span class="hljs-operator">|</span> <span class="hljs-number">1000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">3000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">28.1</span>ms, min:<span class="hljs-number">24.9</span>ms, avg: <span class="hljs-number">27</span>ms, p80:<span class="hljs-number">28.1</span>ms, p95:<span class="hljs-number">28.1</span>ms, iters:<span class="hljs-number">48</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─ExchangeSender_29 <span class="hljs-operator">|</span> <span class="hljs-number">1000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">1000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">14</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">4.67</span>ms, p80:<span class="hljs-number">14</span>ms, p95:<span class="hljs-number">14</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">2</span>} <span class="hljs-operator">|</span> ExchangeType: Broadcast <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> │ └─TableFullScan_28 <span class="hljs-operator">|</span> <span class="hljs-number">1000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">1000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:supplier <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">9</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">3</span>ms, p80:<span class="hljs-number">9</span>ms, p95:<span class="hljs-number">9</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">2</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">123</span>, total_skipped_packs:<span class="hljs-number">0</span>, total_scanned_rows:<span class="hljs-number">1000000</span>, total_skipped_rows:<span class="hljs-number">0</span>, total_rs_index_load_time: <span class="hljs-number">0</span>ms, total_read_time: <span class="hljs-number">2</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableFullScan_31(Probe) <span class="hljs-operator">|</span> <span class="hljs-number">600037902.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600037902</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:lineitem <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">57.9</span>ms, min:<span class="hljs-number">42.9</span>ms, avg: <span class="hljs-number">51.3</span>ms, p80:<span class="hljs-number">57.9</span>ms, p95:<span class="hljs-number">57.9</span>ms, iters:<span class="hljs-number">9297</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">73464</span>, total_skipped_packs:<span class="hljs-number">12985</span>, total_scanned_rows:<span class="hljs-number">600169085</span>, total_skipped_rows:<span class="hljs-number">106014866</span>, total_rs_index_load_time: <span class="hljs-number">23</span>ms, total_read_time: <span class="hljs-number">21667</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">------------------------------------------+--------------+-----------+--------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+------+</span> <span class="hljs-number">9</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span> (<span class="hljs-number">2.76</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><h3 id="设置更大的执行并发度" style="position:relative">设置更大的执行并发度<a href="#%E8%AE%BE%E7%BD%AE%E6%9B%B4%E5%A4%A7%E7%9A%84%E6%89%A7%E8%A1%8C%E5%B9%B6%E5%8F%91%E5%BA%A6" aria-label="设置更大的执行并发度 permalink" class="anchor after"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a></h3><p>设置更大的执行并发度,可以让 TiFlash 占用更多系统 CPU 资源,从而提升查询性能。</p><p><a href="/zh/tidb/stable/system-variables#tidb_max_tiflash_threads-从-v610-版本开始引入"><code>tidb_max_tiflash_threads</code></a>,单位为线程。用来设置 TiFlash 中 request 执行的最大并发度。</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia"><span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_max_tiflash_threads <span class="hljs-operator">=</span> <span class="hljs-number">20</span>; </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>在以下示例中,设置 <code>tidb_max_tiflash_threads</code> 前,单个 TiFlash 实例的 request 执行的并发度为 8 个线程。该集群一共有 3 个 TiFlash 实例,因此所有 TiFlash 实例上的 request 执行的线程总数是 24。当将 <code>tidb_max_tiflash_threads</code> 设置为 <code>20</code> 后,所有 TiFlash 实例上的 request 执行的线程总数是 60。</p><p><code>tidb_max_tiflash_threads</code> 设置前:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> a, <span class="hljs-built_in">count</span>(<span class="hljs-operator">*</span>) <span class="hljs-keyword">from</span> t <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span> a; <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------+--------------+-----------+--------------+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------+--------------+-----------+--------------+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> TableReader_44 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">655.9</span>ms, loops:<span class="hljs-number">2</span>, cop_task: {num: <span class="hljs-number">14</span>, max: <span class="hljs-number">0</span>s, min: <span class="hljs-number">0</span>s, avg: <span class="hljs-number">0</span>s, p95: <span class="hljs-number">0</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>} <span class="hljs-operator">|</span> data:ExchangeSender_43 <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_43 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">654.6</span>ms, min:<span class="hljs-number">652.4</span>ms, avg: <span class="hljs-number">653.8</span>ms, p80:<span class="hljs-number">654.6</span>ms, p95:<span class="hljs-number">654.6</span>ms, iters:<span class="hljs-number">11</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> ExchangeType: PassThrough <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Projection_5 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">654.3</span>ms, min:<span class="hljs-number">651.4</span>ms, avg: <span class="hljs-number">653.1</span>ms, p80:<span class="hljs-number">654.3</span>ms, p95:<span class="hljs-number">654.3</span>ms, iters:<span class="hljs-number">11</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> test.t.a, <span class="hljs-keyword">Column</span>#<span class="hljs-number">22</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Projection_39 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">654.3</span>ms, min:<span class="hljs-number">651.4</span>ms, avg: <span class="hljs-number">653.1</span>ms, p80:<span class="hljs-number">654.3</span>ms, p95:<span class="hljs-number">654.3</span>ms, iters:<span class="hljs-number">11</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">Column</span>#<span class="hljs-number">22</span>, test.t.a <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_40 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">654.3</span>ms, min:<span class="hljs-number">651.4</span>ms, avg: <span class="hljs-number">653.1</span>ms, p80:<span class="hljs-number">654.3</span>ms, p95:<span class="hljs-number">654.3</span>ms, iters:<span class="hljs-number">11</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:test.t.a, funcs:<span class="hljs-built_in">sum</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">29</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">22</span>, funcs:firstrow(test.t.a)<span class="hljs-operator">-</span><span class="hljs-operator">></span>test.t.a, stream_count: <span class="hljs-number">8</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeReceiver_42 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">60</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">654.3</span>ms, min:<span class="hljs-number">651.4</span>ms, avg: <span class="hljs-number">653.1</span>ms, p80:<span class="hljs-number">654.3</span>ms, p95:<span class="hljs-number">654.3</span>ms, iters:<span class="hljs-number">11</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> stream_count: <span class="hljs-number">8</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_41 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">60</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">649</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">216.3</span>ms, p80:<span class="hljs-number">649</span>ms, p95:<span class="hljs-number">649</span>ms, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: test.t.a, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>], stream_count: <span class="hljs-number">8</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_37 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">60</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">649</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">216.3</span>ms, p80:<span class="hljs-number">649</span>ms, p95:<span class="hljs-number">649</span>ms, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:test.t.a, funcs:<span class="hljs-built_in">count</span>(<span class="hljs-number">1</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">29</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableFullScan_26 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:t <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">40</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">13.3</span>ms, p80:<span class="hljs-number">40</span>ms, p95:<span class="hljs-number">40</span>ms, iters:<span class="hljs-number">9386</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">73833</span>, total_skipped_packs:<span class="hljs-number">174</span>, total_scanned_rows:<span class="hljs-number">600000000</span>, total_skipped_rows:<span class="hljs-number">1402537</span>, total_rs_index_load_time: <span class="hljs-number">0</span>ms, total_read_time: <span class="hljs-number">4</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------+--------------+-----------+--------------+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-number">9</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span> (<span class="hljs-number">0.67</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>设置 <code>tidb_max_tiflash_threads</code>:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> <span class="hljs-keyword">set</span> @<span class="hljs-variable">@tidb</span>_max_tiflash_threads <span class="hljs-operator">=</span> <span class="hljs-number">20</span>; Query OK, <span class="hljs-number">0</span> <span class="hljs-keyword">rows</span> affected (<span class="hljs-number">0.00</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p><code>tidb_max_tiflash_threads</code> 设置后:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> a, <span class="hljs-built_in">count</span>(<span class="hljs-operator">*</span>) <span class="hljs-keyword">from</span> t <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span> a; <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------+--------------+-----------+--------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------+--------------+-----------+--------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> TableReader_44 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">357.7</span>ms, loops:<span class="hljs-number">2</span>, cop_task: {num: <span class="hljs-number">19</span>, max: <span class="hljs-number">0</span>s, min: <span class="hljs-number">0</span>s, avg: <span class="hljs-number">0</span>s, p95: <span class="hljs-number">0</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>} <span class="hljs-operator">|</span> data:ExchangeSender_43 <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_43 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">355.3</span>ms, min:<span class="hljs-number">354.6</span>ms, avg: <span class="hljs-number">355</span>ms, p80:<span class="hljs-number">355.3</span>ms, p95:<span class="hljs-number">355.3</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: PassThrough <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Projection_5 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">354.3</span>ms, min:<span class="hljs-number">353.6</span>ms, avg: <span class="hljs-number">354</span>ms, p80:<span class="hljs-number">354.3</span>ms, p95:<span class="hljs-number">354.3</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> test.t.a, <span class="hljs-keyword">Column</span>#<span class="hljs-number">22</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Projection_39 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">354.3</span>ms, min:<span class="hljs-number">353.6</span>ms, avg: <span class="hljs-number">354</span>ms, p80:<span class="hljs-number">354.3</span>ms, p95:<span class="hljs-number">354.3</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">Column</span>#<span class="hljs-number">22</span>, test.t.a <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_40 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">20</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">354.3</span>ms, min:<span class="hljs-number">353.6</span>ms, avg: <span class="hljs-number">354</span>ms, p80:<span class="hljs-number">354.3</span>ms, p95:<span class="hljs-number">354.3</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:test.t.a, funcs:<span class="hljs-built_in">sum</span>(<span class="hljs-keyword">Column</span>#<span class="hljs-number">29</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">22</span>, funcs:firstrow(test.t.a)<span class="hljs-operator">-</span><span class="hljs-operator">></span>test.t.a, stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeReceiver_42 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">60</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">354.3</span>ms, min:<span class="hljs-number">353.6</span>ms, avg: <span class="hljs-number">354</span>ms, p80:<span class="hljs-number">354.3</span>ms, p95:<span class="hljs-number">354.3</span>ms, iters:<span class="hljs-number">16</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_41 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">60</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">349.6</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">116.5</span>ms, p80:<span class="hljs-number">349.6</span>ms, p95:<span class="hljs-number">349.6</span>ms, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: test.t.a, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>], stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─HashAgg_37 <span class="hljs-operator">|</span> <span class="hljs-number">20.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">60</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">347.6</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">115.9</span>ms, p80:<span class="hljs-number">347.6</span>ms, p95:<span class="hljs-number">347.6</span>ms, iters:<span class="hljs-number">3</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-keyword">group</span> <span class="hljs-keyword">by</span>:test.t.a, funcs:<span class="hljs-built_in">count</span>(<span class="hljs-number">1</span>)<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">29</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableFullScan_26 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:t <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">36.6</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">12.2</span>ms, p80:<span class="hljs-number">36.6</span>ms, p95:<span class="hljs-number">36.6</span>ms, iters:<span class="hljs-number">9389</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">73833</span>, total_skipped_packs:<span class="hljs-number">418</span>, total_scanned_rows:<span class="hljs-number">600001386</span>, total_skipped_rows:<span class="hljs-number">3381854</span>, total_rs_index_load_time: <span class="hljs-number">10</span>ms, total_read_time: <span class="hljs-number">61</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">--------------------------------------+--------------+-----------+--------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-number">9</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span> (<span class="hljs-number">0.37</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><h3 id="设置细粒度-shuffle-参数" style="position:relative">设置细粒度 Shuffle 参数<a href="#%E8%AE%BE%E7%BD%AE%E7%BB%86%E7%B2%92%E5%BA%A6-shuffle-%E5%8F%82%E6%95%B0" aria-label="设置细粒度 shuffle 参数 permalink" class="anchor after"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a></h3><p>细粒度 Shuffle 可以通过参数增加窗口函数执行的并发度,让函数执行占用更多系统资源,从而提升查询性能。</p><p><a href="/zh/tidb/stable/system-variables#tiflash_fine_grained_shuffle_stream_count-从-v620-版本开始引入"><code>tiflash_fine_grained_shuffle_stream_count</code></a>,单位为线程数。当窗口函数下推到 TiFlash 执行时,可以通过该变量控制窗口函数执行的并行度。</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia"><span class="hljs-keyword">set</span> @<span class="hljs-variable">@tiflash</span>_fine_grained_shuffle_stream_count <span class="hljs-operator">=</span> <span class="hljs-number">20</span>; </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>在以下示例中,<code>tiflash_fine_grained_shuffle_stream_count</code> 设置前,<code>[ExchangeSender_11, ExchangeReceiver_12, Sort_13, Window_22]</code> 的 <code>stream_count</code> 是 8。<code>tiflash_fine_grained_shuffle_stream_count</code> 设置后,<code>[ExchangeSender_11, ExchangeReceiver_12, Sort_13, Window_22]</code> 的 <code>stream_count</code> 是 20。</p><p><code>tiflash_fine_grained_shuffle_stream_count</code> 设置前:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> <span class="hljs-operator">*</span>, <span class="hljs-built_in">row_number</span>() <span class="hljs-keyword">over</span> (<span class="hljs-keyword">partition</span> <span class="hljs-keyword">by</span> a) <span class="hljs-keyword">from</span> t; <span class="hljs-operator">+</span><span class="hljs-comment">----------------------------------+--------------+-----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">----------------------------------+--------------+-----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> TableReader_24 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">4</span>m30<span class="hljs-number">.5</span>s, loops:<span class="hljs-number">585941</span>, cop_task: {num: <span class="hljs-number">9163</span>, max: <span class="hljs-number">0</span>s, min: <span class="hljs-number">0</span>s, avg: <span class="hljs-number">0</span>s, p95: <span class="hljs-number">0</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>} <span class="hljs-operator">|</span> data:ExchangeSender_23 <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_23 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">4</span>m30<span class="hljs-number">.5</span>s, min:<span class="hljs-number">3</span>m4<span class="hljs-number">.8</span>s, avg: <span class="hljs-number">3</span>m36<span class="hljs-number">.1</span>s, p80:<span class="hljs-number">4</span>m30<span class="hljs-number">.5</span>s, p95:<span class="hljs-number">4</span>m30<span class="hljs-number">.5</span>s, iters:<span class="hljs-number">9160</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> ExchangeType: PassThrough <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Window_22 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">3</span>m31<span class="hljs-number">.6</span>s, min:<span class="hljs-number">2</span>m26<span class="hljs-number">.2</span>s, avg: <span class="hljs-number">2</span>m50<span class="hljs-number">.7</span>s, p80:<span class="hljs-number">3</span>m31<span class="hljs-number">.6</span>s, p95:<span class="hljs-number">3</span>m31<span class="hljs-number">.6</span>s, iters:<span class="hljs-number">9160</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> <span class="hljs-built_in">row_number</span>()<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">23</span> <span class="hljs-keyword">over</span>(<span class="hljs-keyword">partition</span> <span class="hljs-keyword">by</span> test.t.a <span class="hljs-keyword">rows</span> <span class="hljs-keyword">between</span> <span class="hljs-keyword">current</span> <span class="hljs-type">row</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">current</span> <span class="hljs-type">row</span>), stream_count: <span class="hljs-number">8</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Sort_13 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">3</span>m28<span class="hljs-number">.6</span>s, min:<span class="hljs-number">2</span>m24<span class="hljs-number">.2</span>s, avg: <span class="hljs-number">2</span>m48<span class="hljs-number">.4</span>s, p80:<span class="hljs-number">3</span>m28<span class="hljs-number">.6</span>s, p95:<span class="hljs-number">3</span>m28<span class="hljs-number">.6</span>s, iters:<span class="hljs-number">9160</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> test.t.a, stream_count: <span class="hljs-number">8</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeReceiver_12 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">32.4</span>s, min:<span class="hljs-number">32</span>s, avg: <span class="hljs-number">32.1</span>s, p80:<span class="hljs-number">32.4</span>s, p95:<span class="hljs-number">32.4</span>s, iters:<span class="hljs-number">49307</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">24</span>} <span class="hljs-operator">|</span> stream_count: <span class="hljs-number">8</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_11 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">32</span>s, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">10.7</span>s, p80:<span class="hljs-number">32</span>s, p95:<span class="hljs-number">32</span>s, iters:<span class="hljs-number">9386</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: HashPartition, Hash Cols: [name: test.t.a, <span class="hljs-keyword">collate</span>: <span class="hljs-type">binary</span>], stream_count: <span class="hljs-number">8</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─TableFullScan_10 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-keyword">table</span>:t <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">113.9</span>ms, min:<span class="hljs-number">0</span>s, avg: <span class="hljs-number">38</span>ms, p80:<span class="hljs-number">113.9</span>ms, p95:<span class="hljs-number">113.9</span>ms, iters:<span class="hljs-number">9386</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>}, tiflash_scan:{dtfile:{total_scanned_packs:<span class="hljs-number">73834</span>, total_skipped_packs:<span class="hljs-number">190</span>, total_scanned_rows:<span class="hljs-number">600000000</span>, total_skipped_rows:<span class="hljs-number">1536382</span>, total_rs_index_load_time: <span class="hljs-number">16</span>ms, total_read_time: <span class="hljs-number">166324</span>ms}, total_create_snapshot_time: <span class="hljs-number">0</span>ms} <span class="hljs-operator">|</span> keep <span class="hljs-keyword">order</span>:<span class="hljs-literal">false</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">----------------------------------+--------------+-----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-number">7</span> <span class="hljs-keyword">rows</span> <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span> (<span class="hljs-number">4</span> min <span class="hljs-number">30.59</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p>设置 <code>tiflash_fine_grained_shuffle_stream_count</code>:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> <span class="hljs-keyword">set</span> @<span class="hljs-variable">@tiflash</span>_fine_grained_shuffle_stream_count <span class="hljs-operator">=</span> <span class="hljs-number">20</span>; Query OK, <span class="hljs-number">0</span> <span class="hljs-keyword">rows</span> affected (<span class="hljs-number">0.00</span> sec) </div><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1rmx1rm" tabindex="0" type="button" aria-label="Toggle code wrap"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="WrapTextIcon"><path d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"/></svg></button><button class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-fxo539" tabindex="0" type="button" aria-label="copy"><svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1cw4hi4" focusable="false" aria-hidden="true" viewbox="0 0 24 24" data-testid="ContentCopyIcon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button></code></pre><p><code>tiflash_fine_grained_shuffle_stream_count</code> 设置后:</p><pre><code class="hljs language-sql"><div class="MuiBox-root css-1qhimia">mysql<span class="hljs-operator">></span> explain analyze <span class="hljs-keyword">select</span> <span class="hljs-operator">*</span>, <span class="hljs-built_in">row_number</span>() <span class="hljs-keyword">over</span> (<span class="hljs-keyword">partition</span> <span class="hljs-keyword">by</span> a) <span class="hljs-keyword">from</span> t; <span class="hljs-operator">+</span><span class="hljs-comment">----------------------------------+--------------+-----------+--------------+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> id <span class="hljs-operator">|</span> estRows <span class="hljs-operator">|</span> actRows <span class="hljs-operator">|</span> task <span class="hljs-operator">|</span> access object <span class="hljs-operator">|</span> execution info <span class="hljs-operator">|</span> operator info <span class="hljs-operator">|</span> memory <span class="hljs-operator">|</span> disk <span class="hljs-operator">|</span> <span class="hljs-operator">+</span><span class="hljs-comment">----------------------------------+--------------+-----------+--------------+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+--------+------+</span> <span class="hljs-operator">|</span> TableReader_24 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> root <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> <span class="hljs-type">time</span>:<span class="hljs-number">2</span>m55s, loops:<span class="hljs-number">585941</span>, cop_task: {num: <span class="hljs-number">9163</span>, max: <span class="hljs-number">0</span>s, min: <span class="hljs-number">0</span>s, avg: <span class="hljs-number">0</span>s, p95: <span class="hljs-number">0</span>s, copr_cache_hit_ratio: <span class="hljs-number">0.00</span>} <span class="hljs-operator">|</span> data:ExchangeSender_23 <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─ExchangeSender_23 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2</span>m55s, min:<span class="hljs-number">1</span>m37s, avg: <span class="hljs-number">2</span>m28<span class="hljs-number">.7</span>s, p80:<span class="hljs-number">2</span>m55s, p95:<span class="hljs-number">2</span>m55s, iters:<span class="hljs-number">9160</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> ExchangeType: PassThrough <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Window_22 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2</span>m12<span class="hljs-number">.9</span>s, min:<span class="hljs-number">1</span>m17s, avg: <span class="hljs-number">1</span>m54<span class="hljs-number">.2</span>s, p80:<span class="hljs-number">2</span>m12<span class="hljs-number">.9</span>s, p95:<span class="hljs-number">2</span>m12<span class="hljs-number">.9</span>s, iters:<span class="hljs-number">9160</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> <span class="hljs-built_in">row_number</span>()<span class="hljs-operator">-</span><span class="hljs-operator">></span><span class="hljs-keyword">Column</span>#<span class="hljs-number">23</span> <span class="hljs-keyword">over</span>(<span class="hljs-keyword">partition</span> <span class="hljs-keyword">by</span> test.t.a <span class="hljs-keyword">rows</span> <span class="hljs-keyword">between</span> <span class="hljs-keyword">current</span> <span class="hljs-type">row</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">current</span> <span class="hljs-type">row</span>), stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> └─Sort_13 <span class="hljs-operator">|</span> <span class="hljs-number">600000000.00</span> <span class="hljs-operator">|</span> <span class="hljs-number">600000000</span> <span class="hljs-operator">|</span> mpp[tiflash] <span class="hljs-operator">|</span> <span class="hljs-operator">|</span> tiflash_task:{proc max:<span class="hljs-number">2</span>m10<span class="hljs-number">.9</span>s, min:<span class="hljs-number">1</span>m16s, avg: <span class="hljs-number">1</span>m52<span class="hljs-number">.5</span>s, p80:<span class="hljs-number">2</span>m10<span class="hljs-number">.9</span>s, p95:<span class="hljs-number">2</span>m10<span class="hljs-number">.9</span>s, iters:<span class="hljs-number">9160</span>, tasks:<span class="hljs-number">3</span>, threads:<span class="hljs-number">60</span>} <span class="hljs-operator">|</span> test.t.a, stream_count: <span class="hljs-number">20</span> <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span> N<span class="hljs-operator">/</span>A <span class="hljs-operator">|</span>
推荐文章
爱跑步的感冒药
·
犬之岛讽刺社会 _大公网
6 月前
豪爽的皮带
·
申请建行大山白需要什么条件? - 知乎
7 月前
体贴的板凳
·
坦克700最新图片最近信息大曝光…|越野车|新车|车尾|实车图_网易订阅
1 年前
踏实的风衣
·
《地沟油去哪儿了?起底京畿地沟油黑色产业链》之二--财经--人民网
1 年前
跑龙套的圣诞树
·
笑傲江湖 - 🌈️包子漫畫
1 年前