开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
forked from 小圈圈/Archery
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (3)
标签 (52)
master
adminlte
feature/add-restfulapis
v1.8.0
v1.7.13
v1.7.12
v1.7.11
v1.7.10
v1.7.9
v1.7.8
v1.7.7
v1.7.6
v1.7.5
v1.7.4
v1.7.3
v1.7.2
v1.7.1
v1.7.0
v1.6.7
v1.6.6
v1.6.5
v1.6.4
v1.6.3
master
分支 (3)
标签 (52)
master
adminlte
feature/add-restfulapis
v1.8.0
v1.7.13
v1.7.12
v1.7.11
v1.7.10
v1.7.9
v1.7.8
v1.7.7
v1.7.6
v1.7.5
v1.7.4
v1.7.3
v1.7.2
v1.7.1
v1.7.0
v1.6.7
v1.6.6
v1.6.5
v1.6.4
v1.6.3
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (3)
标签 (52)
master
adminlte
feature/add-restfulapis
v1.8.0
v1.7.13
v1.7.12
v1.7.11
v1.7.10
v1.7.9
v1.7.8
v1.7.7
v1.7.6
v1.7.5
v1.7.4
v1.7.3
v1.7.2
v1.7.1
v1.7.0
v1.6.7
v1.6.6
v1.6.5
v1.6.4
v1.6.3
Archery
/
src
/
script
/
rule.json
Archery
/
src
/
script
/
rule.json
rule.json 44.94 KB
一键复制 编辑 原始数据 按行查看 历史
小圈圈 提交于 2018年08月04日 14:23 +08:00 . 调整项目结构,增加themis数据库审核
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455
{
"_id":ObjectId("5b61644153cc7e049902d11b"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.planitem.find({\"schemas\":\"@schema_name@\",\"item_type\" : \"materialized_from_subquery\"}).forEach(function(x){db.sqlinfo.find({checksum:x.checksum}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio})})})",
"rule_desc":"materialized_from_subquery",
"rule_name":"MATERIALIZED_FROM_SUBQUERY",
"rule_status":"ON",
"rule_summary":"",
"rule_type":"SQLPLAN",
"solution":[
"1.使用连接查询",
"2.避免大的结果集"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d11d"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.planitem.find({\"schemas\":\"@schema_name@\",\"dependent\" : true}).forEach(function(x){db.sqlinfo.find({checksum:x.checksum}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio})})})",
"rule_desc":"dependent",
"rule_name":"DEPENDENT",
"rule_status":"ON",
"rule_summary":"",
"rule_type":"SQLPLAN",
"solution":[
"使用连接查询"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d120"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.planitem.find({\"schemas\":\"@schema_name@\",\"access_type\" : \"unique_subquery\"}).forEach(function(x){db.sqlinfo.find({checksum:x.checksum}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio})})})",
"rule_desc":"unique_subquery",
"rule_name":"UNIQUE_SUBQUERY",
"rule_status":"ON",
"rule_summary":"",
"rule_type":"SQLPLAN",
"solution":[
"子查询改写为表关联"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d121"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.planitem.find({\"schemas\":\"@schema_name@\",\"cacheable\" : false}).forEach(function(x){db.sqlinfo.find({checksum:x.checksum}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio})})})",
"rule_desc":"cacheable",
"rule_name":"CACHEABLE",
"rule_status":"ON",
"rule_summary":"",
"rule_type":"SQLPLAN",
"solution":[
"无后续补充"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d128"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"扫描行数",
"parm_name":"ROWS"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.planitem.find({\"schemas\":\"@schema_name@\",\"access_type\" : \"ALL\",\"$or\": [{\"rows\" : {\"$gt\":1}}, {\"rows_examined_per_scan\": {\"$gt\":1}}],\"citem_type\":{\"$ne\":\"materialized_from_subquery\"}}).forEach(function(x){db.sqlinfo.find({checksum:x.checksum}).forEach(function(y){if(x.rows){rows=x.rows}else{rows=x.rows_examined_per_scan}db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio,\"rows\":rows})})})",
"rule_desc":"全表扫描",
"rule_name":"TABLE_FULL_SCAN",
"rule_status":"ON",
"rule_summary":"大表全表扫描,行数超过阀值,扫描了多余的数据,建议使用索引来避免",
"rule_type":"SQLPLAN",
"solution":[
"1.缺索引评估创建索引",
"2.取max、min值评估创建索引",
"3.索引失效重建索引,分区表维护记得维护索引",
"4.对条件字段使用函数或表达式a.函数、表达式放到等于号的右边b.创建函数索引(下策)",
"5.出现隐式转换a.不同类型的谓词匹配先显式转换b.表定义根据数据选择正确的数据类型",
"6.使用不等运算符<>!=做查询条件a.尽量少用不等判断;b.如果列值是连续,可把否定操作更改为两个区间;c.如果列值不多,可用inlist枚举其他所有值",
"7.模糊匹配%a%,%a建议精确匹配",
"8.sql逻辑,比如最大值,改用窗口函数",
"9.弱选择sql,返回结果集较大建议a.添加更多的谓词减少数据的访问,比如时间b.改造分区表c.使用覆盖索引",
"10.统计信息不准确数据批量加载程序触发收集统计信息"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d129"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.planitem.find({\"schemas\":\"@schema_name@\",\"using_temporary_table\" : true}).forEach(function(x){db.sqlinfo.find({checksum:x.checksum}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio})})})",
"rule_desc":"临时表排序",
"rule_name":"USING_TEMPORARY_TABLE",
"rule_status":"ON",
"rule_summary":"",
"rule_type":"SQLPLAN",
"solution":[
"避免大排序"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d12a"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.planitem.find({\"schemas\":\"@schema_name@\",\"using_filesort\" : true}).forEach(function(x){db.sqlinfo.find({checksum:x.checksum}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio})})})",
"rule_desc":"磁盘排序",
"rule_name":"USING_FILESORT",
"rule_status":"ON",
"rule_summary":"",
"rule_type":"SQLPLAN",
"solution":[
"避免大排序"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d12b"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.planitem.find({\"schemas\":\"@schema_name@\",\"access_type\" : \"fulltext\"}).forEach(function(x){db.sqlinfo.find({checksum:x.checksum}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio})})})",
"rule_desc":"fulltext",
"rule_name":"FULLTEXT",
"rule_status":"ON",
"rule_summary":"",
"rule_type":"SQLPLAN",
"solution":[
"不建议使用全文索引,大字段使用外部存储方式"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d12c"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.planitem.find({\"schemas\":\"@schema_name@\",\"access_type\" : \"index_merge\"}).forEach(function(x){db.sqlinfo.find({checksum:x.checksum}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio})})})",
"rule_desc":"index_merge",
"rule_name":"INDEX_MERGE",
"rule_status":"ON",
"rule_summary":"",
"rule_type":"SQLPLAN",
"solution":[
"创建复合索引"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d12e"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.planitem.find({\"schemas\":\"@schema_name@\",\"citem_type\" : \"nested_loop\",\"citem.3\":{\"$exists\":1}}).forEach(function(x){db.sqlinfo.find({checksum:x.checksum}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio})})})",
"rule_desc":"multi_tab_join",
"rule_name":"MULTI_TAB_JOIN",
"rule_status":"ON",
"rule_summary":"",
"rule_type":"SQLPLAN",
"solution":[
"sql逻辑改写,减少表关联"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d133"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_parms":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.sqlinfo.find({\"sqlplan_json.complex\":1}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio})})",
"rule_desc":"complex_sql",
"rule_name":"COMPLEX_SQL",
"rule_status":"ON",
"rule_summary":"",
"rule_type":"SQLPLAN",
"solution":[
"sql过于复杂,无法得到json格式执行计划,建议在逻辑和业务上避免此类复杂sql"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d134"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_datas":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
},
{
"parm_desc":"锁定时间总和",
"parm_name":"Lock_time_sum"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.sqlinfo.find({\"Lock_time_sum\" : {$gt:60}}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio, \"Lock_time_sum\" :y.Lock_time_sum})})",
"rule_desc":"Lock_time_sum",
"rule_name":"LOCK_TIME_SUM",
"rule_status":"ON",
"rule_summary":"锁定时间过长",
"rule_type":"SQLSTAT",
"solution":[
"对sql消耗资源评估是否合理,能否优化"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d135"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":10.0,
"output_datas":[
{
"parm_desc":"CHECKSUM",
"parm_name":"CHECKSUM"
},
{
"parm_desc":"执行次数",
"parm_name":"ts_cnt"
},
{
"parm_desc":"平均执行时间",
"parm_name":"query_time_avg"
},
{
"parm_desc":"平均返回记录数",
"parm_name":"rows_sent_avg"
},
{
"parm_desc":"扫描命中率",
"parm_name":"index_ratio"
},
{
"parm_desc":"锁定时间总和",
"parm_name":"Lock_time_sum"
}
],
"rule_complexity":"simple",
"rule_cmd":"db.sqlinfo.find({\"index_ratio\" : {$gt:10000}}).forEach(function(y){db.@tmp@.save({\"checksum\" :y.checksum,\"ts_cnt\" :y.ts_cnt,\"query_time_avg\" :y.query_time_avg,\"rows_sent_avg\" :y.rows_sent_avg,\"index_ratio\" :y.index_ratio, \"Lock_time_sum\" :y.Lock_time_sum})})",
"rule_desc":"index_ratio",
"rule_name":"INDEX_RATIO",
"rule_status":"ON",
"rule_summary":"扫描命中率过低",
"rule_type":"SQLSTAT",
"solution":[
"对sql消耗资源评估是否合理,能否优化"
],
"weight":0.1
}
{
"_id":ObjectId("5b61644153cc7e049902d13e"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_complexity":"simple",
"rule_cmd":"(cross join)|(outer join)",
"rule_desc":"存在全连接或外连接,cross join或outer join情况",
"rule_name":"BAD_JOIN",
"rule_status":"ON",
"rule_summary":"存在全连接或外连接,cross join或outer join情况",
"rule_type":"TEXT",
"solution":[
"改写为innerjoin"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d13f"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_desc":"delete或update中必须出现where子句,防止出现意外的全部删除或更新动作",
"rule_name":"DML_ALLDATA",
"rule_status":"ON",
"rule_summary":"delete或update中必须出现where子句,防止出现意外的全部删除或更新动作",
"rule_type":"TEXT",
"solution":[
"1.建议加where条件",
"2.全表删除用truncate"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d146"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"or个数",
"parm_name":"or_num",
"parm_value":NumberInt(5),
"parm_unit":""
}
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_desc":"多个过滤条件通过or连接",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_name":"TOOMANY_OR",
"rule_status":"ON",
"rule_summary":"多个过滤条件通过or连接,防止优化器出现选择异常",
"rule_type":"TEXT",
"solution":[
"改用临时表存入变量"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d147"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_complexity":"simple",
"rule_cmd":"like .\\%",
"rule_desc":"谓词条件使用like %xxx,无法使用索引",
"rule_name":"LIKE_UNINDEX",
"rule_status":"ON",
"rule_summary":"谓词条件使用like %xxx,无法使用索引",
"rule_type":"TEXT",
"solution":[
"从业务角度出发,分析是否可使用精确运算符或类似like'xx%'"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d14b"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_desc":"select段出现子查询",
"rule_name":"SUBQUERY_SELECT",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_status":"OFF",
"rule_summary":"select段出现子查询",
"rule_type":"TEXT",
"solution":[
"改写为表关联"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d14d"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"inlist元素个数",
"parm_name":"in_list_num",
"parm_value":NumberInt(20),
"parm_unit":""
}
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_desc":"IN List元素过多",
"rule_name":"TOOMANY_IN_LIST",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_status":"ON",
"rule_summary":"IN List元素过多",
"rule_type":"TEXT",
"solution":[
"改用临时表存入变量"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d14e"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"SQL字符数量",
"parm_name":"char_num",
"parm_value":NumberInt(1000),
"parm_unit":""
}
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_desc":"SQL文本过长",
"rule_name":"LONG_TEXT",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_status":"ON",
"rule_summary":"SQL文本过长",
"rule_type":"TEXT",
"solution":[
"sql改写为精简语句"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d14f"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_desc":"重复查询子句",
"rule_name":"SUBQUERY_REP",
"rule_status":"ON",
"rule_summary":"禁止使用重复的查询子句,应使用with as替换子句(仅限Oracle)来提升SQL执行效率",
"rule_type":"TEXT",
"solution":[
"1.withas",
"2.改写sql避免重复查询"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d150"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_desc":"where段出现子查询",
"rule_name":"SUBQUERY_WHERE",
"rule_complexity":"complex",
"rule_cmd":"",
"rule_status":"OFF",
"rule_summary":"where段出现子查询",
"rule_type":"TEXT",
"solution":[
"改写为表关联"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d152"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_desc":"谓词中存在负向操作符,!=,<>,!<,!>,not exists,not",
"rule_complexity":"simple",
"rule_cmd":"(!=)|(<>)|(!>)|(!<)",
"rule_name":"WHERE_NOT",
"rule_status":"ON",
"rule_summary":"谓词中存在负向操作符,!=,<>,!<,!>,not exists,not",
"rule_type":"TEXT",
"solution":[
"1.如果列值是连续,可把否定操作,更改为两个区间",
"2.不建议使用不等值运算"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d154"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_complexity":"simple",
"rule_cmd":"(select \\*)|(select .*\\.\\*)",
"rule_desc":"禁止使用select *,必须明确选择所需的列。",
"rule_name":"SELECT_ANY",
"rule_status":"ON",
"rule_summary":"禁止使用select *,必须明确选择所需的列",
"rule_type":"TEXT",
"solution":[
"使用明确的列"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d156"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_desc":"having段出现子查询",
"rule_name":"SUBQUERY_HAVING",
"rule_status":"OFF",
"rule_summary":"having段出现子查询",
"rule_type":"TEXT",
"solution":[
"改写为表关联"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d157"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_desc":"delete或update中出现order by子句,防止删除或更新过程中出现不必要的排序",
"rule_name":"DML_SORT",
"rule_complexity":"simple",
"rule_cmd":"(\\s)?((update )|(delete )).*order by",
"rule_status":"ON",
"rule_summary":"delete或update中出现order by子句,防止删除或更新过程中出现不必要的排序",
"rule_type":"TEXT",
"solution":[
"dml操作不需排序"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d159"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_desc":"出现union.防止出现不必要的排序动作",
"rule_name":"UNION",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_status":"ON",
"rule_summary":"出现union,防止出现不必要的排序动作",
"rule_type":"TEXT",
"solution":[
"改写unionall和sql逻辑中去重"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d15a"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_desc":"查询字段引用函数",
"rule_complexity":"simple",
"rule_cmd":"\\)\\s?[<>=]{1,2}",
"rule_name":"WHERE_FUNC",
"rule_status":"ON",
"rule_summary":"禁止在查询字段中引用函数",
"rule_type":"TEXT",
"solution":[
"1.函数写在表达式右边",
"2.应用程序实现函数功能"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d15b"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
],
"rule_desc":"from段出现子查询",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_name":"SUBQUERY_FROM",
"rule_status":"OFF",
"rule_summary":"from段出现子查询",
"rule_type":"TEXT",
"solution":[
"改写为表关联"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d15e"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(6),
"output_parms":[
{
"parm_desc":"表名",
"parm_name":"title1"
},
{
"parm_desc":"字段名",
"parm_name":"title2"
},
{
"parm_desc":"数据类型",
"parm_name":"title3"
}
],
"rule_desc":"大对象字段将影响存取性能、耗费较多空间,建议在数据库之外存储。",
"rule_complexity":"simple",
"rule_cmd":"SELECT TABLE_NAME,column_name , DATA_TYPE FROM information_schema.COLUMNS where TABLE_SCHEMA='@username@' and DATA_TYPE in ('blob','mediumblob','longblob','text','mediumblob','longtext') order by table_name",
"rule_name":"EXIST_LOB_COLUMN",
"rule_status":"ON",
"rule_summary":"存在大对象字段",
"rule_type":"OBJ",
"solution":[
"建议在数据库外部进行存储大字段"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d15f"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"提取做正则判断记录数上限",
"parm_name":"num_row",
"parm_value":NumberInt(10000),
"parm_unit":""
}
],
"max_score":NumberInt(20),
"output_parms":[
{
"parm_desc":"表名",
"parm_name":"title1"
},
{
"parm_desc":"字段名",
"parm_name":"title2"
},
{
"parm_desc":"字段定义类型",
"parm_name":"title3"
},
{
"parm_desc":"字段实际类型",
"parm_name":"title4"
}
],
"rule_desc":"根据字段保存内容判断,字段类型定义异常,建议选择适合的数据类型。",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_name":"COLUMN_WRONG_TYPE",
"rule_status":"ON",
"rule_summary":"字段数据类型定义错误",
"rule_type":"OBJ",
"solution":[
"合理定义字段类型"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d160"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"字段长度(字节)",
"parm_name":"primarykey_length",
"parm_value":NumberInt(16),
"parm_unit":""
}
],
"max_score":NumberInt(20),
"output_parms":[
{
"parm_desc":"表名",
"parm_name":"table_name"
},
{
"parm_desc":"主键字段<br>(如果有多个字段,逗号分开)",
"parm_name":"primary_type"
},
{
"parm_desc":"字段类型<br>(如果有多个字段,逗号分开)",
"parm_name":"title3"
},
{
"parm_desc":"字段总长度(字节)",
"parm_name":"title4"
}
],
"rule_desc":"应控制主键字段长度,过长的主键字段会造成索引空间消耗过大。",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_name":"TABLE_PRIMARYKEY_LENGTH",
"rule_status":"ON",
"rule_summary":"单表主键字段定义长度过长",
"rule_type":"OBJ",
"solution":[
"主键设计是否合理"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d161"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(10),
"output_parms":[
{
"parm_desc":"表名",
"parm_name":"table_name"
}
],
"rule_desc":"时间戳字段是获取增量数据的最佳方法,请为表定义时间戳字段。",
"rule_complexity":"simple",
"rule_cmd":"select t.table_name from information_schema.`TABLES` t where t.TABLE_SCHEMA ='@username@' and t.TABLE_NAME not in(select c.table_name from information_schema.`COLUMNS` c where (c.COLUMN_NAME like '%UPDATE%' OR c.COLUMN_NAME like '%CREATE%') and c.DATA_TYPE in ('datetime','date','timestamp','time') and c.table_schema ='@username@')",
"rule_name":"TABLE_WITHOUT_TIMESTAMP",
"rule_status":"ON",
"rule_summary":"表没有定义时间戳字段",
"rule_type":"OBJ",
"solution":[
"添加时间字段(比如插入、更新的时间戳"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d162"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"字段数",
"parm_name":"column_num",
"parm_value":NumberInt(40),
"parm_unit":""
}
],
"max_score":NumberInt(10),
"output_parms":[
{
"parm_desc":"表名",
"parm_name":"title1"
},
{
"parm_desc":"字段数",
"parm_name":"title2"
}
],
"rule_desc":"表字段数过多,将造成记录过长,单页存储记录数减少。可考虑拆表处理。",
"rule_complexity":"simple",
"rule_cmd":"SELECT table_name,count(1) FROM information_schema.columns WHERE table_schema = '@username@' GROUP BY table_name HAVING count(1)>@column_num@",
"rule_name":"TABLE_COLUMN_NUM",
"rule_status":"ON",
"rule_summary":"单表字段数过多",
"rule_type":"OBJ",
"solution":[
"表设计时尽量符合三范式来避免数据冗余,使用频率低的字段拆到另外一张表,必要时做表关联取数"
],
"weight":NumberInt(1)
}
{
"_id":ObjectId("5b61644153cc7e049902d163"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"字段长度(字节)",
"parm_name":"record_length",
"parm_value":"1000",
"parm_unit":""
}
],
"max_score":NumberInt(20),
"output_parms":[
{
"parm_desc":"表名",
"parm_name":"title1"
},
{
"parm_desc":"字段内容平均长度<br>(取自avg_row_length,有失真情况)",
"parm_name":"title2"
},
{
"parm_desc":"字段定义长度",
"parm_name":"title3"
}
],
"rule_desc":"应控制单表定义长度,避免过长记录。",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_name":"TABLE_RECORD_LENGTH",
"rule_status":"ON",
"rule_summary":"单表字段定义长度过长",
"rule_type":"OBJ",
"solution":[
"按需定义字段长度"
],
"weight":NumberInt(2)
}
{
"_id":ObjectId("5b61644153cc7e049902d164"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
{
"parm_desc":"表名",
"parm_name":"title1"
}
],
"rule_desc":"没有定义主键,MySQL会自动创建主键。这不是一种好的设计方法。",
"rule_complexity":"simple",
"rule_cmd":"select table_name from information_schema.tables where table_schema='@username@' and table_name not in(select table_name from information_schema.statistics where table_schema='@username@' and index_name='PRIMARY')",
"rule_name":"TABLE_NO_DEF_PRIMARYKEY",
"rule_status":"ON",
"rule_summary":"表没有定义主键",
"rule_type":"OBJ",
"solution":[
"必须定义主键"
],
"weight":NumberInt(5)
}
{
"_id":ObjectId("5b61644153cc7e049902d165"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
{
"parm_desc":"类别",
"parm_name":"title1"
},
{
"parm_desc":"对象名",
"parm_name":"title2"
},
{
"parm_desc":"依赖表",
"parm_name":"title3"
}
],
"rule_desc":"存储过程、函数、触发器等都将消耗数据库的计算能力,建议通过应用层保证数据约束。",
"rule_complexity":"simple",
"rule_cmd":"select 'TRIGGER',trigger_name,event_object_table from information_schema.triggers where event_object_schema='@username@' union all (select type,specific_name,''from mysql.proc where db='@username@' order by type)",
"rule_name":"EXIST_FUNC_PROC_TRIGGER",
"rule_status":"ON",
"rule_summary":"单表存在函数、存储过程、触发器",
"rule_type":"OBJ",
"solution":[
"用应用端程序实现将存储过程、函数、触发器"
],
"weight":NumberInt(5)
}
{
"_id":ObjectId("5b61644153cc7e049902d166"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"表大小(GB)",
"parm_name":"table_size",
"parm_value":NumberInt(10),
"parm_unit":"GB"
}
],
"max_score":NumberInt(10),
"output_parms":[
{
"parm_desc":"表名称",
"parm_name":"title1"
},
{
"parm_desc":"表大小(GB)",
"parm_name":"title2"
}
],
"rule_desc":"表的规模过大,将影响表的访问效率、增加维护成本等。常见的解决方案就是使用分区表,将大表转换为分区表。对于大表的访问,可采取分片方式处理。",
"rule_name":"BIG_TABLE_BY_SIZE",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_status":"ON",
"rule_summary":"超过指定规模且没有分区的表",
"rule_type":"OBJ",
"solution":[
"1.建议分库,分表,分区",
"2.历史数据归档"
],
"weight":NumberInt(1)
}
{
"_id":ObjectId("5b61644153cc7e049902d167"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"表个数",
"parm_name":"table_size",
"parm_value":NumberInt(5000),
"parm_unit":""
}
],
"max_score":NumberInt(1),
"output_parms":[
{
"parm_desc":"库名称",
"parm_name":"title1"
},
{
"parm_desc":"数据表个数",
"parm_name":"title2"
}
],
"rule_desc":"单库数据表过多,将影响整体性能。必要时,进行业务逻辑的垂直拆分。",
"rule_name":"BIG_SCHEMA_BY_TABLE_NUM",
"rule_complexity":"complex",
"rule_cmd":"default",
"rule_status":"ON",
"rule_summary":"单库数据表过多",
"rule_type":"OBJ",
"solution":[
"1.建议分库,分表,分区",
"2.历史数据归档"
],
"weight":NumberInt(1)
}
{
"_id":ObjectId("5b61644153cc7e049902d168"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"数据量规模",
"parm_name":"row_num",
"parm_value":NumberInt(20000000),
"parm_unit":""
}
],
"max_score":NumberInt(10),
"output_parms":[
{
"parm_desc":"表(分区)名称",
"parm_name":"title1"
},
{
"parm_desc":"记录数",
"parm_name":"title2"
}
],
"rule_desc":"单表(分区)数据表过多,将影响整体性能。必要时,进行分库、分表或定期清理、归档数据。",
"rule_complexity":"simple",
"rule_cmd":"select table_name,table_rows from information_schema.tables where table_schema='@username@' and CREATE_OPTIONS<>'partitioned' and table_rows>@row_num@ union all select concat(table_name,':',partition_name),table_rows from information_schema.partitions where table_schema='@username@' and table_name not in (select table_name from information_schema.tables where table_schema='@username@' and CREATE_OPTIONS<>'partitioned') and table_rows>@row_num@",
"rule_name":"BIG_TABLE_BY_ROW_NUM",
"rule_status":"ON",
"rule_summary":"单表(分区)数据量过大",
"rule_type":"OBJ",
"solution":[
"1.建议分库,分表,分区",
"2.历史数据归档"
],
"weight":NumberInt(1)
}
{
"_id":ObjectId("5b61644153cc7e049902d169"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"选择率百分比<br>(接近100最好)",
"parm_name":"selectivity",
"parm_value":0.001,
"parm_unit":""
}
],
"max_score":NumberInt(10),
"output_parms":[
{
"parm_desc":"表名",
"parm_name":"title1"
},
{
"parm_desc":"索引名",
"parm_name":"title2"
},
{
"parm_desc":"索引唯一值数量",
"parm_name":"title3"
},
{
"parm_desc":"表记录数",
"parm_name":"title4"
},
{
"parm_desc":"索引选择率(~100%,越高越好)",
"parm_name":"title5"
}
],
"rule_desc":"索引选择率不高,将导致索引低效,请调整索引字段。",
"rule_cmd":"default",
"rule_complexity":"complex",
"rule_name":"INDEX_SELECTIVITY",
"rule_status":"ON",
"rule_summary":"索引选择率不高",
"rule_type":"OBJ",
"solution":[
"调整索引字段,索引是否合理"
],
"weight":NumberInt(1)
}
{
"_id":ObjectId("5b61644153cc7e049902d16a"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
],
"max_score":NumberInt(20),
"output_parms":[
{
"parm_desc":"表名称",
"parm_name":"title1"
},
{
"parm_desc":"外键名",
"parm_name":"title2"
}
],
"rule_desc":"外键资源将消耗数据库的计算能力,建议通过应用层保证数据约束。",
"rule_complexity":"simple",
"rule_cmd":"select table_name,constraint_name from information_schema.table_constraints where CONSTRAINT_SCHEMA='@username@' and table_schema='@username@' and constraint_type='FOREIGN KEY'",
"rule_name":"TABLE_EXIST_FOREIGN_KEY",
"rule_status":"ON",
"rule_summary":"单表存在外键",
"rule_type":"OBJ",
"solution":[
"应用程序实现外键约束,删除表的外键约束"
],
"weight":NumberInt(5)
}
{
"_id":ObjectId("5b61644153cc7e049902d16b"),
"db_type":"mysql",
"exclude_obj_type":"",
"input_parms":[
{
"parm_desc":"索引数量",
"parm_name":"index_num",
"parm_value":NumberInt(7),
"parm_unit":""
}
],
"max_score":NumberInt(10),
"output_parms":[
{
"parm_desc":"表名称",
"parm_name":"title1"
},
{
"parm_desc":"索引数量",
"parm_name":"title2"
}
],
"rule_desc":"单表索引数量过多,不仅维护成本高,而且占用更多的空间。",
"rule_complexity":"simple",
"rule_cmd":"select * from (select table_name,count(distinct index_name) cnt from information_schema.STATISTICS where table_schema='@username@' and index_name<>'PRIMARY' group by table_name) v where cnt>@index_num@",
"rule_name":"BIG_TABLE_BY_INDEX_NUM",
"rule_status":"ON",
"rule_summary":"单表索引数量过多",
"rule_type":"OBJ",
"solution":[
"构建战略性索引结构,不要针对每个需求都通过创建索引解决"
],
"weight":NumberInt(2)
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

Archery 定位于 SQL 审核查询平台,旨在提升 DBA 的工作效率,支持多种数据库的 SQL 上线和查询,同时支持丰富的 MySQL 运维功能
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/CN_python/Archery.git
git@gitee.com:CN_python/Archery.git
CN_python
Archery
Archery
master
点此查找更多帮助

搜索帮助

仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /