{"id":261,"date":"2020-06-12T13:51:43","date_gmt":"2020-06-12T05:51:43","guid":{"rendered":"http:\/\/www.gbase8.cn\/?p=261"},"modified":"2021-06-10T09:04:34","modified_gmt":"2021-06-10T01:04:34","slug":"gbase-8a%e9%9b%86%e7%be%a4%e6%80%a7%e8%83%bd%e7%9b%91%e6%8e%a7sql%e5%9c%a8%e6%af%8f%e4%b8%aa%e8%8a%82%e7%82%b9%e6%89%a7%e8%a1%8c%e6%97%b6%e9%97%b4","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/261","title":{"rendered":"Nanda General GBase 8a cluster performance monitoring SQL execution time on each node"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2adbf613c84\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2adbf613c84\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/261\/#%E5%8F%82%E6%95%B0\" >\u53c2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/261\/#%E7%B3%BB%E7%BB%9F%E8%A1%A8\" >\u7cfb\u7edf\u8868<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/261\/#%E8%A6%86%E7%9B%96%E5%8A%9F%E8%83%BD%E7%82%B9\" >\u8986\u76d6\u529f\u80fd\u70b9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/261\/#%E6%A0%B7%E4%BE%8B\" >\u6837\u4f8b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.gbase8.cn\/en\/261\/#%E5%85%83%E6%95%B0%E6%8D%AE\" >Metadata<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.gbase8.cn\/en\/261\/#sys_sqls\" >sys_sqls<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.gbase8.cn\/en\/261\/#sys_sqls_elapsepernode\" >sys_sqls_elapsepernode<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E6%95%B0\"><\/span>\u53c2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u672c\u529f\u80fd \u7531\u53c2\u6570 gcluster_dql_statistic_threshold \u63a7\u5236\u3002<br>\u5f53 gcluster_dql_statistic_threshold \u4e3a 0\u65f6 \u672c\u529f\u80fd\u5173\u95ed\u3002<br>\u5f53 gcluster_dql_statistic_threshold&gt; 0\u65f6 \u53ea\u6709\u5f53SQL\u6267\u884c\u65f6\u95f4 \u5927\u4e8e gcluster_dql_statistic_threshold \u65f6\u624d\u4f1a\u628a\u672cSQL\u5728\u6240\u6709\u8282\u70b9\u6267\u884c\u4fe1\u606f\u8bb0\u5f55\u5230\u7cfb\u7edf\u8868\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%B3%BB%E7%BB%9F%E8%A1%A8\"><\/span>\u7cfb\u7edf\u8868<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u672c\u529f\u80fd\u65b0\u589e\u4e24\u4e2a\u7cfb\u7edf\u8868\uff1agclusterdb.sys_sqls \u548c gclusterdb.sys_sql_elapsepernode \u3002\u7528\u6765\u8bb0\u5f55\u5386\u53f2SQL\u5728\u6240\u6709\u8282\u70b9\u6267\u884c\u4fe1\u606f\u3002<br>\u672c\u529f\u80fd\u63d0\u4f9b\u4e00\u5f20\u5185\u5b58\u8868\uff1ainformation_schema.SELECT_STATISTIC\u3002 \u7528\u6765\u67e5\u770b\u5f53\u524d\u6b63\u5728\u6267\u884c\u7684SQL\u5728\u6240\u6709\u8282\u70b9\u4e0a\u6267\u884c\u4fe1\u606f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A6%86%E7%9B%96%E5%8A%9F%E8%83%BD%E7%82%B9\"><\/span>\u8986\u76d6\u529f\u80fd\u70b9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>1\u3001\u6d89\u53ca\u5230\u7684sql\u8303\u56f4<br>\u539f\u5219\u662fsql\u4e0b\u53d1\u5230\u6240\u6709\u5206\u7247\u4e0a\u7684sql\u90fd\u4f1a\u8bb0\u5f55\u5230\u7cfb\u7edf\u8868<br>ddl\uff1acreate select<br>dml\uff1ainsert select<br>update\/delete \u5e26\u6709where\u6761\u4ef6\u7684sql<br>DQL\uff1a\u9664\u8868\u7c7b\u578b\u4e3a\u590d\u5236\u8868\u3001\u5355\u70b9hash\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u6309\u7167\u539f\u5219sql\u4e0b\u53d1\u5230\u6240\u6709\u5206\u7247\u4e0a\u7684sql\u90fd\u4f1a\u8bb0\u5f55\u5230\u7cfb\u7edf\u8868\u7684\u67e5\u8be2\u8bed\u53e5<br>\u8986\u76d6\u67e5\u8be2\u7684sql\u53caselect into outfile \u591a\u8868\u5206\u5e03\u5728\u4e0d\u540c\u7684distribution\u4e0a\u67e5\u8be2<\/p>\n\n\n\n<p>2\u3001\u67e5\u8be2\u62a5\u9519\u7684sql\uff0c\u6267\u884c\u8282\u70b9\u6267\u884csql\uff0c\u5728\u5176\u4ed6\u8282\u70b9\u6267\u884ckill gbased\u7b49\u5f02\u5e38\u64cd\u4f5c\uff0c\u4f1a\u51fa\u73b0\u6267\u884c\u8282\u70b9gclusterd\u5b95\u673a<\/p>\n\n\n\n<p>3\u3001\u5e26\u6709hint\u7684\u8bed\u53e5\u67e5\u8be2\u7cfb\u7edf\u8868\u6570\u636e\u8bb0\u5f55\u91cd\u590d<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%A0%B7%E4%BE%8B\"><\/span>\u6837\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\ngbase&gt; set gcluster_dql_statistic_threshold=1;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.01)\n\ngbase&gt; select id,count(*) from t1 group by id order by count(*) desc;\n+---------+----------+\n| id      | count(*) |\n+---------+----------+\n| 1027347 |       68 |\n| 1010186 |       64 |\n| 1027569 |       64 |\n| 1006983 |       64 |\n| 1014427 |       64 |\n| 1032549 |       64 |\n\n| 2009629 |        3 |\n|    9629 |        3 |\n| 2011350 |        2 |\n|   11350 |        2 |\n| 2009140 |        2 |\n|    9140 |        2 |\n+---------+----------+\n98304 rows in set (Elapsed: 00:00:04.28)\n\n\ngbase&gt; use gclusterdb;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.01)\n\ngbase&gt; show tables;\n+------------------------+\n| Tables_in_gclusterdb   |\n+------------------------+\n| audit_log_express      |\n| dual                   |\n| nodedatamap            |\n| rebalancing_status     |\n| sys_sqls               |\n| sys_sqls_elapsepernode |\n+------------------------+\n6 rows in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select * from sys_sqls;\n+---------+---------------------------------------------------------------+---------------------+\n| task_id | sql_text                                                      | elapse_time         |\n+---------+---------------------------------------------------------------+---------------------+\n| 2621528 | select id,count(*) from t1 group by id order by count(*) desc | 2020-11-10 11:17:59 |\n+---------+---------------------------------------------------------------+---------------------+\n1 row in set (Elapsed: 00:00:00.01)\n\ngbase&gt; select * from sys_sqls_elapsepernode;\n+---------+-------------------+----------+------+-------+\n| task_id | node              | node_sid | time | errno |\n+---------+-------------------+----------+------+-------+\n| 2621528 | ::ffff:10.0.2.201 |       59 |    2 |     0 |\n| 2621528 | ::ffff:10.0.2.202 |       71 |    1 |     0 |\n+---------+-------------------+----------+------+-------+\n2 rows in set (Elapsed: 00:00:00.01)\n\ngbase&gt;\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%85%83%E6%95%B0%E6%8D%AE\"><\/span>Metadata<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"sys_sqls\"><\/span>sys_sqls<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u8bb0\u5f55\u7684SQL\u4fe1\u606f<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u5b57\u6bb5\u540d<\/th><th>\u7c7b\u578b<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td>task_id<\/td><td>bigint(20)<\/td><td>\u4efb\u52a1\u7f16\u53f7<\/td><\/tr><tr><td>sql_text<\/td><td>varchar(2000)<\/td><td>\u6267\u884c\u7684SQL\u90e8\u5206\u5185\u5bb9<\/td><\/tr><tr><td>elapse_time<\/td><td>datetime<\/td><td>SQL\u5f00\u59cb\u6267\u884c\u7684\u65f6\u95f4\uff0c\u6ce8\u610f\u4e0d\u662f\u8017\u65f6<\/td><\/tr><tr><td><\/td><td><\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"sys_sqls_elapsepernode\"><\/span>sys_sqls_elapsepernode<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>SQL\u5728\u6bcf\u4e2a\u8282\u70b9\u7684\u6267\u884c\u8017\u65f6<\/p>\n\n\n\n<p>\u8bb0\u5f55\u7684SQL\u4fe1\u606f<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u5b57\u6bb5\u540d<\/th><th>\u7c7b\u578b<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td>task_id<\/td><td>bigint(20)<\/td><td>\u4efb\u52a1\u7f16\u53f7<\/td><\/tr><tr><td>node<\/td><td>varchar(256)<\/td><td>\u6267\u884c\u7684\u8282\u70b9IP<\/td><\/tr><tr><td>node_sid<\/td><td>int(11)<\/td><td>\u6267\u884c\u8282\u70b9\u7684SessionId<\/td><\/tr><tr><td>time<\/td><td>int(11)<\/td><td>\u6267\u884c\u8017\u65f6<\/td><\/tr><tr><td>errno<\/td><td>int(11)<\/td><td>\u6267\u884c\u7ed3\u679c\u3002<br>0 = \u6210\u529f<br>\u5176\u5b83=\u62a5\u9519<\/td><\/tr><\/tbody><\/table><\/figure>","protected":false},"excerpt":{"rendered":"<p>Nanda General GBase 8a cluster performance monitoring SQL execution time on each node<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[69,28],"class_list":{"0":"post-261","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-gbase8a","8":"tag-69","9":"tag-28"},"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=261"}],"version-history":[{"count":6,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/261\/revisions"}],"predecessor-version":[{"id":6334,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/261\/revisions\/6334"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}