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 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484
|
# The MariaDB sys schema
A collection of views, functions and procedures to help MariaDB administrators get insight into MariaDB Database usage.
There are install files available. To load these, you must position yourself within the directory that you downloaded to, as these top level files SOURCE individual files that are shared across versions in most cases (though not all).
## Overview of objects
### Tables
#### sys_config
##### Description
Holds configuration options for the sys schema. This is a persistent table, with the configuration persisting across upgrades (new options are added with `INSERT IGNORE`).
Its structure is as follows:
```SQL
+----------+--------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+-------------------+-----------------------------+
| variable | varchar(128) | NO | PRI | NULL | |
| value | varchar(128) | YES | | NULL | |
| set_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| set_by | varchar(128) | YES | | NULL | |
+----------+--------------+------+-----+-------------------+-----------------------------+
```
Note, when functions check for configuration options, they first check whether a similar named user variable exists with a value, and if this is not set then pull the configuration option from this table in to that named user variable. This is done for performance reasons (to not continually `SELECT` from the table), however this comes with the side effect that once inited, the values last with the session, somewhat like how session variables are inited from global variables. If the values within this table are changed, they will not take effect until the user logs in again.
##### Options included
| Variable | Default Value | Description |
| ------------------------------------ | ------------- | ------------------------------------------------------------------------------ |
| statement_truncate_len | 64 | Sets the size to truncate statements to, for the `format_statement()` function. |
| statement_performance_analyzer.limit | 100 | The maximum number of rows to include for the views that does not have a built-in limit (e.g. the 95th percentile view). If not set the limit is 100. |
| statement_performance_analyzer.view | NULL | Used together with the 'custom' view. If the value contains a space, it is considered a query, otherwise it must be an existing view querying the performance_schema.events_statements_summary_by_digest table. |
| diagnostics.allow_i_s_tables | OFF | Specifies whether it is allowed to do table scan queries on information_schema.TABLES for the `diagnostics` procedure. |
| diagnostics.include_raw | OFF | Set to 'ON' to include the raw data (e.g. the original output of "SELECT * FROM sys.metrics") for the `diagnostics` procedure.|
| ps_thread_trx_info.max_length | 65535 | Sets the maximum output length for JSON object output by the `ps_thread_trx_info()` function. |
### Views
Many of the views in the sys schema have both a command line user friendly format output, as well as tooling friendly versions of any view that contains formatted output duplicated as an x$ table.
The examples below show output for only the formatted views, and note where there is an x$ counterpart available.
#### host_summary / x$host_summary
##### Description
Summarizes statement activity, file IO and connections by host.
When the host found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc host_summary;
+------------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+---------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| statements | decimal(64,0) | YES | | NULL | |
| statement_latency | text | YES | | NULL | |
| statement_avg_latency | text | YES | | NULL | |
| table_scans | decimal(65,0) | YES | | NULL | |
| file_ios | decimal(64,0) | YES | | NULL | |
| file_io_latency | text | YES | | NULL | |
| current_connections | decimal(41,0) | YES | | NULL | |
| total_connections | decimal(41,0) | YES | | NULL | |
| unique_users | bigint(21) | NO | | 0 | |
| current_memory | text | YES | | NULL | |
| total_memory_allocated | text | YES | | NULL | |
+------------------------+---------------+------+-----+---------+-------+
12 rows in set (0.15 sec)
mariadb> desc x$host_summary;
+------------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+---------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| statements | decimal(64,0) | YES | | NULL | |
| statement_latency | decimal(64,0) | YES | | NULL | |
| statement_avg_latency | decimal(65,4) | YES | | NULL | |
| table_scans | decimal(65,0) | YES | | NULL | |
| file_ios | decimal(64,0) | YES | | NULL | |
| file_io_latency | decimal(64,0) | YES | | NULL | |
| current_connections | decimal(41,0) | YES | | NULL | |
| total_connections | decimal(41,0) | YES | | NULL | |
| unique_users | bigint(21) | NO | | 0 | |
| current_memory | decimal(63,0) | YES | | NULL | |
| total_memory_allocated | decimal(64,0) | YES | | NULL | |
+------------------------+---------------+------+-----+---------+-------+
12 rows in set (0.00 sec)
```
##### Example
```SQL
mariadb> select * from host_summary;
+------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+
| host | statements | statement_latency | statement_avg_latency | table_scans | file_ios | file_io_latency | current_connections | total_connections | unique_users |
+------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+
| hal1 | 2924 | 00:03:59.53 | 81.92 ms | 82 | 54702 | 55.61 s | 1 | 1 | 1 |
+------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+
```
#### host_summary_by_file_io / x$host_summary_by_file_io
##### Description
Summarizes file IO totals per host.
When the host found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc host_summary_by_file_io;
+------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| ios | decimal(42,0) | YES | | NULL | |
| io_latency | text | YES | | NULL | |
+------------+---------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mariadb> desc x$host_summary_by_file_io;
+------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| ios | decimal(42,0) | YES | | NULL | |
| io_latency | decimal(42,0) | YES | | NULL | |
+------------+---------------+------+-----+---------+-------+
3 rows in set (0.06 sec)
```
##### Example
```SQL
mariadb> select * from host_summary_by_file_io;
+------------+-------+------------+
| host | ios | io_latency |
+------------+-------+------------+
| hal1 | 26457 | 21.58 s |
| hal2 | 1189 | 394.21 ms |
+------------+-------+------------+
```
#### host_summary_by_file_io_type / x$host_summary_by_file_io_type
##### Description
Summarizes file IO by event type per host.
When the host found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc host_summary_by_file_io_type;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| event_name | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
5 rows in set (0.70 sec)
mariadb> desc x$host_summary_by_file_io_type;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| event_name | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
5 rows in set (0.01 sec)
```
##### Example
```SQL
mariadb> select * from host_summary_by_file_io_type;
+------------+--------------------------------------+-------+---------------+-------------+
| host | event_name | total | total_latency | max_latency |
+------------+--------------------------------------+-------+---------------+-------------+
| hal1 | wait/io/file/sql/FRM | 871 | 168.15 ms | 18.48 ms |
| hal1 | wait/io/file/innodb/innodb_data_file | 173 | 129.56 ms | 34.09 ms |
| hal1 | wait/io/file/innodb/innodb_log_file | 20 | 77.53 ms | 60.66 ms |
| hal1 | wait/io/file/myisam/dfile | 40 | 6.54 ms | 4.58 ms |
| hal1 | wait/io/file/mysys/charset | 3 | 4.79 ms | 4.71 ms |
| hal1 | wait/io/file/myisam/kfile | 67 | 4.38 ms | 300.04 us |
| hal1 | wait/io/file/sql/ERRMSG | 5 | 2.72 ms | 1.69 ms |
| hal1 | wait/io/file/sql/pid | 3 | 266.30 us | 185.47 us |
| hal1 | wait/io/file/sql/casetest | 5 | 246.81 us | 150.19 us |
| hal1 | wait/io/file/sql/global_ddl_log | 2 | 21.24 us | 18.59 us |
| hal2 | wait/io/file/sql/file_parser | 1422 | 4.80 s | 135.14 ms |
| hal2 | wait/io/file/sql/FRM | 865 | 85.82 ms | 9.81 ms |
| hal2 | wait/io/file/myisam/kfile | 1073 | 37.14 ms | 15.79 ms |
| hal2 | wait/io/file/myisam/dfile | 2991 | 25.53 ms | 5.25 ms |
| hal2 | wait/io/file/sql/dbopt | 20 | 1.07 ms | 153.07 us |
| hal2 | wait/io/file/sql/misc | 4 | 59.71 us | 33.75 us |
| hal2 | wait/io/file/archive/data | 1 | 13.91 us | 13.91 us |
+------------+--------------------------------------+-------+---------------+-------------+
```
#### host_summary_by_stages / x$host_summary_by_stages
##### Description
Summarizes stages by host, ordered by host and total latency per stage.
When the host found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc host_summary_by_stages;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| event_name | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
5 rows in set (0.06 sec)
mariadb> desc x$host_summary_by_stages;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| event_name | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| avg_latency | bigint(20) unsigned | NO | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
5 rows in set (0.81 sec)
```
##### Example
```SQL
mariadb> select * from host_summary_by_stages;
+------+--------------------------------+-------+---------------+-------------+
| host | event_name | total | total_latency | avg_latency |
+------+--------------------------------+-------+---------------+-------------+
| hal | stage/sql/Opening tables | 889 | 1.97 ms | 2.22 us |
| hal | stage/sql/Creating sort index | 4 | 1.79 ms | 446.30 us |
| hal | stage/sql/init | 10 | 312.27 us | 31.23 us |
| hal | stage/sql/checking permissions | 10 | 300.62 us | 30.06 us |
| hal | stage/sql/freeing items | 5 | 85.89 us | 17.18 us |
| hal | stage/sql/statistics | 5 | 79.15 us | 15.83 us |
| hal | stage/sql/preparing | 5 | 69.12 us | 13.82 us |
| hal | stage/sql/optimizing | 5 | 53.11 us | 10.62 us |
| hal | stage/sql/Sending data | 5 | 44.66 us | 8.93 us |
| hal | stage/sql/closing tables | 5 | 37.54 us | 7.51 us |
| hal | stage/sql/System lock | 5 | 34.28 us | 6.86 us |
| hal | stage/sql/query end | 5 | 24.37 us | 4.87 us |
| hal | stage/sql/end | 5 | 8.60 us | 1.72 us |
| hal | stage/sql/Sorting result | 5 | 8.33 us | 1.67 us |
| hal | stage/sql/executing | 5 | 5.37 us | 1.07 us |
| hal | stage/sql/cleaning up | 5 | 4.60 us | 919.00 ns |
+------+--------------------------------+-------+---------------+-------------+
```
#### host_summary_by_statement_latency / x$host_summary_by_statement_latency
##### Description
Summarizes overall statement statistics by host.
When the host found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc host_summary_by_statement_latency;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| total | decimal(42,0) | YES | | NULL | |
| total_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
| lock_latency | text | YES | | NULL | |
| rows_sent | decimal(42,0) | YES | | NULL | |
| rows_examined | decimal(42,0) | YES | | NULL | |
| rows_affected | decimal(42,0) | YES | | NULL | |
| full_scans | decimal(43,0) | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
9 rows in set (0.29 sec)
mariadb> desc x$host_summary_by_statement_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| total | decimal(42,0) | YES | | NULL | |
| total_latency | decimal(42,0) | YES | | NULL | |
| max_latency | bigint(20) unsigned | YES | | NULL | |
| lock_latency | decimal(42,0) | YES | | NULL | |
| rows_sent | decimal(42,0) | YES | | NULL | |
| rows_examined | decimal(42,0) | YES | | NULL | |
| rows_affected | decimal(42,0) | YES | | NULL | |
| full_scans | decimal(43,0) | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
9 rows in set (0.00 sec)
```
##### Example
```SQL
mariadb> select * from host_summary_by_statement_latency;
+------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
| host | total | total_latency | max_latency | lock_latency | rows_sent | rows_examined | rows_affected | full_scans |
+------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
| hal | 3381 | 00:02:09.13 | 1.48 s | 1.07 s | 1151 | 93947 | 150 | 91 |
+------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
```
#### host_summary_by_statement_type / x$host_summary_by_statement_type
##### Description
Summarizes the types of statements executed by each host.
When the host found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc host_summary_by_statement_type;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| statement | varchar(128) | YES | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
| lock_latency | text | YES | | NULL | |
| rows_sent | bigint(20) unsigned | NO | | NULL | |
| rows_examined | bigint(20) unsigned | NO | | NULL | |
| rows_affected | bigint(20) unsigned | NO | | NULL | |
| full_scans | bigint(21) unsigned | NO | | 0 | |
+---------------+---------------------+------+-----+---------+-------+
10 rows in set (0.30 sec)
mariadb> desc x$host_summary_by_statement_type;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| statement | varchar(128) | YES | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
| lock_latency | bigint(20) unsigned | NO | | NULL | |
| rows_sent | bigint(20) unsigned | NO | | NULL | |
| rows_examined | bigint(20) unsigned | NO | | NULL | |
| rows_affected | bigint(20) unsigned | NO | | NULL | |
| full_scans | bigint(21) unsigned | NO | | 0 | |
+---------------+---------------------+------+-----+---------+-------+
10 rows in set (0.76 sec)
```
##### Example
```SQL
mariadb> select * from host_summary_by_statement_type;
+------+----------------------+--------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
| host | statement | total | total_latency | max_latency | lock_latency | rows_sent | rows_examined | rows_affected | full_scans |
+------+----------------------+--------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
| hal | create_view | 2063 | 00:05:04.20 | 463.58 ms | 1.42 s | 0 | 0 | 0 | 0 |
| hal | select | 174 | 40.87 s | 28.83 s | 858.13 ms | 5212 | 157022 | 0 | 82 |
| hal | stmt | 6645 | 15.31 s | 491.78 ms | 0 ps | 0 | 0 | 7951 | 0 |
| hal | call_procedure | 17 | 4.78 s | 1.02 s | 37.94 ms | 0 | 0 | 19 | 0 |
| hal | create_table | 19 | 3.04 s | 431.71 ms | 0 ps | 0 | 0 | 0 | 0 |
...
+------+----------------------+--------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
```
#### innodb_buffer_stats_by_schema / x$innodb_buffer_stats_by_schema
##### Description
Summarizes the output of the INFORMATION_SCHEMA.INNODB_BUFFER_PAGE table, aggregating by schema.
##### Structures
```SQL
mariadb> desc innodb_buffer_stats_by_schema;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| object_schema | text | YES | | NULL | |
| allocated | text | YES | | NULL | |
| data | text | YES | | NULL | |
| pages | bigint(21) | NO | | 0 | |
| pages_hashed | bigint(21) | NO | | 0 | |
| pages_old | bigint(21) | NO | | 0 | |
| rows_cached | decimal(44,0) | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
7 rows in set (0.08 sec)
mariadb> desc x$innodb_buffer_stats_by_schema;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| object_schema | text | YES | | NULL | |
| allocated | decimal(43,0) | YES | | NULL | |
| data | decimal(43,0) | YES | | NULL | |
| pages | bigint(21) | NO | | 0 | |
| pages_hashed | bigint(21) | NO | | 0 | |
| pages_old | bigint(21) | NO | | 0 | |
| rows_cached | decimal(44,0) | NO | | 0 | |
+---------------+---------------+------+-----+---------+-------+
7 rows in set (0.12 sec)
````
##### Example
```SQL
mariadb> select * from innodb_buffer_stats_by_schema;
+--------------------------+------------+------------+-------+--------------+-----------+-------------+
| object_schema | allocated | data | pages | pages_hashed | pages_old | rows_cached |
+--------------------------+------------+------------+-------+--------------+-----------+-------------+
| mem30_trunk__instruments | 1.69 MiB | 510.03 KiB | 108 | 108 | 108 | 3885 |
| InnoDB System | 688.00 KiB | 351.62 KiB | 43 | 43 | 43 | 862 |
| mem30_trunk__events | 80.00 KiB | 21.61 KiB | 5 | 5 | 5 | 229 |
+--------------------------+------------+------------+-------+--------------+-----------+-------------+
```
#### innodb_buffer_stats_by_table / x$innodb_buffer_stats_by_table
##### Description
Summarizes the output of the INFORMATION_SCHEMA.INNODB_BUFFER_PAGE table, aggregating by schema and table name.
##### Structures
```SQL
mariadb> desc innodb_buffer_stats_by_table;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| object_schema | text | YES | | NULL | |
| object_name | text | YES | | NULL | |
| allocated | text | YES | | NULL | |
| data | text | YES | | NULL | |
| pages | bigint(21) | NO | | 0 | |
| pages_hashed | bigint(21) | NO | | 0 | |
| pages_old | bigint(21) | NO | | 0 | |
| rows_cached | decimal(44,0) | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
8 rows in set (0.09 sec)
mariadb> desc x$innodb_buffer_stats_by_table;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| object_schema | text | YES | | NULL | |
| object_name | text | YES | | NULL | |
| allocated | decimal(43,0) | YES | | NULL | |
| data | decimal(43,0) | YES | | NULL | |
| pages | bigint(21) | NO | | 0 | |
| pages_hashed | bigint(21) | NO | | 0 | |
| pages_old | bigint(21) | NO | | 0 | |
| rows_cached | decimal(44,0) | NO | | 0 | |
+---------------+---------------+------+-----+---------+-------+
8 rows in set (0.18 sec)
```
##### Example
```SQL
mariadb> select * from innodb_buffer_stats_by_table;
+--------------------------+------------------------------------+------------+-----------+-------+--------------+-----------+-------------+
| object_schema | object_name | allocated | data | pages | pages_hashed | pages_old | rows_cached |
+--------------------------+------------------------------------+------------+-----------+-------+--------------+-----------+-------------+
| InnoDB System | SYS_COLUMNS | 128.00 KiB | 98.97 KiB | 8 | 8 | 8 | 1532 |
| InnoDB System | SYS_FOREIGN | 128.00 KiB | 55.48 KiB | 8 | 8 | 8 | 172 |
| InnoDB System | SYS_TABLES | 128.00 KiB | 56.18 KiB | 8 | 8 | 8 | 365 |
| InnoDB System | SYS_INDEXES | 112.00 KiB | 76.16 KiB | 7 | 7 | 7 | 1046 |
| mem30_trunk__instruments | agentlatencytime | 96.00 KiB | 28.83 KiB | 6 | 6 | 6 | 252 |
| mem30_trunk__instruments | binlogspaceusagedata | 96.00 KiB | 22.54 KiB | 6 | 6 | 6 | 196 |
| mem30_trunk__instruments | connectionsdata | 96.00 KiB | 36.68 KiB | 6 | 6 | 6 | 276 |
| mem30_trunk__instruments | connectionsmaxdata | 96.00 KiB | 31.88 KiB | 6 | 6 | 6 | 271 |
| mem30_trunk__instruments | cpuaverage | 96.00 KiB | 14.32 KiB | 6 | 6 | 6 | 55 |
| mem30_trunk__instruments | diskiototaldata | 96.00 KiB | 42.71 KiB | 6 | 6 | 6 | 152 |
| mem30_trunk__instruments | innodbopenfilesdata | 96.00 KiB | 32.61 KiB | 6 | 6 | 6 | 266 |
| mem30_trunk__instruments | innodbrowlocktimestatisticsdata | 96.00 KiB | 32.16 KiB | 6 | 6 | 6 | 261 |
| mem30_trunk__instruments | myisamkeybufferusagedata | 96.00 KiB | 25.99 KiB | 6 | 6 | 6 | 232 |
| mem30_trunk__instruments | mysqlprocessactivity | 96.00 KiB | 31.99 KiB | 6 | 6 | 6 | 252 |
| mem30_trunk__instruments | querycacheaveragefreeblocksizedata | 96.00 KiB | 27.00 KiB | 6 | 6 | 6 | 237 |
| mem30_trunk__instruments | querycacheaveragequerysizedata | 96.00 KiB | 38.29 KiB | 6 | 6 | 6 | 315 |
| mem30_trunk__instruments | querycachefragmentationdata | 96.00 KiB | 27.00 KiB | 6 | 6 | 6 | 237 |
| mem30_trunk__instruments | querycachememorydata | 96.00 KiB | 32.58 KiB | 6 | 6 | 6 | 278 |
| mem30_trunk__instruments | querycachequeriesincachedata | 96.00 KiB | 27.15 KiB | 6 | 6 | 6 | 238 |
| mem30_trunk__instruments | ramusagedata | 96.00 KiB | 15.02 KiB | 6 | 6 | 6 | 59 |
| mem30_trunk__instruments | slaverelaylogspaceusagedata | 96.00 KiB | 28.28 KiB | 6 | 6 | 6 | 249 |
| mem30_trunk__instruments | swapusagedata | 96.00 KiB | 15.02 KiB | 6 | 6 | 6 | 59 |
| InnoDB System | SYS_FIELDS | 80.00 KiB | 49.78 KiB | 5 | 5 | 5 | 1147 |
| InnoDB System | SYS_DATAFILES | 32.00 KiB | 3.97 KiB | 2 | 2 | 2 | 60 |
| InnoDB System | SYS_FOREIGN_COLS | 32.00 KiB | 7.43 KiB | 2 | 2 | 2 | 83 |
| InnoDB System | SYS_TABLESPACES | 32.00 KiB | 3.65 KiB | 2 | 2 | 2 | 56 |
| InnoDB System | SYS_IBUF_TABLE | 16.00 KiB | 0 bytes | 1 | 1 | 1 | 0 |
+--------------------------+------------------------------------+------------+-----------+-------+--------------+-----------+-------------+
```
#### innodb_lock_waits / x$innodb_lock_waits
##### Description
Gives a snapshot of which InnoDB locks transactions are waiting for.
The lock waits are ordered by the age of the lock descending.
##### Structures
```SQL
mariadb> desc sys.innodb_lock_waits;
+------------------------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------------+---------------------+------+-----+---------------------+-------+
| wait_started | datetime | YES | | NULL | |
| wait_age | time | YES | | NULL | |
| wait_age_secs | bigint(21) | YES | | NULL | |
| locked_table | varchar(1024) | NO | | | |
| locked_index | varchar(1024) | YES | | NULL | |
| locked_type | varchar(32) | NO | | | |
| waiting_trx_id | varchar(18) | NO | | | |
| waiting_trx_started | datetime | NO | | 0000-00-00 00:00:00 | |
| waiting_trx_age | time | YES | | NULL | |
| waiting_trx_rows_locked | bigint(21) unsigned | NO | | 0 | |
| waiting_trx_rows_modified | bigint(21) unsigned | NO | | 0 | |
| waiting_pid | bigint(21) unsigned | NO | | 0 | |
| waiting_query | longtext | YES | | NULL | |
| waiting_lock_id | varchar(81) | NO | | | |
| waiting_lock_mode | varchar(32) | NO | | | |
| blocking_trx_id | varchar(18) | NO | | | |
| blocking_pid | bigint(21) unsigned | NO | | 0 | |
| blocking_query | longtext | YES | | NULL | |
| blocking_lock_id | varchar(81) | NO | | | |
| blocking_lock_mode | varchar(32) | NO | | | |
| blocking_trx_started | datetime | NO | | 0000-00-00 00:00:00 | |
| blocking_trx_age | time | YES | | NULL | |
| blocking_trx_rows_locked | bigint(21) unsigned | NO | | 0 | |
| blocking_trx_rows_modified | bigint(21) unsigned | NO | | 0 | |
| sql_kill_blocking_query | varchar(32) | YES | | NULL | |
| sql_kill_blocking_connection | varchar(26) | YES | | NULL | |
+------------------------------+---------------------+------+-----+---------------------+-------+
26 rows in set (0.01 sec)
mariadb> desc sys.x$innodb_lock_waits;
+------------------------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------------+---------------------+------+-----+---------------------+-------+
| wait_started | datetime | YES | | NULL | |
| wait_age | time | YES | | NULL | |
| wait_age_secs | bigint(21) | YES | | NULL | |
| locked_table | varchar(1024) | NO | | | |
| locked_index | varchar(1024) | YES | | NULL | |
| locked_type | varchar(32) | NO | | | |
| waiting_trx_id | varchar(18) | NO | | | |
| waiting_trx_started | datetime | NO | | 0000-00-00 00:00:00 | |
| waiting_trx_age | time | YES | | NULL | |
| waiting_trx_rows_locked | bigint(21) unsigned | NO | | 0 | |
| waiting_trx_rows_modified | bigint(21) unsigned | NO | | 0 | |
| waiting_pid | bigint(21) unsigned | NO | | 0 | |
| waiting_query | varchar(1024) | YES | | NULL | |
| waiting_lock_id | varchar(81) | NO | | | |
| waiting_lock_mode | varchar(32) | NO | | | |
| blocking_trx_id | varchar(18) | NO | | | |
| blocking_pid | bigint(21) unsigned | NO | | 0 | |
| blocking_query | varchar(1024) | YES | | NULL | |
| blocking_lock_id | varchar(81) | NO | | | |
| blocking_lock_mode | varchar(32) | NO | | | |
| blocking_trx_started | datetime | NO | | 0000-00-00 00:00:00 | |
| blocking_trx_age | time | YES | | NULL | |
| blocking_trx_rows_locked | bigint(21) unsigned | NO | | 0 | |
| blocking_trx_rows_modified | bigint(21) unsigned | NO | | 0 | |
| sql_kill_blocking_query | varchar(32) | YES | | NULL | |
| sql_kill_blocking_connection | varchar(26) | YES | | NULL | |
+------------------------------+---------------------+------+-----+---------------------+-------+
26 rows in set (0.02 sec)
```
##### Example
```SQL
mariadb> SELECT * FROM innodb_lock_waits\G
*************************** 1. row ***************************
wait_started: 2014-11-11 13:39:20
wait_age: 00:00:07
wait_age_secs: 7
locked_table: `db1`.`t1`
locked_index: PRIMARY
locked_type: RECORD
waiting_trx_id: 867158
waiting_trx_started: 2014-11-11 13:39:15
waiting_trx_age: 00:00:12
waiting_trx_rows_locked: 0
waiting_trx_rows_modified: 0
waiting_pid: 3
waiting_query: UPDATE t1 SET val = val + 1 WHERE id = 2
waiting_lock_id: 867158:2363:3:3
waiting_lock_mode: X
blocking_trx_id: 867157
blocking_pid: 4
blocking_query: UPDATE t1 SET val = val + 1 + SLEEP(10) WHERE id = 2
blocking_lock_id: 867157:2363:3:3
blocking_lock_mode: X
blocking_trx_started: 2014-11-11 13:39:11
blocking_trx_age: 00:00:16
blocking_trx_rows_locked: 1
blocking_trx_rows_modified: 1
sql_kill_blocking_query: KILL QUERY 4
sql_kill_blocking_connection: KILL 4
```
#### io_by_thread_by_latency / x$io_by_thread_by_latency
##### Description
Shows the top IO consumers by thread, ordered by total latency.
##### Structures
```SQL
mariadb> desc io_by_thread_by_latency;
+----------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+---------+-------+
| user | varchar(128) | YES | | NULL | |
| total | decimal(42,0) | YES | | NULL | |
| total_latency | text | YES | | NULL | |
| min_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
| thread_id | bigint(20) unsigned | NO | | NULL | |
| processlist_id | bigint(20) unsigned | YES | | NULL | |
+----------------+---------------------+------+-----+---------+-------+
8 rows in set (0.14 sec)
mariadb> desc x$io_by_thread_by_latency;
+----------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+---------+-------+
| user | varchar(128) | YES | | NULL | |
| total | decimal(42,0) | YES | | NULL | |
| total_latency | decimal(42,0) | YES | | NULL | |
| min_latency | bigint(20) unsigned | YES | | NULL | |
| avg_latency | decimal(24,4) | YES | | NULL | |
| max_latency | bigint(20) unsigned | YES | | NULL | |
| thread_id | bigint(20) unsigned | NO | | NULL | |
| processlist_id | bigint(20) unsigned | YES | | NULL | |
+----------------+---------------------+------+-----+---------+-------+
8 rows in set (0.03 sec)
```
##### Example
```SQL
mariadb> select * from io_by_thread_by_latency;
+---------------------+-------+---------------+-------------+-------------+-------------+-----------+----------------+
| user | total | total_latency | min_latency | avg_latency | max_latency | thread_id | processlist_id |
+---------------------+-------+---------------+-------------+-------------+-------------+-----------+----------------+
| root@localhost | 11580 | 18.01 s | 429.78 ns | 1.12 ms | 181.07 ms | 25 | 6 |
| main | 1358 | 1.31 s | 475.02 ns | 2.27 ms | 350.70 ms | 1 | NULL |
| page_cleaner | 654 | 147.44 ms | 588.12 ns | 225.44 us | 46.41 ms | 18 | NULL |
| io_write_thread | 131 | 107.75 ms | 8.60 us | 822.55 us | 27.69 ms | 8 | NULL |
| io_write_thread | 46 | 47.07 ms | 10.64 us | 1.02 ms | 16.90 ms | 9 | NULL |
| io_write_thread | 71 | 46.99 ms | 9.11 us | 661.81 us | 17.04 ms | 11 | NULL |
| io_log_thread | 20 | 21.01 ms | 14.25 us | 1.05 ms | 7.08 ms | 3 | NULL |
| srv_master_thread | 13 | 17.60 ms | 8.49 us | 1.35 ms | 9.99 ms | 16 | NULL |
| srv_purge_thread | 4 | 1.81 ms | 34.31 us | 452.45 us | 1.02 ms | 17 | NULL |
| io_write_thread | 19 | 951.39 us | 9.75 us | 50.07 us | 297.47 us | 10 | NULL |
| signal_handler | 3 | 218.03 us | 21.64 us | 72.68 us | 154.84 us | 19 | NULL |
+---------------------+-------+---------------+-------------+-------------+-------------+-----------+----------------+
```
#### io_global_by_file_by_bytes / x$io_global_by_file_by_bytes
##### Description
Shows the top global IO consumers by bytes usage by file.
##### Structures
```SQL
mariadb> desc io_global_by_file_by_bytes;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| file | varchar(512) | YES | | NULL | |
| count_read | bigint(20) unsigned | NO | | NULL | |
| total_read | text | YES | | NULL | |
| avg_read | text | YES | | NULL | |
| count_write | bigint(20) unsigned | NO | | NULL | |
| total_written | text | YES | | NULL | |
| avg_write | text | YES | | NULL | |
| total | text | YES | | NULL | |
| write_pct | decimal(26,2) | NO | | 0.00 | |
+---------------+---------------------+------+-----+---------+-------+
9 rows in set (0.15 sec)
mariadb> desc x$io_global_by_file_by_bytes;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| file | varchar(512) | NO | | NULL | |
| count_read | bigint(20) unsigned | NO | | NULL | |
| total_read | bigint(20) | NO | | NULL | |
| avg_read | decimal(23,4) | NO | | 0.0000 | |
| count_write | bigint(20) unsigned | NO | | NULL | |
| total_written | bigint(20) | NO | | NULL | |
| avg_write | decimal(23,4) | NO | | 0.0000 | |
| total | bigint(21) | NO | | 0 | |
| write_pct | decimal(26,2) | NO | | 0.00 | |
+---------------+---------------------+------+-----+---------+-------+
9 rows in set (0.14 sec)
```
##### Example
```SQL
mariadb> SELECT * FROM io_global_by_file_by_bytes LIMIT 5;
+--------------------------------------------+------------+------------+-----------+-------------+---------------+-----------+------------+-----------+
| file | count_read | total_read | avg_read | count_write | total_written | avg_write | total | write_pct |
+--------------------------------------------+------------+------------+-----------+-------------+---------------+-----------+------------+-----------+
| @@datadir/ibdata1 | 147 | 4.27 MiB | 29.71 KiB | 3 | 48.00 KiB | 16.00 KiB | 4.31 MiB | 1.09 |
| @@datadir/mysql/proc.MYD | 347 | 85.35 KiB | 252 bytes | 111 | 19.08 KiB | 176 bytes | 104.43 KiB | 18.27 |
| @@datadir/ib_logfile0 | 6 | 68.00 KiB | 11.33 KiB | 8 | 4.00 KiB | 512 bytes | 72.00 KiB | 5.56 |
| /opt/mysql/5.5.33/share/english/errmsg.sys | 3 | 43.68 KiB | 14.56 KiB | 0 | 0 bytes | 0 bytes | 43.68 KiB | 0.00 |
| /opt/mysql/5.5.33/share/charsets/Index.xml | 1 | 17.89 KiB | 17.89 KiB | 0 | 0 bytes | 0 bytes | 17.89 KiB | 0.00 |
+--------------------------------------------+------------+------------+-----------+-------------+---------------+-----------+------------+-----------+
```
#### io_global_by_file_by_latency / x$io_global_by_file_by_latency
##### Description
Shows the top global IO consumers by latency by file.
##### Structures
```SQL
mariadb> desc io_global_by_file_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| file | varchar(512) | YES | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| count_read | bigint(20) unsigned | NO | | NULL | |
| read_latency | text | YES | | NULL | |
| count_write | bigint(20) unsigned | NO | | NULL | |
| write_latency | text | YES | | NULL | |
| count_misc | bigint(20) unsigned | NO | | NULL | |
| misc_latency | text | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
9 rows in set (0.00 sec)
mariadb> desc x$io_global_by_file_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| file | varchar(512) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| count_read | bigint(20) unsigned | NO | | NULL | |
| read_latency | bigint(20) unsigned | NO | | NULL | |
| count_write | bigint(20) unsigned | NO | | NULL | |
| write_latency | bigint(20) unsigned | NO | | NULL | |
| count_misc | bigint(20) unsigned | NO | | NULL | |
| misc_latency | bigint(20) unsigned | NO | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
9 rows in set (0.07 sec)
```
##### Example
```SQL
mariadb> select * from io_global_by_file_by_latency limit 5;
+-----------------------------------------------------------+-------+---------------+------------+--------------+-------------+---------------+------------+--------------+
| file | total | total_latency | count_read | read_latency | count_write | write_latency | count_misc | misc_latency |
+-----------------------------------------------------------+-------+---------------+------------+--------------+-------------+---------------+------------+--------------+
| @@datadir/sys/wait_classes_global_by_avg_latency_raw.frm~ | 24 | 451.99 ms | 0 | 0 ps | 4 | 108.07 us | 20 | 451.88 ms |
| @@datadir/sys/innodb_buffer_stats_by_schema_raw.frm~ | 24 | 379.84 ms | 0 | 0 ps | 4 | 108.88 us | 20 | 379.73 ms |
| @@datadir/sys/io_by_thread_by_latency_raw.frm~ | 24 | 379.46 ms | 0 | 0 ps | 4 | 101.37 us | 20 | 379.36 ms |
| @@datadir/ibtmp1 | 53 | 373.45 ms | 0 | 0 ps | 48 | 246.08 ms | 5 | 127.37 ms |
| @@datadir/sys/statement_analysis_raw.frm~ | 24 | 353.14 ms | 0 | 0 ps | 4 | 94.96 us | 20 | 353.04 ms |
+-----------------------------------------------------------+-------+---------------+------------+--------------+-------------+---------------+------------+--------------+
```
#### io_global_by_wait_by_bytes / x$io_global_by_wait_by_bytes
##### Description
Shows the top global IO consumer classes by bytes usage.
##### Structures
```SQL
mariadb> desc io_global_by_wait_by_bytes;
+-----------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+---------------------+------+-----+---------+-------+
| event_name | varchar(128) | YES | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| min_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
| count_read | bigint(20) unsigned | NO | | NULL | |
| total_read | text | YES | | NULL | |
| avg_read | text | YES | | NULL | |
| count_write | bigint(20) unsigned | NO | | NULL | |
| total_written | text | YES | | NULL | |
| avg_written | text | YES | | NULL | |
| total_requested | text | YES | | NULL | |
+-----------------+---------------------+------+-----+---------+-------+
13 rows in set (0.02 sec)
mariadb> desc x$io_global_by_wait_by_bytes;
+-----------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+---------------------+------+-----+---------+-------+
| event_name | varchar(128) | YES | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| min_latency | bigint(20) unsigned | NO | | NULL | |
| avg_latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
| count_read | bigint(20) unsigned | NO | | NULL | |
| total_read | bigint(20) | NO | | NULL | |
| avg_read | decimal(23,4) | NO | | 0.0000 | |
| count_write | bigint(20) unsigned | NO | | NULL | |
| total_written | bigint(20) | NO | | NULL | |
| avg_written | decimal(23,4) | NO | | 0.0000 | |
| total_requested | bigint(21) | NO | | 0 | |
+-----------------+---------------------+------+-----+---------+-------+
13 rows in set (0.01 sec)
```
##### Example
```SQL
mariadb> select * from io_global_by_wait_by_bytes;
+--------------------+--------+---------------+-------------+-------------+-------------+------------+------------+-----------+-------------+---------------+-------------+-----------------+
| event_name | total | total_latency | min_latency | avg_latency | max_latency | count_read | total_read | avg_read | count_write | total_written | avg_written | total_requested |
+--------------------+--------+---------------+-------------+-------------+-------------+------------+------------+-----------+-------------+---------------+-------------+-----------------+
| myisam/dfile | 163681 | 983.13 ms | 379.08 ns | 6.01 us | 22.06 ms | 68737 | 127.31 MiB | 1.90 KiB | 1012221 | 121.52 MiB | 126 bytes | 248.83 MiB |
| myisam/kfile | 1775 | 375.13 ms | 1.02 us | 211.34 µs | 35.15 ms | 54066 | 9.97 MiB | 193 bytes | 428257 | 12.40 MiB | 30 bytes | 22.37 MiB |
| sql/FRM | 57889 | 8.40 s | 19.44 ns | 145.05 us | 336.71 ms | 8009 | 2.60 MiB | 341 bytes | 14675 | 2.91 MiB | 208 bytes | 5.51 MiB |
| sql/global_ddl_log | 164 | 75.96 ms | 5.72 us | 463.19 µs | 7.43 ms | 20 | 80.00 KiB | 4.00 KiB | 76 | 304.00 KiB | 4.00 KiB | 384.00 KiB |
| sql/file_parser | 419 | 601.37 ms | 1.96 us | 1.44 ms | 37.14 ms | 66 | 42.01 KiB | 652 bytes | 64 | 226.98 KiB | 3.55 KiB | 268.99 KiB |
| sql/binlog | 190 | 6.79 s | 1.56 us | 35.76 ms | 4.21 s | 52 | 60.54 KiB | 1.16 KiB | 0 | 0 bytes | 0 bytes | 60.54 KiB |
| sql/ERRMSG | 5 | 2.03 s | 8.61 us | 405.40 ms | 2.03 s | 3 | 51.82 KiB | 17.27 KiB | 0 | 0 bytes | 0 bytes | 51.82 KiB |
| mysys/charset | 3 | 196.52 us | 17.61 µs | 65.51 µs | 137.33 µs | 1 | 17.83 KiB | 17.83 KiB | 0 | 0 bytes | 0 bytes | 17.83 KiB |
| sql/partition | 81 | 18.87 ms | 888.08 ns | 232.92 us | 4.67 ms | 66 | 2.75 KiB | 43 bytes | 8 | 288 bytes | 36 bytes | 3.04 KiB |
| sql/dbopt | 329166 | 26.95 s | 2.06 us | 81.89 µs | 178.71 ms | 0 | 0 bytes | 0 bytes | 9 | 585 bytes | 65 bytes | 585 bytes |
| sql/relaylog | 7 | 1.18 ms | 838.84 ns | 168.30 us | 892.70 µs | 0 | 0 bytes | 0 bytes | 1 | 120 bytes | 120 bytes | 120 bytes |
| mysys/cnf | 5 | 171.61 us | 303.26 ns | 34.32 µs | 115.21 µs | 3 | 56 bytes | 19 bytes | 0 | 0 bytes | 0 bytes | 56 bytes |
| sql/pid | 3 | 220.55 us | 29.29 µs | 73.52 µs | 143.11 µs | 0 | 0 bytes | 0 bytes | 1 | 5 bytes | 5 bytes | 5 bytes |
| sql/casetest | 1 | 121.19 us | 121.19 µs | 121.19 µs | 121.19 µs | 0 | 0 bytes | 0 bytes | 0 | 0 bytes | 0 bytes | 0 bytes |
| sql/binlog_index | 5 | 593.47 us | 1.07 µs | 118.69 µs | 535.90 µs | 0 | 0 bytes | 0 bytes | 0 | 0 bytes | 0 bytes | 0 bytes |
| sql/misc | 23 | 2.73 ms | 65.14 us | 118.50 µs | 255.31 µs | 0 | 0 bytes | 0 bytes | 0 | 0 bytes | 0 bytes | 0 bytes |
+--------------------+--------+---------------+-------------+-------------+-------------+------------+------------+-----------+-------------+---------------+-------------+-----------------+
```
#### io_global_by_wait_by_latency / x$io_global_by_wait_by_latency
##### Description
Shows the top global IO consumers by latency.
##### Structures
```SQL
mariadb> desc io_global_by_wait_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| event_name | varchar(128) | YES | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
| read_latency | text | YES | | NULL | |
| write_latency | text | YES | | NULL | |
| misc_latency | text | YES | | NULL | |
| count_read | bigint(20) unsigned | NO | | NULL | |
| total_read | text | YES | | NULL | |
| avg_read | text | YES | | NULL | |
| count_write | bigint(20) unsigned | NO | | NULL | |
| total_written | text | YES | | NULL | |
| avg_written | text | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
14 rows in set (0.19 sec)
mariadb> desc x$io_global_by_wait_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| event_name | varchar(128) | YES | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| avg_latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
| read_latency | bigint(20) unsigned | NO | | NULL | |
| write_latency | bigint(20) unsigned | NO | | NULL | |
| misc_latency | bigint(20) unsigned | NO | | NULL | |
| count_read | bigint(20) unsigned | NO | | NULL | |
| total_read | bigint(20) | NO | | NULL | |
| avg_read | decimal(23,4) | NO | | 0.0000 | |
| count_write | bigint(20) unsigned | NO | | NULL | |
| total_written | bigint(20) | NO | | NULL | |
| avg_written | decimal(23,4) | NO | | 0.0000 | |
+---------------+---------------------+------+-----+---------+-------+
14 rows in set (0.01 sec)
```
##### Example
```SQL
mariadb> SELECT * FROM io_global_by_wait_by_latency;
+-------------------------+-------+---------------+-------------+-------------+--------------+---------------+--------------+------------+------------+-----------+-------------+---------------+-------------+
| event_name | total | total_latency | avg_latency | max_latency | read_latency | write_latency | misc_latency | count_read | total_read | avg_read | count_write | total_written | avg_written |
+-------------------------+-------+---------------+-------------+-------------+--------------+---------------+--------------+------------+------------+-----------+-------------+---------------+-------------+
| sql/file_parser | 5433 | 30.20 s | 5.56 ms | 203.65 ms | 22.08 ms | 24.89 ms | 30.16 s | 24 | 6.18 KiB | 264 bytes | 737 | 2.15 MiB | 2.99 KiB |
| innodb/innodb_data_file | 1344 | 1.52 s | 1.13 ms | 350.70 ms | 203.82 ms | 450.96 ms | 868.21 ms | 147 | 2.30 MiB | 16.00 KiB | 1001 | 53.61 MiB | 54.84 KiB |
| innodb/innodb_log_file | 828 | 893.48 ms | 1.08 ms | 30.11 ms | 16.32 ms | 705.89 ms | 171.27 ms | 6 | 68.00 KiB | 11.33 KiB | 413 | 2.19 MiB | 5.42 KiB |
| myisam/kfile | 7642 | 242.34 ms | 31.71 us | 19.27 ms | 73.60 ms | 23.48 ms | 145.26 ms | 758 | 135.63 KiB | 183 bytes | 4386 | 232.52 KiB | 54 bytes |
| myisam/dfile | 12540 | 223.47 ms | 17.82 us | 32.50 ms | 87.76 ms | 16.97 ms | 118.74 ms | 5390 | 4.49 MiB | 873 bytes | 1448 | 2.65 MiB | 1.88 KiB |
| csv/metadata | 8 | 28.98 ms | 3.62 ms | 20.15 ms | 399.27 us | 0 ps | 28.58 ms | 2 | 70 bytes | 35 bytes | 0 | 0 bytes | 0 bytes |
| mysys/charset | 3 | 24.24 ms | 8.08 ms | 24.15 ms | 24.15 ms | 0 ps | 93.18 us | 1 | 17.31 KiB | 17.31 KiB | 0 | 0 bytes | 0 bytes |
| sql/ERRMSG | 5 | 20.43 ms | 4.09 ms | 19.31 ms | 20.32 ms | 0 ps | 103.20 us | 3 | 58.97 KiB | 19.66 KiB | 0 | 0 bytes | 0 bytes |
| mysys/cnf | 5 | 11.37 ms | 2.27 ms | 11.28 ms | 11.29 ms | 0 ps | 78.22 us | 3 | 56 bytes | 19 bytes | 0 | 0 bytes | 0 bytes |
| sql/dbopt | 57 | 4.04 ms | 70.92 us | 843.70 us | 0 ps | 186.43 us | 3.86 ms | 0 | 0 bytes | 0 bytes | 7 | 431 bytes | 62 bytes |
| csv/data | 4 | 411.55 us | 102.89 us | 234.89 us | 0 ps | 0 ps | 411.55 us | 0 | 0 bytes | 0 bytes | 0 | 0 bytes | 0 bytes |
| sql/misc | 22 | 340.38 us | 15.47 us | 33.77 us | 0 ps | 0 ps | 340.38 us | 0 | 0 bytes | 0 bytes | 0 | 0 bytes | 0 bytes |
| archive/data | 39 | 277.86 us | 7.12 us | 16.18 us | 0 ps | 0 ps | 277.86 us | 0 | 0 bytes | 0 bytes | 0 | 0 bytes | 0 bytes |
| sql/pid | 3 | 218.03 us | 72.68 us | 154.84 us | 0 ps | 21.64 us | 196.39 us | 0 | 0 bytes | 0 bytes | 1 | 6 bytes | 6 bytes |
| sql/casetest | 5 | 197.15 us | 39.43 us | 126.31 us | 0 ps | 0 ps | 197.15 us | 0 | 0 bytes | 0 bytes | 0 | 0 bytes | 0 bytes |
| sql/global_ddl_log | 2 | 14.60 us | 7.30 us | 12.12 us | 0 ps | 0 ps | 14.60 us | 0 | 0 bytes | 0 bytes | 0 | 0 bytes | 0 bytes |
+-------------------------+-------+---------------+-------------+-------------+--------------+---------------+--------------+------------+------------+-----------+-------------+---------------+-------------+
```
#### latest_file_io / x$latest_file_io
##### Description
Shows the latest file IO, by file / thread.
##### Structures
```SQL
mariadb> desc latest_file_io;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| thread | varchar(149) | YES | | NULL | |
| file | varchar(512) | YES | | NULL | |
| latency | text | YES | | NULL | |
| operation | varchar(32) | NO | | NULL | |
| requested | text | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+
5 rows in set (0.10 sec)
mariadb> desc x$latest_file_io;
+-----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------------+------+-----+---------+-------+
| thread | varchar(149) | YES | | NULL | |
| file | varchar(512) | YES | | NULL | |
| latency | bigint(20) unsigned | YES | | NULL | |
| operation | varchar(32) | NO | | NULL | |
| requested | bigint(20) | YES | | NULL | |
+-----------+---------------------+------+-----+---------+-------+
5 rows in set (0.05 sec)
```
##### Example
```SQL
mariadb> select * from latest_file_io limit 5;
+----------------------+----------------------------------------+------------+-----------+-----------+
| thread | file | latency | operation | requested |
+----------------------+----------------------------------------+------------+-----------+-----------+
| msandbox@localhost:1 | @@tmpdir/#sqlcf28_1_4e.MYI | 9.26 us | write | 124 bytes |
| msandbox@localhost:1 | @@tmpdir/#sqlcf28_1_4e.MYI | 4.00 us | write | 2 bytes |
| msandbox@localhost:1 | @@tmpdir/#sqlcf28_1_4e.MYI | 56.34 us | close | NULL |
| msandbox@localhost:1 | @@tmpdir/#sqlcf28_1_4e.MYD | 53.93 us | close | NULL |
| msandbox@localhost:1 | @@tmpdir/#sqlcf28_1_4e.MYI | 104.05 ms | delete | NULL |
+----------------------+----------------------------------------+------------+-----------+-----------+
```
#### memory_by_host_by_current_bytes / x$memory_by_host_by_current_bytes
##### Description
Summarizes memory use by host using the Performance Schema instrumentation.
When the host found is NULL, it is assumed to be a local "background" thread.
##### Structures
```SQL
mariadb> desc memory_by_host_by_current_bytes;
+--------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| current_count_used | decimal(41,0) | YES | | NULL | |
| current_allocated | text | YES | | NULL | |
| current_avg_alloc | text | YES | | NULL | |
| current_max_alloc | text | YES | | NULL | |
| total_allocated | text | YES | | NULL | |
+--------------------+---------------+------+-----+---------+-------+
6 rows in set (0.24 sec)
mariadb> desc x$memory_by_host_by_current_bytes;
+--------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| current_count_used | decimal(41,0) | YES | | NULL | |
| current_allocated | decimal(41,0) | YES | | NULL | |
| current_avg_alloc | decimal(45,4) | NO | | 0.0000 | |
| current_max_alloc | bigint(20) | YES | | NULL | |
| total_allocated | decimal(42,0) | YES | | NULL | |
+--------------------+---------------+------+-----+---------+-------+
6 rows in set (0.28 sec)
```
##### Example
```SQL
mariadb> select * from memory_by_host_by_current_bytes WHERE host IS NOT NULL;
+------------+--------------------+-------------------+-------------------+-------------------+-----------------+
| host | current_count_used | current_allocated | current_avg_alloc | current_max_alloc | total_allocated |
+------------+--------------------+-------------------+-------------------+-------------------+-----------------+
| background | 2773 | 10.84 MiB | 4.00 KiB | 8.00 MiB | 30.69 MiB |
| localhost | 1509 | 809.30 KiB | 549 bytes | 176.38 KiB | 83.59 MiB |
+------------+--------------------+-------------------+-------------------+-------------------+-----------------+
```
#### memory_by_thread_by_current_bytes / x$memory_by_thread_by_current_bytes
##### Description
Summarizes memory use by user using the Performance Schema instrumentation.
The user columns shows either the background or foreground user name appropriately.
##### Structures
```SQL
mariadb> desc memory_by_thread_by_current_bytes;
+--------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------------+------+-----+---------+-------+
| thread_id | bigint(20) unsigned | NO | | NULL | |
| user | varchar(128) | YES | | NULL | |
| current_count_used | decimal(41,0) | YES | | NULL | |
| current_allocated | text | YES | | NULL | |
| current_avg_alloc | text | YES | | NULL | |
| current_max_alloc | text | YES | | NULL | |
| total_allocated | text | YES | | NULL | |
+--------------------+---------------------+------+-----+---------+-------+
7 rows in set (0.49 sec)
mariadb> desc x$memory_by_thread_by_current_bytes;
+--------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------------+------+-----+---------+-------+
| thread_id | bigint(20) unsigned | NO | | NULL | |
| user | varchar(128) | YES | | NULL | |
| current_count_used | decimal(41,0) | YES | | NULL | |
| current_allocated | decimal(41,0) | YES | | NULL | |
| current_avg_alloc | decimal(45,4) | NO | | 0.0000 | |
| current_max_alloc | bigint(20) | YES | | NULL | |
| total_allocated | decimal(42,0) | YES | | NULL | |
+--------------------+---------------------+------+-----+---------+-------+
7 rows in set (0.25 sec)
```
##### Example
```SQL
mariadb> select * from sys.memory_by_thread_by_current_bytes limit 5;
+-----------+----------------+--------------------+-------------------+-------------------+-------------------+-----------------+
| thread_id | user | current_count_used | current_allocated | current_avg_alloc | current_max_alloc | total_allocated |
+-----------+----------------+--------------------+-------------------+-------------------+-------------------+-----------------+
| 1 | sql/main | 29333 | 166.02 MiB | 5.80 KiB | 131.13 MiB | 196.00 MiB |
| 55 | root@localhost | 175 | 1.04 MiB | 6.09 KiB | 350.86 KiB | 67.37 MiB |
| 58 | root@localhost | 236 | 368.13 KiB | 1.56 KiB | 312.05 KiB | 130.34 MiB |
| 904 | root@localhost | 32 | 18.00 KiB | 576 bytes | 16.00 KiB | 6.68 MiB |
| 970 | root@localhost | 12 | 16.80 KiB | 1.40 KiB | 16.00 KiB | 1.20 MiB |
+-----------+----------------+--------------------+-------------------+-------------------+-------------------+-----------------+
```
#### memory_by_user_by_current_bytes / x$memory_by_user_by_current_bytes
##### Description
Summarizes memory use by user using the Performance Schema instrumentation.
When the user found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc memory_by_user_by_current_bytes;
+--------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| current_count_used | decimal(41,0) | YES | | NULL | |
| current_allocated | text | YES | | NULL | |
| current_avg_alloc | text | YES | | NULL | |
| current_max_alloc | text | YES | | NULL | |
| total_allocated | text | YES | | NULL | |
+--------------------+---------------+------+-----+---------+-------+
6 rows in set (0.06 sec)
mariadb> desc x$memory_by_user_by_current_bytes;
+--------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| current_count_used | decimal(41,0) | YES | | NULL | |
| current_allocated | decimal(41,0) | YES | | NULL | |
| current_avg_alloc | decimal(45,4) | NO | | 0.0000 | |
| current_max_alloc | bigint(20) | YES | | NULL | |
| total_allocated | decimal(42,0) | YES | | NULL | |
+--------------------+---------------+------+-----+---------+-------+
6 rows in set (0.12 sec)
```
##### Example
```SQL
mariadb> select * from memory_by_user_by_current_bytes;
+------+--------------------+-------------------+-------------------+-------------------+-----------------+
| user | current_count_used | current_allocated | current_avg_alloc | current_max_alloc | total_allocated |
+------+--------------------+-------------------+-------------------+-------------------+-----------------+
| root | 1401 | 1.09 MiB | 815 bytes | 334.97 KiB | 42.73 MiB |
| mark | 201 | 496.08 KiB | 2.47 KiB | 334.97 KiB | 5.50 MiB |
+------+--------------------+-------------------+-------------------+-------------------+-----------------+
```
#### memory_global_by_current_bytes / x$memory_global_by_current_bytes
##### Description
Shows the current memory usage within the server globally broken down by allocation type.
##### Structures
```SQL
mariadb> desc memory_global_by_current_bytes;
+-------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------+------+-----+---------+-------+
| event_name | varchar(128) | NO | | NULL | |
| current_count | bigint(20) | NO | | NULL | |
| current_alloc | text | YES | | NULL | |
| current_avg_alloc | text | YES | | NULL | |
| high_count | bigint(20) | NO | | NULL | |
| high_alloc | text | YES | | NULL | |
| high_avg_alloc | text | YES | | NULL | |
+-------------------+--------------+------+-----+---------+-------+
7 rows in set (0.08 sec)
mariadb> desc x$memory_global_by_current_bytes;
+-------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------+------+-----+---------+-------+
| event_name | varchar(128) | NO | | NULL | |
| current_count | bigint(20) | NO | | NULL | |
| current_alloc | bigint(20) | NO | | NULL | |
| current_avg_alloc | decimal(23,4) | NO | | 0.0000 | |
| high_count | bigint(20) | NO | | NULL | |
| high_alloc | bigint(20) | NO | | NULL | |
| high_avg_alloc | decimal(23,4) | NO | | 0.0000 | |
+-------------------+---------------+------+-----+---------+-------+
7 rows in set (0.16 sec)
```
##### Example
```SQL
mariadb> select * from memory_global_by_current_bytes;
+----------------------------------------+---------------+---------------+-------------------+------------+------------+----------------+
| event_name | current_count | current_alloc | current_avg_alloc | high_count | high_alloc | high_avg_alloc |
+----------------------------------------+---------------+---------------+-------------------+------------+------------+----------------+
| memory/sql/TABLE_SHARE::mem_root | 269 | 568.21 KiB | 2.11 KiB | 339 | 706.04 KiB | 2.08 KiB |
| memory/sql/TABLE | 214 | 366.56 KiB | 1.71 KiB | 245 | 481.13 KiB | 1.96 KiB |
| memory/sql/sp_head::main_mem_root | 32 | 334.97 KiB | 10.47 KiB | 421 | 9.73 MiB | 23.66 KiB |
| memory/sql/Filesort_buffer::sort_keys | 1 | 255.89 KiB | 255.89 KiB | 1 | 256.00 KiB | 256.00 KiB |
| memory/mysys/array_buffer | 82 | 121.66 KiB | 1.48 KiB | 1124 | 852.55 KiB | 777 bytes |
...
+----------------------------------------+---------------+---------------+-------------------+------------+------------+----------------+
```
#### memory_global_total / x$memory_global_total
##### Description
Shows the total memory usage within the server globally.
##### Structures
```SQL
mariadb> desc memory_global_total;
+-----------------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------+------+-----+---------+-------+
| total_allocated | text | YES | | NULL | |
+-----------------+------+------+-----+---------+-------+
1 row in set (0.07 sec)
mariadb> desc x$memory_global_total;
+-----------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+---------------+------+-----+---------+-------+
| total_allocated | decimal(41,0) | YES | | NULL | |
+-----------------+---------------+------+-----+---------+-------+
1 row in set (0.00 sec)
```
##### Example
```SQL
mariadb> select * from memory_global_total;
+-----------------+
| total_allocated |
+-----------------+
| 458.44 MiB |
+-----------------+
```
#### metrics
##### Description
Creates a union of the following information:
* performance_schema.global_status
* information_schema.INNODB_METRICS
* Performance Schema global memory usage information
* Current time
It is required that performance_schema = ON, though there is no requirements to which
instruments and consumers that are enabled. See also the description of the Enabled column below.
For view has the following columns:
* Variable_name: The name of the variable
* Variable_value: The value of the variable
* Type: The type of the variable. This will depend on the source, e.g. Global Status, InnoDB Metrics - ..., etc.
* Enabled: Whether the variable is enabled or not. Possible values are 'YES', 'NO', 'PARTIAL'.
PARTIAL is currently only supported for the memory usage variables and means some but not all of the memory/% instruments are enabled.
##### Structures
```SQL
mariadb> DESC metrics;
+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| Variable_name | varchar(193) | YES | | NULL | |
| Variable_value | text | YES | | NULL | |
| Type | varchar(210) | YES | | NULL | |
| Enabled | varchar(7) | NO | | | |
+----------------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysq> DESC metrics_56;
+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| Variable_name | varchar(193) | YES | | NULL | |
| Variable_value | text | YES | | NULL | |
| Type | varchar(210) | YES | | NULL | |
| Enabled | varchar(7) | NO | | | |
+----------------+--------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
```
##### Example
```SQL
mariadb> SELECT * FROM metrics;
+-----------------------------------------------+-------------------------...+--------------------------------------+---------+
| Variable_name | Variable_value ...| Type | Enabled |
+-----------------------------------------------+-------------------------...+--------------------------------------+---------+
| aborted_clients | 0 ...| Global Status | YES |
| aborted_connects | 0 ...| Global Status | YES |
| binlog_cache_disk_use | 0 ...| Global Status | YES |
| binlog_cache_use | 0 ...| Global Status | YES |
| binlog_stmt_cache_disk_use | 0 ...| Global Status | YES |
| binlog_stmt_cache_use | 0 ...| Global Status | YES |
| bytes_received | 217081 ...| Global Status | YES |
| bytes_sent | 27257 ...| Global Status | YES |
...
| innodb_rwlock_x_os_waits | 0 ...| InnoDB Metrics - server | YES |
| innodb_rwlock_x_spin_rounds | 2723 ...| InnoDB Metrics - server | YES |
| innodb_rwlock_x_spin_waits | 1 ...| InnoDB Metrics - server | YES |
| trx_active_transactions | 0 ...| InnoDB Metrics - transaction | NO |
...
| trx_rseg_current_size | 0 ...| InnoDB Metrics - transaction | NO |
| trx_rseg_history_len | 4 ...| InnoDB Metrics - transaction | YES |
| trx_rw_commits | 0 ...| InnoDB Metrics - transaction | NO |
| trx_undo_slots_cached | 0 ...| InnoDB Metrics - transaction | NO |
| trx_undo_slots_used | 0 ...| InnoDB Metrics - transaction | NO |
| memory_current_allocated | 138244216 ...| Performance Schema | PARTIAL |
| memory_total_allocated | 138244216 ...| Performance Schema | PARTIAL |
| NOW() | 2015-05-31 13:27:50.382 ...| System Time | YES |
| UNIX_TIMESTAMP() | 1433042870.382 ...| System Time | YES |
+-----------------------------------------------+-------------------------...+--------------------------------------+---------+
412 rows in set (0.02 sec)
```
#### processlist / x$processlist
##### Description
A detailed non-blocking processlist view to replace [INFORMATION_SCHEMA. | SHOW FULL] PROCESSLIST.
Performs less locking than the legacy sources, whilst giving extra information.
The output includes both background threads and user connections by default. See also `session` / `x$session`
for a view that contains only user session information.
##### Structures
```SQL
mariadb> desc processlist;
+------------------------+------------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+------------------------------------------+------+-----+---------+-------+
| thd_id | bigint(20) unsigned | NO | | NULL | |
| conn_id | bigint(20) unsigned | YES | | NULL | |
| user | varchar(128) | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| command | varchar(16) | YES | | NULL | |
| state | varchar(64) | YES | | NULL | |
| time | bigint(20) | YES | | NULL | |
| current_statement | longtext | YES | | NULL | |
| statement_latency | text | YES | | NULL | |
| progress | decimal(26,2) | YES | | NULL | |
| lock_latency | text | YES | | NULL | |
| rows_examined | bigint(20) unsigned | YES | | NULL | |
| rows_sent | bigint(20) unsigned | YES | | NULL | |
| rows_affected | bigint(20) unsigned | YES | | NULL | |
| tmp_tables | bigint(20) unsigned | YES | | NULL | |
| tmp_disk_tables | bigint(20) unsigned | YES | | NULL | |
| full_scan | varchar(3) | NO | | | |
| last_statement | longtext | YES | | NULL | |
| last_statement_latency | text | YES | | NULL | |
| current_memory | text | YES | | NULL | |
| last_wait | varchar(128) | YES | | NULL | |
| last_wait_latency | text | YES | | NULL | |
| source | varchar(64) | YES | | NULL | |
| trx_latency | text | YES | | NULL | |
| trx_state | enum('ACTIVE','COMMITTED','ROLLED BACK') | YES | | NULL | |
| trx_autocommit | enum('YES','NO') | YES | | NULL | |
| pid | varchar(1024) | YES | | NULL | |
| program_name | varchar(1024) | YES | | NULL | |
+------------------------+------------------------------------------+------+-----+---------+-------+
28 rows in set (0.04 sec)
mariadb> desc x$processlist;
+------------------------+------------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+------------------------------------------+------+-----+---------+-------+
| thd_id | bigint(20) unsigned | NO | | NULL | |
| conn_id | bigint(20) unsigned | YES | | NULL | |
| user | varchar(128) | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| command | varchar(16) | YES | | NULL | |
| state | varchar(64) | YES | | NULL | |
| time | bigint(20) | YES | | NULL | |
| current_statement | longtext | YES | | NULL | |
| statement_latency | bigint(20) unsigned | YES | | NULL | |
| progress | decimal(26,2) | YES | | NULL | |
| lock_latency | bigint(20) unsigned | YES | | NULL | |
| rows_examined | bigint(20) unsigned | YES | | NULL | |
| rows_sent | bigint(20) unsigned | YES | | NULL | |
| rows_affected | bigint(20) unsigned | YES | | NULL | |
| tmp_tables | bigint(20) unsigned | YES | | NULL | |
| tmp_disk_tables | bigint(20) unsigned | YES | | NULL | |
| full_scan | varchar(3) | NO | | | |
| last_statement | longtext | YES | | NULL | |
| last_statement_latency | bigint(20) unsigned | YES | | NULL | |
| current_memory | decimal(41,0) | YES | | NULL | |
| last_wait | varchar(128) | YES | | NULL | |
| last_wait_latency | varchar(20) | YES | | NULL | |
| source | varchar(64) | YES | | NULL | |
| trx_latency | bigint(20) unsigned | YES | | NULL | |
| trx_state | enum('ACTIVE','COMMITTED','ROLLED BACK') | YES | | NULL | |
| trx_autocommit | enum('YES','NO') | YES | | NULL | |
| pid | varchar(1024) | YES | | NULL | |
| program_name | varchar(1024) | YES | | NULL | |
+------------------------+------------------------------------------+------+-----+---------+-------+
28 rows in set (0.01 sec)
```
##### Example
```SQL
mariadb> select * from sys.processlist where conn_id is not null and command != 'daemon' and conn_id != connection_id()\G
*************************** 1. row ***************************
thd_id: 44524
conn_id: 44502
user: msandbox@localhost
db: test
command: Query
state: alter table (flush)
time: 18
current_statement: alter table t1 add column g int
statement_latency: 18.45 s
progress: 98.84
lock_latency: 265.43 ms
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 0
tmp_disk_tables: 0
full_scan: NO
last_statement: NULL
last_statement_latency: NULL
current_memory: 664.06 KiB
last_wait: wait/io/file/innodb/innodb_data_file
last_wait_latency: 1.07 us
source: fil0fil.cc:5146
trx_latency: NULL
trx_state: NULL
trx_autocommit: NULL
pid: 4212
program_name: mysql
```
#### ps_check_lost_instrumentation
##### Description
Used to check whether Performance Schema is not able to monitor all runtime data - only returns variables that have lost instruments
##### Structure
```SQL
mariadb> desc ps_check_lost_instrumentation;
+----------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------+-------+
| variable_name | varchar(64) | NO | | | |
| variable_value | varchar(1024) | YES | | NULL | |
+----------------+---------------+------+-----+---------+-------+
2 rows in set (0.09 sec)
```
##### Example
```SQL
mariadb> select * from ps_check_lost_instrumentation;
+----------------------------------------+----------------+
| variable_name | variable_value |
+----------------------------------------+----------------+
| Performance_schema_file_handles_lost | 101223 |
| Performance_schema_file_instances_lost | 1231 |
+----------------------------------------+----------------+
```
#### schema_auto_increment_columns
##### Description
Present current auto_increment usage/capacity in all tables.
##### Structures
```SQL
mariadb> desc schema_auto_increment_columns;
+----------------------+------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+------------------------+------+-----+---------+-------+
| table_schema | varchar(64) | NO | | | |
| table_name | varchar(64) | NO | | | |
| column_name | varchar(64) | NO | | | |
| data_type | varchar(64) | NO | | | |
| column_type | longtext | NO | | NULL | |
| is_signed | int(1) | NO | | 0 | |
| is_unsigned | int(1) | NO | | 0 | |
| max_value | bigint(21) unsigned | YES | | NULL | |
| auto_increment | bigint(21) unsigned | YES | | NULL | |
| auto_increment_ratio | decimal(25,4) unsigned | YES | | NULL | |
+----------------------+------------------------+------+-----+---------+-------+
```
##### Example
```SQL
mariadb> select * from schema_auto_increment_columns limit 5;
+-------------------+-------------------+-------------+-----------+-------------+-----------+-------------+---------------------+----------------+----------------------+
| table_schema | table_name | column_name | data_type | column_type | is_signed | is_unsigned | max_value | auto_increment | auto_increment_ratio |
+-------------------+-------------------+-------------+-----------+-------------+-----------+-------------+---------------------+----------------+----------------------+
| test | t1 | i | tinyint | tinyint(4) | 1 | 0 | 127 | 34 | 0.2677 |
| mem__advisor_text | template_meta | hib_id | int | int(11) | 1 | 0 | 2147483647 | 516 | 0.0000 |
| mem__advisors | advisor_schedules | schedule_id | int | int(11) | 1 | 0 | 2147483647 | 249 | 0.0000 |
| mem__advisors | app_identity_path | hib_id | int | int(11) | 1 | 0 | 2147483647 | 251 | 0.0000 |
| mem__bean_config | plists | id | bigint | bigint(20) | 1 | 0 | 9223372036854775807 | 1 | 0.0000 |
+-------------------+-------------------+-------------+-----------+-------------+-----------+-------------+---------------------+----------------+----------------------+
```
#### schema_index_statistics / x$schema_index_statistics
##### Description
Statistics around indexes.
Ordered by the total wait time descending - top indexes are most contended.
##### Structures
```SQL
mariadb> desc schema_index_statistics;
+----------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+---------+-------+
| table_schema | varchar(64) | YES | | NULL | |
| table_name | varchar(64) | YES | | NULL | |
| index_name | varchar(64) | YES | | NULL | |
| rows_selected | bigint(20) unsigned | NO | | NULL | |
| select_latency | text | YES | | NULL | |
| rows_inserted | bigint(20) unsigned | NO | | NULL | |
| insert_latency | text | YES | | NULL | |
| rows_updated | bigint(20) unsigned | NO | | NULL | |
| update_latency | text | YES | | NULL | |
| rows_deleted | bigint(20) unsigned | NO | | NULL | |
| delete_latency | text | YES | | NULL | |
+----------------+---------------------+------+-----+---------+-------+
11 rows in set (0.17 sec)
mariadb> desc x$schema_index_statistics;
+----------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+---------+-------+
| table_schema | varchar(64) | YES | | NULL | |
| table_name | varchar(64) | YES | | NULL | |
| index_name | varchar(64) | YES | | NULL | |
| rows_selected | bigint(20) unsigned | NO | | NULL | |
| select_latency | bigint(20) unsigned | NO | | NULL | |
| rows_inserted | bigint(20) unsigned | NO | | NULL | |
| insert_latency | bigint(20) unsigned | NO | | NULL | |
| rows_updated | bigint(20) unsigned | NO | | NULL | |
| update_latency | bigint(20) unsigned | NO | | NULL | |
| rows_deleted | bigint(20) unsigned | NO | | NULL | |
| delete_latency | bigint(20) unsigned | NO | | NULL | |
+----------------+---------------------+------+-----+---------+-------+
11 rows in set (0.42 sec)
```
##### Example
```SQL
mariadb> select * from schema_index_statistics limit 5;
+------------------+-------------+------------+---------------+----------------+---------------+----------------+--------------+----------------+--------------+----------------+
| table_schema | table_name | index_name | rows_selected | select_latency | rows_inserted | insert_latency | rows_updated | update_latency | rows_deleted | delete_latency |
+------------------+-------------+------------+---------------+----------------+---------------+----------------+--------------+----------------+--------------+----------------+
| mem | mysqlserver | PRIMARY | 6208 | 108.27 ms | 0 | 0 ps | 5470 | 1.47 s | 0 | 0 ps |
| mem | innodb | PRIMARY | 4666 | 76.27 ms | 0 | 0 ps | 4454 | 571.47 ms | 0 | 0 ps |
| mem | connection | PRIMARY | 1064 | 20.98 ms | 0 | 0 ps | 1064 | 457.30 ms | 0 | 0 ps |
| mem | environment | PRIMARY | 5566 | 151.17 ms | 0 | 0 ps | 694 | 252.57 ms | 0 | 0 ps |
| mem | querycache | PRIMARY | 1698 | 27.99 ms | 0 | 0 ps | 1698 | 371.72 ms | 0 | 0 ps |
+------------------+-------------+------------+---------------+----------------+---------------+----------------+--------------+----------------+--------------+----------------+
```
#### schema_object_overview
##### Description
Shows an overview of the types of objects within each schema
Note: On instances with a large numbers of objects, this could take some time to execute, and may not be recommended.
##### Structure
```SQL
mariadb> desc schema_object_overview;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| db | varchar(64) | NO | | | |
| object_type | varchar(64) | NO | | | |
| count | bigint(21) | NO | | 0 | |
+-------------+-------------+------+-----+---------+-------+
3 rows in set (0.08 sec)
```
##### Example
```SQL
mariadb> select * from schema_object_overview;
+--------------------+---------------+-------+
| db | object_type | count |
+--------------------+---------------+-------+
| information_schema | SYSTEM VIEW | 60 |
| mysql | BASE TABLE | 31 |
| mysql | INDEX (BTREE) | 69 |
| performance_schema | BASE TABLE | 76 |
| sys | BASE TABLE | 1 |
| sys | FUNCTION | 12 |
| sys | INDEX (BTREE) | 1 |
| sys | PROCEDURE | 22 |
| sys | TRIGGER | 2 |
| sys | VIEW | 91 |
+--------------------+---------------+-------+
10 rows in set (1.58 sec)
```
#### privileges_by_table_by_level
##### Description
-- Shows granted privileges broken down by table on which they allow access
-- and level on which they were granted:
-- - user_privileges
-- - schema_privileges
-- - table_privileges
##### Structure
```SQL
MariaDB [test]> desc sys.privileges_by_table_by_level;
+--------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| TABLE_SCHEMA | varchar(64) | NO | | NULL | |
| TABLE_NAME | varchar(64) | NO | | NULL | |
| GRANTEE | varchar(385) | NO | | | |
| PRIVILEGE | varchar(64) | NO | | | |
| LEVEL | varchar(6) | NO | | | |
+--------------+--------------+------+-----+---------+-------+
5 rows in set (0.002 sec)
```
##### Example
```SQL
mysql> select * from sys.privileges_by_table_by_level;
+--------------+------------+--------------------+----------------+--------+
| TABLE_SCHEMA | TABLE_NAME | GRANTEE | PRIVILEGE_TYPE | LEVEL |
+--------------+------------+--------------------+----------------+--------+
| test | v1 | 'oleg'@'localhost' | SELECT | GLOBAL |
| test | t1 | 'oleg'@'localhost' | SELECT | GLOBAL |
| test | v1 | 'oleg'@'localhost' | INSERT | GLOBAL |
| test | t1 | 'oleg'@'localhost' | INSERT | GLOBAL |
| test | v1 | 'oleg'@'localhost' | UPDATE | GLOBAL |
| test | v1 | 'PUBLIC'@'' | SELECT | SCHEMA |
| test | t1 | 'PUBLIC'@'' | SELECT | SCHEMA |
| test | v1 | 'PUBLIC'@'' | INSERT | SCHEMA |
| test | t1 | 'PUBLIC'@'' | INSERT | SCHEMA |
| test | v1 | 'PUBLIC'@'' | UPDATE | SCHEMA |
| test | t1 | 'PUBLIC'@'' | UPDATE | SCHEMA |
| test | v1 | 'PUBLIC'@'' | DELETE HISTORY | SCHEMA |
| test | t1 | 'PUBLIC'@'' | DELETE HISTORY | SCHEMA |
| test | t1 | 'oleg'@'%' | SELECT | TABLE |
| test | t1 | 'oleg'@'%' | UPDATE | TABLE |
| test | v1 | 'oleg'@'%' | SELECT | TABLE |
+--------------+------------+--------------------+----------------+--------+
16 rows in set (1.58 sec)
```
#### schema_table_statistics / x$schema_table_statistics
##### Description
Statistics around tables.
Ordered by the total wait time descending - top tables are most contended.
Also includes the helper view (used by schema_table_statistics_with_buffer as well):
* x$ps_schema_table_statistics_io
##### Structures
```SQL
mariadb> desc schema_table_statistics;
+-------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------+-------+
| table_schema | varchar(64) | YES | | NULL | |
| table_name | varchar(64) | YES | | NULL | |
| total_latency | text | YES | | NULL | |
| rows_fetched | bigint(20) unsigned | NO | | NULL | |
| fetch_latency | text | YES | | NULL | |
| rows_inserted | bigint(20) unsigned | NO | | NULL | |
| insert_latency | text | YES | | NULL | |
| rows_updated | bigint(20) unsigned | NO | | NULL | |
| update_latency | text | YES | | NULL | |
| rows_deleted | bigint(20) unsigned | NO | | NULL | |
| delete_latency | text | YES | | NULL | |
| io_read_requests | decimal(42,0) | YES | | NULL | |
| io_read | text | YES | | NULL | |
| io_read_latency | text | YES | | NULL | |
| io_write_requests | decimal(42,0) | YES | | NULL | |
| io_write | text | YES | | NULL | |
| io_write_latency | text | YES | | NULL | |
| io_misc_requests | decimal(42,0) | YES | | NULL | |
| io_misc_latency | text | YES | | NULL | |
+-------------------+---------------------+------+-----+---------+-------+
19 rows in set (0.12 sec)
mariadb> desc x$schema_table_statistics;
+-------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------+-------+
| table_schema | varchar(64) | YES | | NULL | |
| table_name | varchar(64) | YES | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| rows_fetched | bigint(20) unsigned | NO | | NULL | |
| fetch_latency | bigint(20) unsigned | NO | | NULL | |
| rows_inserted | bigint(20) unsigned | NO | | NULL | |
| insert_latency | bigint(20) unsigned | NO | | NULL | |
| rows_updated | bigint(20) unsigned | NO | | NULL | |
| update_latency | bigint(20) unsigned | NO | | NULL | |
| rows_deleted | bigint(20) unsigned | NO | | NULL | |
| delete_latency | bigint(20) unsigned | NO | | NULL | |
| io_read_requests | decimal(42,0) | YES | | NULL | |
| io_read | decimal(41,0) | YES | | NULL | |
| io_read_latency | decimal(42,0) | YES | | NULL | |
| io_write_requests | decimal(42,0) | YES | | NULL | |
| io_write | decimal(41,0) | YES | | NULL | |
| io_write_latency | decimal(42,0) | YES | | NULL | |
| io_misc_requests | decimal(42,0) | YES | | NULL | |
| io_misc_latency | decimal(42,0) | YES | | NULL | |
+-------------------+---------------------+------+-----+---------+-------+
19 rows in set (0.13 sec)
mariadb> desc x$ps_schema_table_statistics_io;
+---------------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------------------+---------------+------+-----+---------+-------+
| table_schema | varchar(64) | YES | | NULL | |
| table_name | varchar(64) | YES | | NULL | |
| count_read | decimal(42,0) | YES | | NULL | |
| sum_number_of_bytes_read | decimal(41,0) | YES | | NULL | |
| sum_timer_read | decimal(42,0) | YES | | NULL | |
| count_write | decimal(42,0) | YES | | NULL | |
| sum_number_of_bytes_write | decimal(41,0) | YES | | NULL | |
| sum_timer_write | decimal(42,0) | YES | | NULL | |
| count_misc | decimal(42,0) | YES | | NULL | |
| sum_timer_misc | decimal(42,0) | YES | | NULL | |
+---------------------------+---------------+------+-----+---------+-------+
10 rows in set (0.10 sec)
```
##### Example
```SQL
mariadb> select * from schema_table_statistics\G
*************************** 1. row ***************************
table_schema: sys
table_name: sys_config
total_latency: 0 ps
rows_fetched: 0
fetch_latency: 0 ps
rows_inserted: 0
insert_latency: 0 ps
rows_updated: 0
update_latency: 0 ps
rows_deleted: 0
delete_latency: 0 ps
io_read_requests: 8
io_read: 2.28 KiB
io_read_latency: 727.32 us
io_write_requests: 0
io_write: 0 bytes
io_write_latency: 0 ps
io_misc_requests: 10
io_misc_latency: 126.88 us
```
#### schema_redundant_indexes / x$schema_flattened_keys
##### Description
Shows indexes which are made redundant (or duplicate) by other (dominant) keys.
Also includes the the helper view `x$schema_flattened_keys`.
##### Structures
```SQL
mariadb> desc sys.schema_redundant_indexes;
+----------------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------------+--------------+------+-----+---------+-------+
| table_schema | varchar(64) | NO | | | |
| table_name | varchar(64) | NO | | | |
| redundant_index_name | varchar(64) | NO | | | |
| redundant_index_columns | text | YES | | NULL | |
| redundant_index_non_unique | bigint(1) | YES | | NULL | |
| dominant_index_name | varchar(64) | NO | | | |
| dominant_index_columns | text | YES | | NULL | |
| dominant_index_non_unique | bigint(1) | YES | | NULL | |
| subpart_exists | int(1) | NO | | 0 | |
| sql_drop_index | varchar(223) | YES | | NULL | |
+----------------------------+--------------+------+-----+---------+-------+
10 rows in set (0.00 sec)
mariadb> desc sys.x$schema_flattened_keys;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| table_schema | varchar(64) | NO | | | |
| table_name | varchar(64) | NO | | | |
| index_name | varchar(64) | NO | | | |
| non_unique | bigint(1) | YES | | NULL | |
| subpart_exists | bigint(1) | YES | | NULL | |
| index_columns | text | YES | | NULL | |
+----------------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
```
##### Example
```SQL
mariadb> select * from sys.schema_redundant_indexes\G
*************************** 1. row ***************************
table_schema: test
table_name: rkey
redundant_index_name: j
redundant_index_columns: j
redundant_index_non_unique: 1
dominant_index_name: j_2
dominant_index_columns: j,k
dominant_index_non_unique: 1
subpart_exists: 0
sql_drop_index: ALTER TABLE `test`.`rkey` DROP INDEX `j`
1 row in set (0.20 sec)
mariadb> SHOW CREATE TABLE test.rkey\G
*************************** 1. row ***************************
Table: rkey
Create Table: CREATE TABLE `rkey` (
`i` int(11) NOT NULL,
`j` int(11) DEFAULT NULL,
`k` int(11) DEFAULT NULL,
PRIMARY KEY (`i`),
KEY `j` (`j`),
KEY `j_2` (`j`,`k`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.06 sec)
```
#### schema_table_lock_waits / x$schema_table_lock_waits
##### Description
Shows sessions that are blocked waiting on table metadata locks, and who is blocking them.
##### Structures
```SQL
mariadb> desc schema_table_lock_waits;
+------------------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------------+---------------------+------+-----+---------+-------+
| object_schema | varchar(64) | YES | | NULL | |
| object_name | varchar(64) | YES | | NULL | |
| waiting_thread_id | bigint(20) unsigned | NO | | NULL | |
| waiting_pid | bigint(20) unsigned | YES | | NULL | |
| waiting_account | text | YES | | NULL | |
| waiting_lock_type | varchar(32) | NO | | NULL | |
| waiting_lock_duration | varchar(32) | NO | | NULL | |
| waiting_query | longtext | YES | | NULL | |
| waiting_query_secs | bigint(20) | YES | | NULL | |
| waiting_query_rows_affected | bigint(20) unsigned | YES | | NULL | |
| waiting_query_rows_examined | bigint(20) unsigned | YES | | NULL | |
| blocking_thread_id | bigint(20) unsigned | NO | | NULL | |
| blocking_pid | bigint(20) unsigned | YES | | NULL | |
| blocking_account | text | YES | | NULL | |
| blocking_lock_type | varchar(32) | NO | | NULL | |
| blocking_lock_duration | varchar(32) | NO | | NULL | |
| sql_kill_blocking_query | varchar(31) | YES | | NULL | |
| sql_kill_blocking_connection | varchar(25) | YES | | NULL | |
+------------------------------+---------------------+------+-----+---------+-------+
18 rows in set (0.15 sec)
mariadb> desc x$schema_table_lock_waits;
+------------------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------------+---------------------+------+-----+---------+-------+
| object_schema | varchar(64) | YES | | NULL | |
| object_name | varchar(64) | YES | | NULL | |
| waiting_thread_id | bigint(20) unsigned | NO | | NULL | |
| waiting_pid | bigint(20) unsigned | YES | | NULL | |
| waiting_account | text | YES | | NULL | |
| waiting_lock_type | varchar(32) | NO | | NULL | |
| waiting_lock_duration | varchar(32) | NO | | NULL | |
| waiting_query | longtext | YES | | NULL | |
| waiting_query_secs | bigint(20) | YES | | NULL | |
| waiting_query_rows_affected | bigint(20) unsigned | YES | | NULL | |
| waiting_query_rows_examined | bigint(20) unsigned | YES | | NULL | |
| blocking_thread_id | bigint(20) unsigned | NO | | NULL | |
| blocking_pid | bigint(20) unsigned | YES | | NULL | |
| blocking_account | text | YES | | NULL | |
| blocking_lock_type | varchar(32) | NO | | NULL | |
| blocking_lock_duration | varchar(32) | NO | | NULL | |
| sql_kill_blocking_query | varchar(31) | YES | | NULL | |
| sql_kill_blocking_connection | varchar(25) | YES | | NULL | |
+------------------------------+---------------------+------+-----+---------+-------+
18 rows in set (0.03 sec)
```
##### Example
```SQL
mariadb> select * from sys.schema_table_lock_waits\G
*************************** 1. row ***************************
object_schema: test
object_name: t
waiting_thread_id: 43
waiting_pid: 21
waiting_account: msandbox@localhost
waiting_lock_type: SHARED_UPGRADABLE
waiting_lock_duration: TRANSACTION
waiting_query: alter table test.t add foo int
waiting_query_secs: 988
waiting_query_rows_affected: 0
waiting_query_rows_examined: 0
blocking_thread_id: 42
blocking_pid: 20
blocking_account: msandbox@localhost
blocking_lock_type: SHARED_NO_READ_WRITE
blocking_lock_duration: TRANSACTION
sql_kill_blocking_query: KILL QUERY 20
sql_kill_blocking_connection: KILL 20
```
#### schema_table_statistics_with_buffer / x$schema_table_statistics_with_buffer
##### Description
Statistics around tables.
Ordered by the total wait time descending - top tables are most contended.
More statistics such as caching stats for the InnoDB buffer pool with InnoDB tables
Uses the x$ps_schema_table_statistics_io helper view from schema_table_statistics.
##### Structures
```SQL
mariadb> desc schema_table_statistics_with_buffer;
+----------------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------------+---------------------+------+-----+---------+-------+
| table_schema | varchar(64) | YES | | NULL | |
| table_name | varchar(64) | YES | | NULL | |
| rows_fetched | bigint(20) unsigned | NO | | NULL | |
| fetch_latency | text | YES | | NULL | |
| rows_inserted | bigint(20) unsigned | NO | | NULL | |
| insert_latency | text | YES | | NULL | |
| rows_updated | bigint(20) unsigned | NO | | NULL | |
| update_latency | text | YES | | NULL | |
| rows_deleted | bigint(20) unsigned | NO | | NULL | |
| delete_latency | text | YES | | NULL | |
| io_read_requests | decimal(42,0) | YES | | NULL | |
| io_read | text | YES | | NULL | |
| io_read_latency | text | YES | | NULL | |
| io_write_requests | decimal(42,0) | YES | | NULL | |
| io_write | text | YES | | NULL | |
| io_write_latency | text | YES | | NULL | |
| io_misc_requests | decimal(42,0) | YES | | NULL | |
| io_misc_latency | text | YES | | NULL | |
| innodb_buffer_allocated | text | YES | | NULL | |
| innodb_buffer_data | text | YES | | NULL | |
| innodb_buffer_free | text | YES | | NULL | |
| innodb_buffer_pages | bigint(21) | YES | | 0 | |
| innodb_buffer_pages_hashed | bigint(21) | YES | | 0 | |
| innodb_buffer_pages_old | bigint(21) | YES | | 0 | |
| innodb_buffer_rows_cached | decimal(44,0) | YES | | 0 | |
+----------------------------+---------------------+------+-----+---------+-------+
25 rows in set (0.05 sec)
mariadb> desc x$schema_table_statistics_with_buffer;
+----------------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------------+---------------------+------+-----+---------+-------+
| table_schema | varchar(64) | YES | | NULL | |
| table_name | varchar(64) | YES | | NULL | |
| rows_fetched | bigint(20) unsigned | NO | | NULL | |
| fetch_latency | bigint(20) unsigned | NO | | NULL | |
| rows_inserted | bigint(20) unsigned | NO | | NULL | |
| insert_latency | bigint(20) unsigned | NO | | NULL | |
| rows_updated | bigint(20) unsigned | NO | | NULL | |
| update_latency | bigint(20) unsigned | NO | | NULL | |
| rows_deleted | bigint(20) unsigned | NO | | NULL | |
| delete_latency | bigint(20) unsigned | NO | | NULL | |
| io_read_requests | decimal(42,0) | YES | | NULL | |
| io_read | decimal(41,0) | YES | | NULL | |
| io_read_latency | decimal(42,0) | YES | | NULL | |
| io_write_requests | decimal(42,0) | YES | | NULL | |
| io_write | decimal(41,0) | YES | | NULL | |
| io_write_latency | decimal(42,0) | YES | | NULL | |
| io_misc_requests | decimal(42,0) | YES | | NULL | |
| io_misc_latency | decimal(42,0) | YES | | NULL | |
| innodb_buffer_allocated | decimal(43,0) | YES | | NULL | |
| innodb_buffer_data | decimal(43,0) | YES | | NULL | |
| innodb_buffer_free | decimal(44,0) | YES | | NULL | |
| innodb_buffer_pages | bigint(21) | YES | | 0 | |
| innodb_buffer_pages_hashed | bigint(21) | YES | | 0 | |
| innodb_buffer_pages_old | bigint(21) | YES | | 0 | |
| innodb_buffer_rows_cached | decimal(44,0) | YES | | 0 | |
+----------------------------+---------------------+------+-----+---------+-------+
25 rows in set (0.17 sec)
```
##### Example
```SQL
mariadb> select * from schema_table_statistics_with_buffer limit 1\G
*************************** 1. row ***************************
table_schema: mem
table_name: mysqlserver
rows_fetched: 27087
fetch_latency: 442.72 ms
rows_inserted: 2
insert_latency: 185.04 us
rows_updated: 5096
update_latency: 1.39 s
rows_deleted: 0
delete_latency: 0 ps
io_read_requests: 2565
io_read_bytes: 1121627
io_read_latency: 10.07 ms
io_write_requests: 1691
io_write_bytes: 128383
io_write_latency: 14.17 ms
io_misc_requests: 2698
io_misc_latency: 433.66 ms
innodb_buffer_pages: 19
innodb_buffer_pages_hashed: 19
innodb_buffer_pages_old: 19
innodb_buffer_bytes_allocated: 311296
innodb_buffer_bytes_data: 1924
innodb_buffer_rows_cached: 2
```
#### schema_tables_with_full_table_scans / x$schema_tables_with_full_table_scans
##### Description
Finds tables that are being accessed by full table scans ordering by the number of rows scanned descending.
##### Structures
```SQL
mariadb> desc schema_tables_with_full_table_scans;
+-------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------+-------+
| object_schema | varchar(64) | YES | | NULL | |
| object_name | varchar(64) | YES | | NULL | |
| rows_full_scanned | bigint(20) unsigned | NO | | NULL | |
| latency | text | YES | | NULL | |
+-------------------+---------------------+------+-----+---------+-------+
4 rows in set (0.02 sec)
mariadb> desc x$schema_tables_with_full_table_scans;
+-------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------+-------+
| object_schema | varchar(64) | YES | | NULL | |
| object_name | varchar(64) | YES | | NULL | |
| rows_full_scanned | bigint(20) unsigned | NO | | NULL | |
| latency | bigint(20) unsigned | NO | | NULL | |
+-------------------+---------------------+------+-----+---------+-------+
4 rows in set (0.03 sec)
```
##### Example
```SQL
mariadb> select * from schema_tables_with_full_table_scans limit 5;
+--------------------+--------------------------------+-------------------+-----------+
| object_schema | object_name | rows_full_scanned | latency |
+--------------------+--------------------------------+-------------------+-----------+
| mem30__instruments | fsstatistics | 10207042 | 13.10 s |
| mem30__instruments | preparedstatementapidata | 436428 | 973.27 ms |
| mem30__instruments | mysqlprocessactivity | 411702 | 282.07 ms |
| mem30__instruments | querycachequeriesincachedata | 374011 | 767.15 ms |
| mem30__instruments | rowaccessesdata | 322321 | 1.55 s |
+--------------------+--------------------------------+-------------------+-----------+
```
#### schema_unused_indexes
##### Description
Finds indexes that have had no events against them (and hence, no usage).
To trust whether the data from this view is representative of your workload, you should ensure that the server has been up for a representative amount of time before using it.
PRIMARY (key) indexes are ignored.
##### Structure
```SQL
mariadb> desc schema_unused_indexes;
+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| object_schema | varchar(64) | YES | | NULL | |
| object_name | varchar(64) | YES | | NULL | |
| index_name | varchar(64) | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+
3 rows in set (0.09 sec)
```
##### Example
```SQL
mariadb> select * from schema_unused_indexes limit 5;
+--------------------+---------------------+--------------------+
| object_schema | object_name | index_name |
+--------------------+---------------------+--------------------+
| mem30__bean_config | plists | path |
| mem30__config | group_selections | name |
| mem30__config | notification_groups | name |
| mem30__config | user_form_defaults | FKC1AEF1F9E7EE2CFB |
| mem30__enterprise | whats_new_entries | entryId |
+--------------------+---------------------+--------------------+
```
#### session / x$session
##### Description
A detailed non-blocking processlist view to replace [INFORMATION_SCHEMA. | SHOW FULL] PROCESSLIST.
Performs less locking than the legacy sources, whilst giving extra information.
The output of this view is restricted to threads from user sessions. See also processlist / x$processlist which contains both user and background threads.
##### Structures
```SQL
mariadb> desc session;
+------------------------+------------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+------------------------------------------+------+-----+---------+-------+
| thd_id | bigint(20) unsigned | NO | | NULL | |
| conn_id | bigint(20) unsigned | YES | | NULL | |
| user | varchar(128) | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| command | varchar(16) | YES | | NULL | |
| state | varchar(64) | YES | | NULL | |
| time | bigint(20) | YES | | NULL | |
| current_statement | longtext | YES | | NULL | |
| statement_latency | text | YES | | NULL | |
| progress | decimal(26,2) | YES | | NULL | |
| lock_latency | text | YES | | NULL | |
| rows_examined | bigint(20) unsigned | YES | | NULL | |
| rows_sent | bigint(20) unsigned | YES | | NULL | |
| rows_affected | bigint(20) unsigned | YES | | NULL | |
| tmp_tables | bigint(20) unsigned | YES | | NULL | |
| tmp_disk_tables | bigint(20) unsigned | YES | | NULL | |
| full_scan | varchar(3) | NO | | | |
| last_statement | longtext | YES | | NULL | |
| last_statement_latency | text | YES | | NULL | |
| current_memory | text | YES | | NULL | |
| last_wait | varchar(128) | YES | | NULL | |
| last_wait_latency | text | YES | | NULL | |
| source | varchar(64) | YES | | NULL | |
| trx_latency | text | YES | | NULL | |
| trx_state | enum('ACTIVE','COMMITTED','ROLLED BACK') | YES | | NULL | |
| trx_autocommit | enum('YES','NO') | YES | | NULL | |
| pid | varchar(1024) | YES | | NULL | |
| program_name | varchar(1024) | YES | | NULL | |
+------------------------+------------------------------------------+------+-----+---------+-------+
28 rows in set (0.00 sec)
mariadb> desc x$session;
+------------------------+------------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+------------------------------------------+------+-----+---------+-------+
| thd_id | bigint(20) unsigned | NO | | NULL | |
| conn_id | bigint(20) unsigned | YES | | NULL | |
| user | varchar(128) | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| command | varchar(16) | YES | | NULL | |
| state | varchar(64) | YES | | NULL | |
| time | bigint(20) | YES | | NULL | |
| current_statement | longtext | YES | | NULL | |
| statement_latency | bigint(20) unsigned | YES | | NULL | |
| progress | decimal(26,2) | YES | | NULL | |
| lock_latency | bigint(20) unsigned | YES | | NULL | |
| rows_examined | bigint(20) unsigned | YES | | NULL | |
| rows_sent | bigint(20) unsigned | YES | | NULL | |
| rows_affected | bigint(20) unsigned | YES | | NULL | |
| tmp_tables | bigint(20) unsigned | YES | | NULL | |
| tmp_disk_tables | bigint(20) unsigned | YES | | NULL | |
| full_scan | varchar(3) | NO | | | |
| last_statement | longtext | YES | | NULL | |
| last_statement_latency | bigint(20) unsigned | YES | | NULL | |
| current_memory | decimal(41,0) | YES | | NULL | |
| last_wait | varchar(128) | YES | | NULL | |
| last_wait_latency | varchar(20) | YES | | NULL | |
| source | varchar(64) | YES | | NULL | |
| trx_latency | bigint(20) unsigned | YES | | NULL | |
| trx_state | enum('ACTIVE','COMMITTED','ROLLED BACK') | YES | | NULL | |
| trx_autocommit | enum('YES','NO') | YES | | NULL | |
| pid | varchar(1024) | YES | | NULL | |
| program_name | varchar(1024) | YES | | NULL | |
+------------------------+------------------------------------------+------+-----+---------+-------+
28 rows in set (0.00 sec)
```
##### Example
```SQL
mariadb> select * from sys.session\G
*************************** 1. row ***************************
thd_id: 24
conn_id: 2
user: root@localhost
db: sys
command: Query
state: Sending data
time: 0
current_statement: select * from sys.session
statement_latency: 137.22 ms
progress: NULL
lock_latency: 33.75 ms
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 4
tmp_disk_tables: 1
full_scan: YES
last_statement: NULL
last_statement_latency: NULL
current_memory: 3.26 MiB
last_wait: wait/synch/mutex/innodb/file_format_max_mutex
last_wait_latency: 64.09 ns
source: trx0sys.cc:778
trx_latency: 7.88 s
trx_state: ACTIVE
trx_autocommit: NO
pid: 4212
program_name: mysql
```
#### session_ssl_status
##### Description
Shows SSL version, cipher and the count of re-used SSL sessions per connection
##### Structures
```SQL
mariadb> desc sys.session_ssl_status;
+---------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------------+---------------------+------+-----+---------+-------+
| thread_id | bigint(20) unsigned | NO | | NULL | |
| ssl_version | varchar(1024) | YES | | NULL | |
| ssl_cipher | varchar(1024) | YES | | NULL | |
| ssl_sessions_reused | varchar(1024) | YES | | NULL | |
+---------------------+---------------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
```
##### Example
```SQL
mariadb> select * from session_ssl_status;
+-----------+-------------+--------------------+---------------------+
| thread_id | ssl_version | ssl_cipher | ssl_sessions_reused |
+-----------+-------------+--------------------+---------------------+
| 26 | TLSv1 | DHE-RSA-AES256-SHA | 0 |
| 27 | TLSv1 | DHE-RSA-AES256-SHA | 0 |
| 28 | TLSv1 | DHE-RSA-AES256-SHA | 0 |
+-----------+-------------+--------------------+---------------------+
3 rows in set (0.00 sec)
```
#### statement_analysis / x$statement_analysis
##### Description
Lists a normalized statement view with aggregated statistics, ordered by the total execution time per normalized statement
##### Structures
```SQL
mariadb> desc statement_analysis;
+-------------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| full_scan | varchar(1) | NO | | | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| err_count | bigint(20) unsigned | NO | | NULL | |
| warn_count | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
| lock_latency | text | YES | | NULL | |
| rows_sent | bigint(20) unsigned | NO | | NULL | |
| rows_sent_avg | decimal(21,0) | NO | | 0 | |
| rows_examined | bigint(20) unsigned | NO | | NULL | |
| rows_examined_avg | decimal(21,0) | NO | | 0 | |
| rows_affected | bigint(20) unsigned | NO | | NULL | |
| rows_affected_avg | decimal(21,0) | NO | | 0 | |
| tmp_tables | bigint(20) unsigned | NO | | NULL | |
| tmp_disk_tables | bigint(20) unsigned | NO | | NULL | |
| rows_sorted | bigint(20) unsigned | NO | | NULL | |
| sort_merge_passes | bigint(20) unsigned | NO | | NULL | |
| digest | varchar(32) | YES | | NULL | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
+-------------------+---------------------+------+-----+---------------------+-------+
23 rows in set (0.26 sec)
mariadb> desc x$statement_analysis;
+-------------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| full_scan | varchar(1) | NO | | | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| err_count | bigint(20) unsigned | NO | | NULL | |
| warn_count | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
| avg_latency | bigint(20) unsigned | NO | | NULL | |
| lock_latency | bigint(20) unsigned | NO | | NULL | |
| rows_sent | bigint(20) unsigned | NO | | NULL | |
| rows_sent_avg | decimal(21,0) | NO | | 0 | |
| rows_examined | bigint(20) unsigned | NO | | NULL | |
| rows_examined_avg | decimal(21,0) | NO | | 0 | |
| rows_affected | bigint(20) unsigned | NO | | NULL | |
| rows_affected_avg | decimal(21,0) | NO | | 0 | |
| tmp_tables | bigint(20) unsigned | NO | | NULL | |
| tmp_disk_tables | bigint(20) unsigned | NO | | NULL | |
| rows_sorted | bigint(20) unsigned | NO | | NULL | |
| sort_merge_passes | bigint(20) unsigned | NO | | NULL | |
| digest | varchar(32) | YES | | NULL | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
+-------------------+---------------------+------+-----+---------------------+-------+
23 rows in set (0.27 sec)
```
##### Example
```SQL
mariadb> select * from statement_analysis limit 1\G
*************************** 1. row ***************************
query: SELECT * FROM `schema_object_o ... MA` , `information_schema` ...
db: sys
full_scan: *
exec_count: 2
err_count: 0
warn_count: 0
total_latency: 16.75 s
max_latency: 16.57 s
avg_latency: 8.38 s
lock_latency: 16.69 s
rows_sent: 84
rows_sent_avg: 42
rows_examined: 20012
rows_examined_avg: 10006
rows_affected: 0
rows_affected_avg: 0
tmp_tables: 378
tmp_disk_tables: 66
rows_sorted: 168
sort_merge_passes: 0
digest: 54f9bd520f0bbf15db0c2ed93386bec9
first_seen: 2014-03-07 13:13:41
last_seen: 2014-03-07 13:13:48
```
#### statements_with_errors_or_warnings / x$statements_with_errors_or_warnings
##### Description
Lists all normalized statements that have raised errors or warnings.
##### Structures
```SQL
mariadb> desc statements_with_errors_or_warnings;
+-------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| errors | bigint(20) unsigned | NO | | NULL | |
| error_pct | decimal(27,4) | NO | | 0.0000 | |
| warnings | bigint(20) unsigned | NO | | NULL | |
| warning_pct | decimal(27,4) | NO | | 0.0000 | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| digest | varchar(32) | YES | | NULL | |
+-------------+---------------------+------+-----+---------------------+-------+
10 rows in set (0.55 sec)
mariadb> desc x$statements_with_errors_or_warnings;
+-------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| errors | bigint(20) unsigned | NO | | NULL | |
| error_pct | decimal(27,4) | NO | | 0.0000 | |
| warnings | bigint(20) unsigned | NO | | NULL | |
| warning_pct | decimal(27,4) | NO | | 0.0000 | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| digest | varchar(32) | YES | | NULL | |
+-------------+---------------------+------+-----+---------------------+-------+
10 rows in set (0.25 sec)
```
##### Example
```SQL
mariadb> select * from statements_with_errors_or_warnings LIMIT 1\G
*************************** 1. row ***************************
query: CREATE OR REPLACE ALGORITHM = ... _delete` AS `rows_deleted` ...
db: sys
exec_count: 2
errors: 1
error_pct: 50.0000
warnings: 0
warning_pct: 0.0000
first_seen: 2014-03-07 12:56:54
last_seen: 2014-03-07 13:01:01
digest: 943a788859e623d5f7798ba0ae0fd8a9
```
#### statements_with_full_table_scans / x$statements_with_full_table_scans
##### Description
Lists all normalized statements that use have done a full table scan ordered by number the percentage of times a full scan was done, then by the statement latency.
This view ignores SHOW statements, as these always cause a full table scan, and there is nothing that can be done about this.
##### Structures
```SQL
mariadb> desc statements_with_full_table_scans;
+--------------------------+------------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+------------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| no_index_used_count | bigint(20) unsigned | NO | | NULL | |
| no_good_index_used_count | bigint(20) unsigned | NO | | NULL | |
| no_index_used_pct | decimal(24,0) | NO | | 0 | |
| rows_sent | bigint(20) unsigned | NO | | NULL | |
| rows_examined | bigint(20) unsigned | NO | | NULL | |
| rows_sent_avg | decimal(21,0) unsigned | YES | | NULL | |
| rows_examined_avg | decimal(21,0) unsigned | YES | | NULL | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| digest | varchar(32) | YES | | NULL | |
+--------------------------+------------------------+------+-----+---------------------+-------+
14 rows in set (0.04 sec)
mariadb> desc x$statements_with_full_table_scans;
+--------------------------+------------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+------------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| no_index_used_count | bigint(20) unsigned | NO | | NULL | |
| no_good_index_used_count | bigint(20) unsigned | NO | | NULL | |
| no_index_used_pct | decimal(24,0) | NO | | 0 | |
| rows_sent | bigint(20) unsigned | NO | | NULL | |
| rows_examined | bigint(20) unsigned | NO | | NULL | |
| rows_sent_avg | decimal(21,0) unsigned | YES | | NULL | |
| rows_examined_avg | decimal(21,0) unsigned | YES | | NULL | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| digest | varchar(32) | YES | | NULL | |
+--------------------------+------------------------+------+-----+---------------------+-------+
14 rows in set (0.14 sec)
```
##### Example
```SQL
mariadb> select * from statements_with_full_table_scans limit 1\G
*************************** 1. row ***************************
query: SELECT * FROM `schema_tables_w ... ex_usage` . `COUNT_READ` DESC
db: sys
exec_count: 1
total_latency: 88.20 ms
no_index_used_count: 1
no_good_index_used_count: 0
no_index_used_pct: 100
rows_sent: 0
rows_examined: 1501
rows_sent_avg: 0
rows_examined_avg: 1501
first_seen: 2014-03-07 13:58:20
last_seen: 2014-03-07 13:58:20
digest: 64baecd5c1e1e1651a6b92e55442a288
```
#### statements_with_runtimes_in_95th_percentile / x$statements_with_runtimes_in_95th_percentile
##### Description
Lists all statements whose average runtime, in microseconds, is in the top 95th percentile.
Also includes two helper views:
* x$ps_digest_avg_latency_distribution
* x$ps_digest_95th_percentile_by_avg_us
##### Structures
```SQL
mariadb> desc statements_with_runtimes_in_95th_percentile;
+-------------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| full_scan | varchar(1) | NO | | | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| err_count | bigint(20) unsigned | NO | | NULL | |
| warn_count | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
| rows_sent | bigint(20) unsigned | NO | | NULL | |
| rows_sent_avg | decimal(21,0) | NO | | 0 | |
| rows_examined | bigint(20) unsigned | NO | | NULL | |
| rows_examined_avg | decimal(21,0) | NO | | 0 | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| digest | varchar(32) | YES | | NULL | |
+-------------------+---------------------+------+-----+---------------------+-------+
16 rows in set (0.11 sec)
mariadb> desc x$statements_with_runtimes_in_95th_percentile;
+-------------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| full_scan | varchar(1) | NO | | | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| err_count | bigint(20) unsigned | NO | | NULL | |
| warn_count | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
| avg_latency | bigint(20) unsigned | NO | | NULL | |
| rows_sent | bigint(20) unsigned | NO | | NULL | |
| rows_sent_avg | decimal(21,0) | NO | | 0 | |
| rows_examined | bigint(20) unsigned | NO | | NULL | |
| rows_examined_avg | decimal(21,0) | NO | | 0 | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| digest | varchar(32) | YES | | NULL | |
+-------------------+---------------------+------+-----+---------------------+-------+
16 rows in set (0.00 sec)
mariadb> desc x$ps_digest_avg_latency_distribution;
+--------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------------+------+-----+---------+-------+
| cnt | bigint(21) | NO | | 0 | |
| avg_us | decimal(21,0) | YES | | NULL | |
+--------+---------------+------+-----+---------+-------+
2 rows in set (0.10 sec)
mariadb> desc x$ps_digest_95th_percentile_by_avg_us;
+------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| avg_us | decimal(21,0) | YES | | NULL | |
| percentile | decimal(46,4) | NO | | 0.0000 | |
+------------+---------------+------+-----+---------+-------+
2 rows in set (0.15 sec)
```
##### Example
```SQL
mariadb> select * from statements_with_runtimes_in_95th_percentile\G
*************************** 1. row ***************************
query: SELECT * FROM `schema_object_o ... MA` , `information_schema` ...
db: sys
full_scan: *
exec_count: 2
err_count: 0
warn_count: 0
total_latency: 16.75 s
max_latency: 16.57 s
avg_latency: 8.38 s
rows_sent: 84
rows_sent_avg: 42
rows_examined: 20012
rows_examined_avg: 10006
first_seen: 2014-03-07 13:13:41
last_seen: 2014-03-07 13:13:48
digest: 54f9bd520f0bbf15db0c2ed93386bec9
```
#### statements_with_sorting / x$statements_with_sorting
##### Description
Lists all normalized statements that have done sorts, ordered by total_latency descending.
##### Structures
```SQL
mariadb> desc statements_with_sorting;
+-------------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| sort_merge_passes | bigint(20) unsigned | NO | | NULL | |
| avg_sort_merges | decimal(21,0) | NO | | 0 | |
| sorts_using_scans | bigint(20) unsigned | NO | | NULL | |
| sort_using_range | bigint(20) unsigned | NO | | NULL | |
| rows_sorted | bigint(20) unsigned | NO | | NULL | |
| avg_rows_sorted | decimal(21,0) | NO | | 0 | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| digest | varchar(32) | YES | | NULL | |
+-------------------+---------------------+------+-----+---------------------+-------+
13 rows in set (0.01 sec)
mariadb> desc x$statements_with_sorting;
+-------------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| sort_merge_passes | bigint(20) unsigned | NO | | NULL | |
| avg_sort_merges | decimal(21,0) | NO | | 0 | |
| sorts_using_scans | bigint(20) unsigned | NO | | NULL | |
| sort_using_range | bigint(20) unsigned | NO | | NULL | |
| rows_sorted | bigint(20) unsigned | NO | | NULL | |
| avg_rows_sorted | decimal(21,0) | NO | | 0 | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| digest | varchar(32) | YES | | NULL | |
+-------------------+---------------------+------+-----+---------------------+-------+
13 rows in set (0.04 sec)
```
##### Example
```SQL
mariadb> select * from statements_with_sorting limit 1\G
*************************** 1. row ***************************
query: SELECT * FROM `schema_object_o ... MA` , `information_schema` ...
db: sys
exec_count: 2
total_latency: 16.75 s
sort_merge_passes: 0
avg_sort_merges: 0
sorts_using_scans: 12
sort_using_range: 0
rows_sorted: 168
avg_rows_sorted: 84
first_seen: 2014-03-07 13:13:41
last_seen: 2014-03-07 13:13:48
digest: 54f9bd520f0bbf15db0c2ed93386bec9
```
#### statements_with_temp_tables / x$statements_with_temp_tables
##### Description
Lists all normalized statements that use temporary tables ordered by number of on disk temporary tables descending first, then by the number of memory tables.
##### Structures
```SQL
mariadb> desc statements_with_temp_tables;
+--------------------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+---------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| memory_tmp_tables | bigint(20) unsigned | NO | | NULL | |
| disk_tmp_tables | bigint(20) unsigned | NO | | NULL | |
| avg_tmp_tables_per_query | decimal(21,0) | NO | | 0 | |
| tmp_tables_to_disk_pct | decimal(24,0) | NO | | 0 | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| digest | varchar(32) | YES | | NULL | |
+--------------------------+---------------------+------+-----+---------------------+-------+
11 rows in set (0.30 sec)
mariadb> desc x$statements_with_temp_tables;
+--------------------------+---------------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+---------------------+------+-----+---------------------+-------+
| query | longtext | YES | | NULL | |
| db | varchar(64) | YES | | NULL | |
| exec_count | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| memory_tmp_tables | bigint(20) unsigned | NO | | NULL | |
| disk_tmp_tables | bigint(20) unsigned | NO | | NULL | |
| avg_tmp_tables_per_query | decimal(21,0) | NO | | 0 | |
| tmp_tables_to_disk_pct | decimal(24,0) | NO | | 0 | |
| first_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| last_seen | timestamp | NO | | 0000-00-00 00:00:00 | |
| digest | varchar(32) | YES | | NULL | |
+--------------------------+---------------------+------+-----+---------------------+-------+
11 rows in set (0.05 sec)
```
##### Example
```SQL
mariadb> select * from statements_with_temp_tables limit 1\G
*************************** 1. row ***************************
query: SELECT * FROM `schema_object_o ... MA` , `information_schema` ...
db: sys
exec_count: 2
total_latency: 16.75 s
memory_tmp_tables: 378
disk_tmp_tables: 66
avg_tmp_tables_per_query: 189
tmp_tables_to_disk_pct: 17
first_seen: 2014-03-07 13:13:41
last_seen: 2014-03-07 13:13:48
digest: 54f9bd520f0bbf15db0c2ed93386bec9
```
#### user_summary / x$user_summary
##### Description
Summarizes statement activity, file IO and connections by user.
When the user found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc user_summary;
+------------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+---------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| statements | decimal(64,0) | YES | | NULL | |
| statement_latency | text | YES | | NULL | |
| statement_avg_latency | text | YES | | NULL | |
| table_scans | decimal(65,0) | YES | | NULL | |
| file_ios | decimal(64,0) | YES | | NULL | |
| file_io_latency | text | YES | | NULL | |
| current_connections | decimal(41,0) | YES | | NULL | |
| total_connections | decimal(41,0) | YES | | NULL | |
| unique_hosts | bigint(21) | NO | | 0 | |
| current_memory | text | YES | | NULL | |
| total_memory_allocated | text | YES | | NULL | |
+------------------------+---------------+------+-----+---------+-------+
12 rows in set (0.00 sec)
mariadb> desc x$user_summary;
+------------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+---------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| statements | decimal(64,0) | YES | | NULL | |
| statement_latency | decimal(64,0) | YES | | NULL | |
| statement_avg_latency | decimal(65,4) | NO | | 0.0000 | |
| table_scans | decimal(65,0) | YES | | NULL | |
| file_ios | decimal(64,0) | YES | | NULL | |
| file_io_latency | decimal(64,0) | YES | | NULL | |
| current_connections | decimal(41,0) | YES | | NULL | |
| total_connections | decimal(41,0) | YES | | NULL | |
| unique_hosts | bigint(21) | NO | | 0 | |
| current_memory | decimal(63,0) | YES | | NULL | |
| total_memory_allocated | decimal(64,0) | YES | | NULL | |
+------------------------+---------------+------+-----+---------+-------+
12 rows in set (0.01 sec)
```
##### Example
```SQL
mariadb> select * from user_summary\G
*************************** 1. row ***************************
user: root
statements: 4981
statement_latency: 26.54 s
statement_avg_latency: 5.33 ms
table_scans: 74
file_ios: 7792
file_io_latency: 40.08 s
current_connections: 1
total_connections: 2
unique_hosts: 1
current_memory: 3.57 MiB
total_memory_allocated: 83.37 MiB
*************************** 2. row ***************************
user: background
statements: 0
statement_latency: 0 ps
statement_avg_latency: 0 ps
table_scans: 0
file_ios: 1618
file_io_latency: 4.78 s
current_connections: 21
total_connections: 23
unique_hosts: 0
current_memory: 165.94 MiB
total_memory_allocated: 197.29 MiB
```
#### user_summary_by_file_io / x$user_summary_by_file_io
##### Description
Summarizes file IO totals per user.
When the user found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc user_summary_by_file_io;
+------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| ios | decimal(42,0) | YES | | NULL | |
| io_latency | text | YES | | NULL | |
+------------+---------------+------+-----+---------+-------+
3 rows in set (0.20 sec)
mariadb> desc x$user_summary_by_file_io;
+------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| ios | decimal(42,0) | YES | | NULL | |
| io_latency | decimal(42,0) | YES | | NULL | |
+------------+---------------+------+-----+---------+-------+
3 rows in set (0.02 sec)
```
##### Example
```SQL
mariadb> select * from user_summary_by_file_io;
+------------+-------+------------+
| user | ios | io_latency |
+------------+-------+------------+
| root | 26457 | 21.58 s |
| background | 1189 | 394.21 ms |
+------------+-------+------------+
```
#### user_summary_by_file_io_type / x$user_summary_by_file_io_type
##### Description
Summarizes file IO by event type per user.
When the user found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc user_summary_by_file_io_type;
+-------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| event_name | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
+-------------+---------------------+------+-----+---------+-------+
5 rows in set (0.02 sec)
mariadb> desc x$user_summary_by_file_io_type;
+-------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| event_name | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
+-------------+---------------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
```
##### Example
```SQL
mariadb> select * from user_summary_by_file_io_type;
+------------+--------------------------------------+-------+-----------+-------------+
| user | event_name | total | latency | max_latency |
+------------+--------------------------------------+-------+-----------+-------------+
| background | wait/io/file/innodb/innodb_data_file | 1434 | 3.29 s | 147.56 ms |
| background | wait/io/file/sql/FRM | 910 | 286.61 ms | 32.92 ms |
| background | wait/io/file/sql/relaylog | 9 | 252.28 ms | 144.17 ms |
| background | wait/io/file/sql/binlog | 56 | 193.73 ms | 153.72 ms |
| background | wait/io/file/sql/binlog_index | 22 | 183.02 ms | 81.83 ms |
| background | wait/io/file/innodb/innodb_log_file | 20 | 117.17 ms | 36.53 ms |
| background | wait/io/file/sql/relaylog_index | 9 | 50.15 ms | 48.04 ms |
| background | wait/io/file/sql/ERRMSG | 5 | 35.41 ms | 31.78 ms |
| background | wait/io/file/myisam/kfile | 67 | 18.14 ms | 9.00 ms |
| background | wait/io/file/mysys/charset | 3 | 7.46 ms | 4.13 ms |
| background | wait/io/file/sql/casetest | 5 | 6.01 ms | 5.86 ms |
| background | wait/io/file/sql/pid | 3 | 5.96 ms | 3.06 ms |
| background | wait/io/file/myisam/dfile | 43 | 980.38 us | 152.46 us |
| background | wait/io/file/mysys/cnf | 5 | 154.97 us | 58.87 us |
| background | wait/io/file/sql/global_ddl_log | 2 | 18.64 us | 16.40 us |
| root | wait/io/file/sql/file_parser | 11048 | 48.79 s | 201.11 ms |
| root | wait/io/file/innodb/innodb_data_file | 4699 | 3.02 s | 46.93 ms |
| root | wait/io/file/sql/FRM | 10403 | 2.38 s | 61.72 ms |
| root | wait/io/file/myisam/dfile | 22143 | 726.77 ms | 308.79 ms |
| root | wait/io/file/myisam/kfile | 6213 | 435.35 ms | 88.76 ms |
| root | wait/io/file/sql/dbopt | 159 | 130.86 ms | 15.46 ms |
| root | wait/io/file/csv/metadata | 8 | 86.60 ms | 50.32 ms |
| root | wait/io/file/sql/binlog | 15 | 38.79 ms | 9.40 ms |
| root | wait/io/file/sql/misc | 21 | 22.33 ms | 15.30 ms |
| root | wait/io/file/csv/data | 4 | 297.46 us | 111.93 us |
| root | wait/io/file/archive/data | 3 | 54.10 us | 40.74 us |
+------------+--------------------------------------+-------+-----------+-------------+
```
#### user_summary_by_stages / x$user_summary_by_stages
##### Description
Summarizes stages by user, ordered by user and total latency per stage.
When the user found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc user_summary_by_stages;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| event_name | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
5 rows in set (0.01 sec)
mariadb> desc x$user_summary_by_stages;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| user | varchar(16) | YES | | NULL | |
| event_name | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| avg_latency | bigint(20) unsigned | NO | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
5 rows in set (0.05 sec)
```
##### Example
```SQL
mariadb> select * from user_summary_by_stages;
+------+--------------------------------+-------+---------------+-------------+
| user | event_name | total | total_latency | avg_latency |
+------+--------------------------------+-------+---------------+-------------+
| root | stage/sql/Opening tables | 889 | 1.97 ms | 2.22 us |
| root | stage/sql/Creating sort index | 4 | 1.79 ms | 446.30 us |
| root | stage/sql/init | 10 | 312.27 us | 31.23 us |
| root | stage/sql/checking permissions | 10 | 300.62 us | 30.06 us |
| root | stage/sql/freeing items | 5 | 85.89 us | 17.18 us |
| root | stage/sql/statistics | 5 | 79.15 us | 15.83 us |
| root | stage/sql/preparing | 5 | 69.12 us | 13.82 us |
| root | stage/sql/optimizing | 5 | 53.11 us | 10.62 us |
| root | stage/sql/Sending data | 5 | 44.66 us | 8.93 us |
| root | stage/sql/closing tables | 5 | 37.54 us | 7.51 us |
| root | stage/sql/System lock | 5 | 34.28 us | 6.86 us |
| root | stage/sql/query end | 5 | 24.37 us | 4.87 us |
| root | stage/sql/end | 5 | 8.60 us | 1.72 us |
| root | stage/sql/Sorting result | 5 | 8.33 us | 1.67 us |
| root | stage/sql/executing | 5 | 5.37 us | 1.07 us |
| root | stage/sql/cleaning up | 5 | 4.60 us | 919.00 ns |
+------+--------------------------------+-------+---------------+-------------+
```
#### user_summary_by_statement_latency / x$user_summary_by_statement_latency
##### Description
Summarizes overall statement statistics by user.
When the user found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc user_summary_by_statement_latency;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| total | decimal(42,0) | YES | | NULL | |
| total_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
| lock_latency | text | YES | | NULL | |
| rows_sent | decimal(42,0) | YES | | NULL | |
| rows_examined | decimal(42,0) | YES | | NULL | |
| rows_affected | decimal(42,0) | YES | | NULL | |
| full_scans | decimal(43,0) | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
9 rows in set (0.00 sec)
mariadb> desc x$user_summary_by_statement_latency;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| total | decimal(42,0) | YES | | NULL | |
| total_latency | decimal(42,0) | YES | | NULL | |
| max_latency | decimal(42,0) | YES | | NULL | |
| lock_latency | decimal(42,0) | YES | | NULL | |
| rows_sent | decimal(42,0) | YES | | NULL | |
| rows_examined | decimal(42,0) | YES | | NULL | |
| rows_affected | decimal(42,0) | YES | | NULL | |
| full_scans | decimal(43,0) | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
9 rows in set (0.28 sec)
```
##### Example
```SQL
mariadb> select * from user_summary_by_statement_latency;
+------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
| user | total | total_latency | max_latency | lock_latency | rows_sent | rows_examined | rows_affected | full_scans |
+------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
| root | 3381 | 00:02:09.13 | 1.48 s | 1.07 s | 1151 | 93947 | 150 | 91 |
+------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
```
#### user_summary_by_statement_type / x$user_summary_by_statement_type
##### Description
Summarizes the types of statements executed by each user.
When the user found is NULL, it is assumed to be a "background" thread.
##### Structures
```SQL
mariadb> desc user_summary_by_statement_type;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| statement | varchar(128) | YES | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
| lock_latency | text | YES | | NULL | |
| rows_sent | bigint(20) unsigned | NO | | NULL | |
| rows_examined | bigint(20) unsigned | NO | | NULL | |
| rows_affected | bigint(20) unsigned | NO | | NULL | |
| full_scans | bigint(21) unsigned | NO | | 0 | |
+---------------+---------------------+------+-----+---------+-------+
10 rows in set (0.21 sec)
mariadb> desc x$user_summary_by_statement_type;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| statement | varchar(128) | YES | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
| lock_latency | bigint(20) unsigned | NO | | NULL | |
| rows_sent | bigint(20) unsigned | NO | | NULL | |
| rows_examined | bigint(20) unsigned | NO | | NULL | |
| rows_affected | bigint(20) unsigned | NO | | NULL | |
| full_scans | bigint(21) unsigned | NO | | 0 | |
+---------------+---------------------+------+-----+---------+-------+
10 rows in set (0.37 sec)
```
##### Example
```SQL
mariadb> select * from user_summary_by_statement_type;
+------+------------------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
| user | statement | total | total_latency | max_latency | lock_latency | rows_sent | rows_examined | rows_affected | full_scans |
+------+------------------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
| root | create_view | 1332 | 00:03:39.08 | 677.76 ms | 494.56 ms | 0 | 0 | 0 | 0 |
| root | select | 88 | 20.13 s | 16.57 s | 17.40 s | 1804 | 77285 | 0 | 48 |
| root | drop_db | 16 | 6.83 s | 1.14 s | 5.73 s | 0 | 0 | 953 | 0 |
| root | drop_view | 392 | 1.70 s | 739.49 ms | 0 ps | 0 | 0 | 0 | 0 |
| root | show_databases | 16 | 1.37 s | 587.44 ms | 1.31 ms | 400 | 400 | 0 | 16 |
| root | show_tables | 34 | 676.78 ms | 167.04 ms | 3.46 ms | 1087 | 1087 | 0 | 34 |
| root | create_db | 22 | 334.90 ms | 38.93 ms | 0 ps | 0 | 0 | 22 | 0 |
| root | create_procedure | 352 | 250.02 ms | 21.90 ms | 165.17 ms | 0 | 0 | 0 | 0 |
| root | drop_function | 176 | 122.44 ms | 69.18 ms | 87.24 ms | 0 | 0 | 0 | 0 |
| root | create_function | 176 | 76.12 ms | 1.36 ms | 49.50 ms | 0 | 0 | 0 | 0 |
| root | drop_procedure | 352 | 67.41 ms | 1.57 ms | 36.22 ms | 0 | 0 | 0 | 0 |
| root | update | 2 | 41.75 ms | 35.96 ms | 35.52 ms | 0 | 557 | 338 | 0 |
| root | error | 3 | 17.22 ms | 17.05 ms | 0 ps | 0 | 0 | 0 | 0 |
| root | set_option | 88 | 8.02 ms | 1.63 ms | 0 ps | 0 | 0 | 0 | 0 |
| root | call_procedure | 2 | 2.98 ms | 2.29 ms | 95.00 us | 0 | 0 | 0 | 0 |
| root | Init DB | 22 | 1.07 ms | 117.65 us | 0 ps | 0 | 0 | 0 | 0 |
| root | show_status | 1 | 408.69 us | 408.69 us | 102.00 us | 23 | 23 | 0 | 1 |
+------+------------------+-------+---------------+-------------+--------------+-----------+---------------+---------------+------------+
```
#### wait_classes_global_by_avg_latency / x$wait_classes_global_by_avg_latency
##### Description
Lists the top wait classes by average latency, ignoring idle (this may be very large).
##### Structures
```SQL
mariadb> desc wait_classes_global_by_avg_latency;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| event_class | varchar(128) | YES | | NULL | |
| total | decimal(42,0) | YES | | NULL | |
| total_latency | text | YES | | NULL | |
| min_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
6 rows in set (0.11 sec)
mariadb> desc x$wait_classes_global_by_avg_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| event_class | varchar(128) | YES | | NULL | |
| total | decimal(42,0) | YES | | NULL | |
| total_latency | decimal(42,0) | YES | | NULL | |
| min_latency | bigint(20) unsigned | YES | | NULL | |
| avg_latency | decimal(46,4) | NO | | 0.0000 | |
| max_latency | bigint(20) unsigned | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
6 rows in set (0.02 sec)
```
##### Example
```SQL
mariadb> select * from wait_classes_global_by_avg_latency where event_class != 'idle';
+-------------------+--------+---------------+-------------+-------------+-------------+
| event_class | total | total_latency | min_latency | avg_latency | max_latency |
+-------------------+--------+---------------+-------------+-------------+-------------+
| wait/io/file | 543123 | 44.60 s | 19.44 ns | 82.11 us | 4.21 s |
| wait/io/table | 22002 | 766.60 ms | 148.72 ns | 34.84 us | 44.97 ms |
| wait/io/socket | 79613 | 967.17 ms | 0 ps | 12.15 us | 27.10 ms |
| wait/lock/table | 35409 | 18.68 ms | 65.45 ns | 527.51 ns | 969.88 us |
| wait/synch/rwlock | 37935 | 4.61 ms | 21.38 ns | 121.61 ns | 34.65 us |
| wait/synch/mutex | 390622 | 18.60 ms | 19.44 ns | 47.61 ns | 10.32 us |
+-------------------+--------+---------------+-------------+-------------+-------------+
```
#### wait_classes_global_by_latency / x$wait_classes_global_by_latency
##### Description
Lists the top wait classes by total latency, ignoring idle (this may be very large).
##### Structures
```SQL
mariadb> desc wait_classes_global_by_latency;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| event_class | varchar(128) | YES | | NULL | |
| total | decimal(42,0) | YES | | NULL | |
| total_latency | text | YES | | NULL | |
| min_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
mariadb> desc x$wait_classes_global_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| event_class | varchar(128) | YES | | NULL | |
| total | decimal(42,0) | YES | | NULL | |
| total_latency | decimal(42,0) | YES | | NULL | |
| min_latency | bigint(20) unsigned | YES | | NULL | |
| avg_latency | decimal(46,4) | NO | | 0.0000 | |
| max_latency | bigint(20) unsigned | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
6 rows in set (0.02 sec)
```
##### Example
```SQL
mariadb> select * from wait_classes_global_by_latency;
+-------------------+--------+---------------+-------------+-------------+-------------+
| event_class | total | total_latency | min_latency | avg_latency | max_latency |
+-------------------+--------+---------------+-------------+-------------+-------------+
| wait/io/file | 550470 | 46.01 s | 19.44 ns | 83.58 us | 4.21 s |
| wait/io/socket | 228833 | 2.71 s | 0 ps | 11.86 us | 29.93 ms |
| wait/io/table | 64063 | 1.89 s | 99.79 ns | 29.43 us | 68.07 ms |
| wait/lock/table | 76029 | 47.19 ms | 65.45 ns | 620.74 ns | 969.88 us |
| wait/synch/mutex | 635925 | 34.93 ms | 19.44 ns | 54.93 ns | 107.70 us |
| wait/synch/rwlock | 61287 | 7.62 ms | 21.38 ns | 124.37 ns | 34.65 us |
+-------------------+--------+---------------+-------------+-------------+-------------+
```
#### waits_by_user_by_latency / x$waits_by_user_by_latency
##### Description
Lists the top wait events per user by their total latency, ignoring idle (this may be very large) per user.
##### Structures
```SQL
mariadb> desc waits_by_user_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| event | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
mariadb> desc x$waits_by_user_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| user | varchar(32) | YES | | NULL | |
| event | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| avg_latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
6 rows in set (0.30 sec)
```
##### Example
```SQL
mariadb> select * from waits_by_user_by_latency;
+------+-----------------------------------------------------+--------+---------------+-------------+-------------+
| user | event | total | total_latency | avg_latency | max_latency |
+------+-----------------------------------------------------+--------+---------------+-------------+-------------+
| root | wait/io/file/sql/file_parser | 13743 | 00:01:00.46 | 4.40 ms | 231.88 ms |
| root | wait/io/file/innodb/innodb_data_file | 4699 | 3.02 s | 643.38 us | 46.93 ms |
| root | wait/io/file/sql/FRM | 11462 | 2.60 s | 226.83 us | 61.72 ms |
| root | wait/io/file/myisam/dfile | 26776 | 746.70 ms | 27.89 us | 308.79 ms |
| root | wait/io/file/myisam/kfile | 7126 | 462.66 ms | 64.93 us | 88.76 ms |
| root | wait/io/file/sql/dbopt | 179 | 137.58 ms | 768.59 us | 15.46 ms |
| root | wait/io/file/csv/metadata | 8 | 86.60 ms | 10.82 ms | 50.32 ms |
| root | wait/synch/mutex/mysys/IO_CACHE::append_buffer_lock | 798080 | 66.46 ms | 82.94 ns | 161.03 us |
| root | wait/io/file/sql/binlog | 19 | 49.11 ms | 2.58 ms | 9.40 ms |
| root | wait/io/file/sql/misc | 26 | 22.38 ms | 860.80 us | 15.30 ms |
| root | wait/io/file/csv/data | 4 | 297.46 us | 74.37 us | 111.93 us |
| root | wait/synch/rwlock/sql/MDL_lock::rwlock | 944 | 287.86 us | 304.62 ns | 874.64 ns |
| root | wait/io/file/archive/data | 4 | 82.71 us | 20.68 us | 40.74 us |
| root | wait/synch/mutex/myisam/MYISAM_SHARE::intern_lock | 60 | 12.21 us | 203.20 ns | 512.72 ns |
| root | wait/synch/mutex/innodb/trx_mutex | 81 | 5.93 us | 73.14 ns | 252.59 ns |
+------+-----------------------------------------------------+--------+---------------+-------------+-------------+
```
#### waits_by_host_by_latency / x$waits_by_host_by_latency
##### Description
Lists the top wait events per host by their total latency, ignoring idle (this may be very large) per host.
##### Structures
```SQL
mariadb> desc waits_by_host_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| event | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
6 rows in set (0.36 sec)
mariadb> desc x$waits_by_host_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| event | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| avg_latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
6 rows in set (0.25 sec)
```
##### Example
```SQL
mariadb> select * from waits_by_host_by_latency;
+------+-----------------------------------------------------+--------+---------------+-------------+-------------+
| host | event | total | total_latency | avg_latency | max_latency |
+------+-----------------------------------------------------+--------+---------------+-------------+-------------+
| hal1 | wait/io/file/sql/file_parser | 13743 | 00:01:00.46 | 4.40 ms | 231.88 ms |
| hal1 | wait/io/file/innodb/innodb_data_file | 4699 | 3.02 s | 643.38 us | 46.93 ms |
| hal1 | wait/io/file/sql/FRM | 11462 | 2.60 s | 226.83 us | 61.72 ms |
| hal1 | wait/io/file/myisam/dfile | 26776 | 746.70 ms | 27.89 us | 308.79 ms |
| hal1 | wait/io/file/myisam/kfile | 7126 | 462.66 ms | 64.93 us | 88.76 ms |
| hal1 | wait/io/file/sql/dbopt | 179 | 137.58 ms | 768.59 us | 15.46 ms |
| hal1 | wait/io/file/csv/metadata | 8 | 86.60 ms | 10.82 ms | 50.32 ms |
| hal1 | wait/synch/mutex/mysys/IO_CACHE::append_buffer_lock | 798080 | 66.46 ms | 82.94 ns | 161.03 us |
| hal1 | wait/io/file/sql/binlog | 19 | 49.11 ms | 2.58 ms | 9.40 ms |
| hal1 | wait/io/file/sql/misc | 26 | 22.38 ms | 860.80 us | 15.30 ms |
| hal1 | wait/io/file/csv/data | 4 | 297.46 us | 74.37 us | 111.93 us |
| hal1 | wait/synch/rwlock/sql/MDL_lock::rwlock | 944 | 287.86 us | 304.62 ns | 874.64 ns |
| hal1 | wait/io/file/archive/data | 4 | 82.71 us | 20.68 us | 40.74 us |
| hal1 | wait/synch/mutex/myisam/MYISAM_SHARE::intern_lock | 60 | 12.21 us | 203.20 ns | 512.72 ns |
| hal1 | wait/synch/mutex/innodb/trx_mutex | 81 | 5.93 us | 73.14 ns | 252.59 ns |
+------+-----------------------------------------------------+--------+---------------+-------------+-------------+
```
#### waits_global_by_latency / x$waits_global_by_latency
##### Description
Lists the top wait events by their total latency, ignoring idle (this may be very large).
##### Structures
```SQL
mariadb> desc waits_global_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| events | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | text | YES | | NULL | |
| avg_latency | text | YES | | NULL | |
| max_latency | text | YES | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
5 rows in set (0.01 sec)
mariadb> desc x$waits_global_by_latency;
+---------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| events | varchar(128) | NO | | NULL | |
| total | bigint(20) unsigned | NO | | NULL | |
| total_latency | bigint(20) unsigned | NO | | NULL | |
| avg_latency | bigint(20) unsigned | NO | | NULL | |
| max_latency | bigint(20) unsigned | NO | | NULL | |
+---------------+---------------------+------+-----+---------+-------+
5 rows in set (0.03 sec)
```
##### Example
```SQL
mariadb> select * from waits_global_by_latency;
+-----------------------------------------------------+---------+---------------+-------------+-------------+
| events | total | total_latency | avg_latency | max_latency |
+-----------------------------------------------------+---------+---------------+-------------+-------------+
| wait/io/file/sql/file_parser | 14936 | 00:01:06.64 | 4.46 ms | 231.88 ms |
| wait/io/file/innodb/innodb_data_file | 6133 | 6.31 s | 1.03 ms | 147.56 ms |
| wait/io/file/sql/FRM | 12677 | 2.83 s | 223.37 us | 40.86 ms |
| wait/io/file/myisam/dfile | 28446 | 754.40 ms | 26.52 us | 308.79 ms |
| wait/io/file/myisam/kfile | 7572 | 491.17 ms | 64.87 us | 88.76 ms |
| wait/io/file/sql/relaylog | 9 | 252.28 ms | 28.03 ms | 144.17 ms |
| wait/io/file/sql/binlog | 76 | 242.87 ms | 3.20 ms | 153.72 ms |
| wait/io/file/sql/binlog_index | 21 | 173.07 ms | 8.24 ms | 81.83 ms |
| wait/io/file/sql/dbopt | 184 | 149.52 ms | 812.62 us | 15.46 ms |
| wait/io/file/innodb/innodb_log_file | 20 | 117.17 ms | 5.86 ms | 36.53 ms |
| wait/synch/mutex/mysys/IO_CACHE::append_buffer_lock | 1197128 | 99.27 ms | 82.56 ns | 161.03 us |
| wait/io/file/csv/metadata | 8 | 86.60 ms | 10.82 ms | 50.32 ms |
| wait/io/file/sql/relaylog_index | 10 | 60.10 ms | 6.01 ms | 48.04 ms |
| wait/io/file/sql/ERRMSG | 5 | 35.41 ms | 7.08 ms | 31.78 ms |
| wait/io/file/sql/misc | 28 | 22.40 ms | 800.06 us | 15.30 ms |
| wait/io/file/mysys/charset | 3 | 7.46 ms | 2.49 ms | 4.13 ms |
| wait/io/file/sql/casetest | 5 | 6.01 ms | 1.20 ms | 5.86 ms |
| wait/io/file/sql/pid | 3 | 5.96 ms | 1.99 ms | 3.06 ms |
| wait/synch/rwlock/sql/MDL_lock::rwlock | 1396 | 420.58 us | 301.22 ns | 874.64 ns |
| wait/io/file/csv/data | 4 | 297.46 us | 74.37 us | 111.93 us |
| wait/io/file/mysys/cnf | 5 | 154.97 us | 30.99 us | 58.87 us |
| wait/io/file/archive/data | 4 | 82.71 us | 20.68 us | 40.74 us |
| wait/synch/mutex/myisam/MYISAM_SHARE::intern_lock | 90 | 19.23 us | 213.38 ns | 576.81 ns |
| wait/io/file/sql/global_ddl_log | 2 | 18.64 us | 9.32 us | 16.40 us |
| wait/synch/mutex/innodb/trx_mutex | 108 | 8.23 us | 76.15 ns | 365.69 ns |
+-----------------------------------------------------+---------+---------------+-------------+-------------+
```
### Functions
#### extract_schema_from_file_name
##### Description
Takes a raw file path, and attempts to extract the schema name from it.
Useful for when interacting with Performance Schema data concerning IO statistics, for example.
Currently relies on the fact that a table data file will be within a specified database directory (will not work with partitions or tables that specify an individual DATA_DIRECTORY).
##### Parameters
* path (VARCHAR(512)): The full file path to a data file to extract the schema name from.
##### Returns
VARCHAR(64)
##### Example
```SQL
mariadb> SELECT sys.extract_schema_from_file_name('/var/lib/mysql/employees/employee.ibd');
+----------------------------------------------------------------------------+
| sys.extract_schema_from_file_name('/var/lib/mysql/employees/employee.ibd') |
+----------------------------------------------------------------------------+
| employees |
+----------------------------------------------------------------------------+
1 row in set (0.00 sec)
```
#### extract_table_from_file_name
##### Description
Takes a raw file path, and extracts the table name from it.
Useful for when interacting with Performance Schema data concerning IO statistics, for example.
##### Parameters
* path (VARCHAR(512)): The full file path to a data file to extract the table name from.
##### Returns
VARCHAR(64)
##### Example
```SQL
mariadb> SELECT sys.extract_table_from_file_name('/var/lib/mysql/employees/employee.ibd');
+---------------------------------------------------------------------------+
| sys.extract_table_from_file_name('/var/lib/mysql/employees/employee.ibd') |
+---------------------------------------------------------------------------+
| employee |
+---------------------------------------------------------------------------+
1 row in set (0.02 sec)
```
#### format_bytes
##### Description
Takes a raw bytes value, and converts it to a human readable format.
##### Parameters
* bytes (TEXT): A raw bytes value.
##### Returns
TEXT
##### Example
```SQL
mariadb> SELECT format_bytes(2348723492723746) AS size;
+----------+
| size |
+----------+
| 2.09 PiB |
+----------+
1 row in set (0.00 sec)
mariadb> SELECT format_bytes(2348723492723) AS size;
+----------+
| size |
+----------+
| 2.14 TiB |
+----------+
1 row in set (0.00 sec)
mariadb> SELECT format_bytes(23487234) AS size;
+-----------+
| size |
+-----------+
| 22.40 MiB |
+-----------+
1 row in set (0.00 sec)
```
#### format_path
##### Description
Takes a raw path value, and strips out the datadir or tmpdir replacing with @@datadir and @@tmpdir respectively.
Also normalizes the paths across operating systems, so backslashes on Windows are converted to forward slashes.
##### Parameters
* path (VARCHAR(512)): The raw file path value to format.
##### Returns
VARCHAR(512) CHARSET UTF8
##### Example
```SQL
mariadb> select @@datadir;
+-----------------------------------------------+
| @@datadir |
+-----------------------------------------------+
| /Users/mark/sandboxes/SmallTree/AMaster/data/ |
+-----------------------------------------------+
1 row in set (0.06 sec)
mariadb> select format_path('/Users/mark/sandboxes/SmallTree/AMaster/data/mysql/proc.MYD') AS path;
+--------------------------+
| path |
+--------------------------+
| @@datadir/mysql/proc.MYD |
+--------------------------+
1 row in set (0.03 sec)
```
#### format_statement
##### Description
Formats a normalized statement, truncating it if it is > 64 characters long by default.
To configure the length to truncate the statement to by default, update the `statement_truncate_len` variable with `sys_config` table to a different value. Alternatively, to change it just for just your particular session, use `SET @sys.statement_truncate_len := <some new value>`.
Useful for printing statement related data from Performance Schema from the command line.
##### Parameters
* statement (LONGTEXT): The statement to format.
##### Returns
LONGTEXT
##### Example
```SQL
mariadb> SELECT sys.format_statement(digest_text)
-> FROM performance_schema.events_statements_summary_by_digest
-> ORDER by sum_timer_wait DESC limit 5;
+-------------------------------------------------------------------+
| sys.format_statement(digest_text) |
+-------------------------------------------------------------------+
| CREATE SQL SECURITY INVOKER VI ... KE ? AND `variable_value` > ? |
| CREATE SQL SECURITY INVOKER VI ... ait` IS NOT NULL , `esc` . ... |
| CREATE SQL SECURITY INVOKER VI ... ait` IS NOT NULL , `sys` . ... |
| CREATE SQL SECURITY INVOKER VI ... , `compressed_size` ) ) DESC |
| CREATE SQL SECURITY INVOKER VI ... LIKE ? ORDER BY `timer_start` |
+-------------------------------------------------------------------+
5 rows in set (0.00 sec)
```
#### format_time
##### Description
Takes a raw picoseconds value, and converts it to a human readable form.
Picoseconds are the precision that all latency values are printed in within Performance Schema, however are not user friendly when wanting to scan output from the command line.
##### Parameters
* picoseconds (TEXT): The raw picoseconds value to convert.
##### Returns
TEXT
##### Example
```SQL
mariadb> select format_time(342342342342345);
+------------------------------+
| format_time(342342342342345) |
+------------------------------+
| 00:05:42 |
+------------------------------+
1 row in set (0.00 sec)
mariadb> select format_time(342342342);
+------------------------+
| format_time(342342342) |
+------------------------+
| 342.34 us |
+------------------------+
1 row in set (0.00 sec)
mariadb> select format_time(34234);
+--------------------+
| format_time(34234) |
+--------------------+
| 34.23 ns |
+--------------------+
1 row in set (0.00 sec)
```
#### list_add
##### Description
Takes a list, and a value to add to the list, and returns the resulting list.
Useful for altering certain session variables, like sql_mode or optimizer_switch for instance.
##### Parameters
in_list (TEXT): The comma separated list to add a value to
in_add_value (TEXT): The value to add to the input list
##### Returns
TEXT
##### Example
```SQL
mariadb> select @@sql_mode;
+-----------------------------------------------------------------------------------+
| @@sql_mode |
+-----------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mariadb> set sql_mode = sys.list_add(@@sql_mode, 'ANSI_QUOTES');
Query OK, 0 rows affected (0.06 sec)
mariadb> select @@sql_mode;
+-----------------------------------------------------------------------------------------------+
| @@sql_mode |
+-----------------------------------------------------------------------------------------------+
| ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```
#### list_drop
##### Description
Takes a list, and a value to attempt to remove from the list, and returns the resulting list.
Useful for altering certain session variables, like sql_mode or optimizer_switch for instance.
##### Parameters
in_list (TEXT): The comma separated list to drop a value from
in_drop_value (TEXT): The value to drop from the input list
##### Returns
TEXT
##### Example
```SQL
mariadb> select @@sql_mode;
+-----------------------------------------------------------------------------------------------+
| @@sql_mode |
+-----------------------------------------------------------------------------------------------+
| ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mariadb> set sql_mode = sys.list_drop(@@sql_mode, 'ONLY_FULL_GROUP_BY');
Query OK, 0 rows affected (0.03 sec)
mariadb> select @@sql_mode;
+----------------------------------------------------------------------------+
| @@sql_mode |
+----------------------------------------------------------------------------+
| ANSI_QUOTES,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+----------------------------------------------------------------------------+
1 row in set (0.00 sec)
```
#### ps_is_account_enabled
##### Description
Determines whether instrumentation of an account is enabled within Performance Schema.
##### Parameters
* in_host VARCHAR(60): The hostname of the account to check.
* in_user VARCHAR(32): The username of the account to check.
##### Returns
ENUM('YES', 'NO')
##### Example
```SQL
mariadb> SELECT sys.ps_is_account_enabled('localhost', 'root');
+------------------------------------------------+
| sys.ps_is_account_enabled('localhost', 'root') |
+------------------------------------------------+
| YES |
+------------------------------------------------+
1 row in set (0.01 sec)
```
#### ps_is_consumer_enabled
##### Description
Determines whether a consumer is enabled (taking the consumer hierarchy into consideration) within the Performance Schema.
##### Parameters
* in_consumer VARCHAR(64): The name of the consumer to check.
##### Returns
ENUM('YES', 'NO')
##### Example
```SQL
mariadb> SELECT sys.ps_is_consumer_enabled('events_stages_history');
+-----------------------------------------------------+
| sys.ps_is_consumer_enabled('events_stages_history') |
+-----------------------------------------------------+
| NO |
+-----------------------------------------------------+
1 row in set (0.00 sec)
```
#### ps_is_instrument_default_enabled
##### Description
Returns whether an instrument is enabled by default in this version of MariaDB.
##### Parameters
* in_instrument VARCHAR(128): The instrument to check.
##### Returns
ENUM('YES', 'NO')
##### Example
```SQL
mariadb> SELECT sys.ps_is_instrument_default_enabled('statement/sql/select');
+--------------------------------------------------------------+
| sys.ps_is_instrument_default_enabled('statement/sql/select') |
+--------------------------------------------------------------+
| YES |
+--------------------------------------------------------------+
1 row in set (0.00 sec)
```
#### ps_is_instrument_default_timed
##### Description
Returns whether an instrument is timed by default in this version of MariaDB.
##### Parameters
* in_instrument VARCHAR(128): The instrument to check.
##### Returns
ENUM('YES', 'NO')
##### Example
```SQL
mariadb> SELECT sys.ps_is_instrument_default_timed('statement/sql/select');
+------------------------------------------------------------+
| sys.ps_is_instrument_default_timed('statement/sql/select') |
+------------------------------------------------------------+
| YES |
+------------------------------------------------------------+
1 row in set (0.00 sec)
```
#### ps_is_thread_instrumented
##### Description
Checks whether the provided connection id is instrumented within Performance Schema.
##### Parameters
* in_connection_id (BIGINT UNSIGNED): the id of the connection to check.
##### Returns
ENUM('YES', 'NO', 'UNKNOWN')
##### Example
```SQL
mariadb> SELECT sys.ps_is_thread_instrumented(CONNECTION_ID());
+------------------------------------------------+
| sys.ps_is_thread_instrumented(CONNECTION_ID()) |
+------------------------------------------------+
| YES |
+------------------------------------------------+
1 row in set (0.10 sec)
```
#### ps_thread_id
##### Description
Return the Performance Schema THREAD_ID for the specified connection ID.
##### Parameters
* in_connection_id (BIGINT UNSIGNED): The id of the connection to return the thread id for. If NULL, the current connection thread id is returned.
##### Returns
BIGINT UNSIGNED
##### Example
```SQL
mariadb> SELECT sys.ps_thread_id(79);
+----------------------+
| sys.ps_thread_id(79) |
+----------------------+
| 98 |
+----------------------+
1 row in set (0.00 sec)
mariadb> SELECT sys.ps_thread_id(CONNECTION_ID());
+-----------------------------------+
| sys.ps_thread_id(CONNECTION_ID()) |
+-----------------------------------+
| 98 |
+-----------------------------------+
1 row in set (0.00 sec)
```
#### ps_thread_stack
##### Description
Outputs a JSON formatted stack of all statements, stages and events within Performance Schema for the specified thread.
##### Parameters
* thd_id (BIGINT): The id of the thread to trace. This should match the thread_id column from the performance_schema.threads table.
##### Example
(line separation added for output)
```SQL
mariadb> SELECT sys.ps_thread_stack(37, FALSE) AS thread_stack\G
*************************** 1. row ***************************
thread_stack: {"rankdir": "LR","nodesep": "0.10","stack_created": "2024-09-04 21:21:44",
"mysql_version": "10.6.19-MariaDB","mysql_user": "msandbox@localhost","events": []}
...
```
#### ps_thread_trx_info
##### Description
Returns a JSON object with info on the given thread's current transaction, and the statements it has already executed, derived from the `performance_schema.events_transactions_current` and `performance_schema.events_statements_history` tables (so the consumers for these also have to be enabled within Performance Schema to get full data in the object).
When the output exceeds the default truncation length (65535), a JSON error object is returned, such as:
`{ "error": "Trx info truncated: Row 6 was cut by GROUP_CONCAT()" }`
Similar error objects are returned for other warnings/and exceptions raised when calling the function.
The max length of the output of this function can be controlled with the `ps_thread_trx_info.max_length` variable set via `sys_config`, or the `@sys.ps_thread_trx_info.max_length` user variable, as appropriate.
##### Parameters
* in_thread_id (BIGINT UNSIGNED): The id of the thread to return the transaction info for.
##### Example
```SQL
SELECT sys.ps_thread_trx_info(48)\G
*************************** 1. row ***************************
sys.ps_thread_trx_info(48): [
{
"time": "790.70 us",
"state": "COMMITTED",
"mode": "READ WRITE",
"autocommitted": "NO",
"gtid": "AUTOMATIC",
"isolation": "REPEATABLE READ",
"statements_executed": [
{
"sql_text": "INSERT INTO info VALUES (1, \'foo\')",
"time": "471.02 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 1,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
},
{
"sql_text": "COMMIT",
"time": "254.42 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 0,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
}
]
},
{
"time": "426.20 us",
"state": "COMMITTED",
"mode": "READ WRITE",
"autocommitted": "NO",
"gtid": "AUTOMATIC",
"isolation": "REPEATABLE READ",
"statements_executed": [
{
"sql_text": "INSERT INTO info VALUES (2, \'bar\')",
"time": "107.33 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 1,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
},
{
"sql_text": "COMMIT",
"time": "213.23 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 0,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
}
]
}
]
1 row in set (0.03 sec)
```
#### quote_identifier
##### Description
Takes an unquoted identifier (schema name, table name, etc.) and
returns the identifier quoted with backticks.
##### Parameters
* in_identifier (TEXT): The identifier to quote.
##### Returns
TEXT
##### Example
```SQL
mariadb> SELECT sys.quote_identifier('my_identifier') AS Identifier;
+-----------------+
| Identifier |
+-----------------+
| `my_identifier` |
+-----------------+
1 row in set (0.00 sec)
mariadb> SELECT sys.quote_identifier('my`idenfier') AS Identifier;
+----------------+
| Identifier |
+----------------+
| `my``idenfier` |
+----------------+
1 row in set (0.00 sec)
```
#### sys_get_config
##### Description
Returns the value for the requested variable using the following logic:
1. If the option exists in sys.sys_config return the value from there.
2. Else fall back on the provided default value.
Notes for using sys_get_config():
* If the default value argument to sys_get_config() is NULL and case 2. is reached, NULL is returned.
It is then expected that the caller is able to handle NULL for the given configuration option.
* The convention is to name the user variables @sys.<name of variable>. It is <name of variable> that
is stored in the sys_config table and is what is expected as the argument to sys_get_config().
* If you want to check whether the configuration option has already been set and if not assign with
the return value of sys_get_config() you can use IFNULL(...) (see example below). However this should
not be done inside a loop (e.g. for each row in a result set) as for repeated calls where assignment
is only needed in the first iteration using IFNULL(...) is expected to be significantly slower than
using an IF (...) THEN ... END IF; block (see example below).
##### Parameters
* in_variable_name (VARCHAR(128)): The name of the config option to return the value for.
* in_default_value (VARCHAR(128)): The default value to return if the variable does not exist in sys.sys_config.
##### Returns
VARCHAR(128)
##### Example
```SQL
-- Get the configuration value from sys.sys_config falling back on 128 if the option is not present in the table.
mariadb> SELECT sys.sys_get_config('statement_truncate_len', 128) AS Value;
+-------+
| Value |
+-------+
| 64 |
+-------+
1 row in set (0.00 sec)
-- Check whether the option is already set, if not assign - IFNULL(...) one liner example.
mariadb> SET @sys.statement_truncate_len = IFNULL(@sys.statement_truncate_len, sys.sys_get_config('statement_truncate_len', 64));
Query OK, 0 rows affected (0.00 sec)
-- Check whether the option is already set, if not assign - IF ... THEN ... END IF example.
IF (@sys.statement_truncate_len IS NULL) THEN
SET @sys.statement_truncate_len = sys.sys_get_config('statement_truncate_len', 64);
END IF;
```
#### version_major
##### Description
Returns the major version of MariaDB Server.
##### Returns
TINYINT UNSIGNED
##### Example
```SQL
mariadb> SELECT VERSION(), sys.version_major();
+-----------------+---------------------+
| VERSION() | sys.version_major() |
+-----------------+---------------------+
| 10.6.19-MariaDB | 10 |
+-----------------+---------------------+
1 row in set (0.00 sec)
```
#### version_minor
##### Description
Returns the minor (release series) version of MariaDB Server.
##### Returns
TINYINT UNSIGNED
##### Example
```SQL
mariadb> SELECT VERSION(), sys.server_minor();
+-----------------+---------------------+
| VERSION() | sys.version_minor() |
+-----------------+---------------------+
| 10.6.19-MariaDB | 6 |
+-----------------+---------------------+
1 row in set (0.00 sec)
```
#### version_patch
##### Description
Returns the patch release version of MariaDB Server.
##### Returns
TINYINT UNSIGNED
##### Example
```SQL
mariadb> SELECT VERSION(), sys.version_patch();
+-----------------+---------------------+
| VERSION() | sys.version_patch() |
+-----------------+---------------------+
| 10.6.19-MariaDB | 19 |
+-----------------+---------------------+
1 row in set (0.00 sec)
```
### Procedures
#### create_synonym_db
##### Description
Takes a source database name and synonym name, and then creates the synonym database with views that point to all of the tables within the source database.
Useful for creating a "ps" synonym for "performance_schema", or "is" instead of "information_schema", for example.
##### Parameters
* in_db_name (VARCHAR(64)):
** The database name that you would like to create a synonym for.
* in_synonym (VARCHAR(64)):
** The database synonym name.
##### Example
```SQL
mariadb> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00 sec)
mariadb> CALL sys.create_synonym_db('performance_schema', 'ps');
+---------------------------------------+
| summary |
+---------------------------------------+
| Created 74 views in the `ps` database |
+---------------------------------------+
1 row in set (8.57 sec)
Query OK, 0 rows affected (8.57 sec)
mariadb> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| ps |
| sys |
| test |
+--------------------+
6 rows in set (0.00 sec)
mariadb> SHOW FULL TABLES FROM ps;
+-----------------------------------------+------------+
| Tables_in_ps | Table_type |
+-----------------------------------------+------------+
| accounts | VIEW |
| cond_instances | VIEW |
| events_stages_current | VIEW |
| events_stages_history | VIEW |
...
```
#### diagnostics
##### Description
Create a report of the current status of the server for diagnostics purposes. Data collected includes (some items depends on versions and settings):
* The GLOBAL VARIABLES
* Several sys schema views including metrics or equivalent (depending on version and settings)
* Queries in the 95th percentile
* Replication (both master and slave) information.
Some of the sys schema views are calculated as initial (optional), overall, delta:
* The initial view is the content of the view at the start of this procedure.
This output will be the same as the the start values used for the delta view.
The initial view is included if @sys.diagnostics.include_raw = 'ON'.
* The overall view is the content of the view at the end of this procedure.
This output is the same as the end values used for the delta view.
The overall view is always included.
* The delta view is the difference from the beginning to the end. Note that for min and max values
they are simply the min or max value from the end view respectively, so does not necessarily reflect
the minimum/maximum value in the monitored period.
Note: except for the metrics view the delta is only calculation between the first and last outputs.
Requires the SUPER privilege for "SET sql_log_bin = 0;".
Some configuration options are supported:
* sys.diagnostics.allow_i_s_tables
Specifies whether it is allowed to do table scan queries on information_schema.TABLES. This can be expensive if there
are many tables. Set to 'ON' to allow, 'OFF' to not allow.
Default is 'OFF'.
* sys.diagnostics.include_raw
Set to 'ON' to include the raw data (e.g. the original output of "SELECT * FROM sys.metrics").
Use this to get the initial values of the various views.
Default is 'OFF'.
* sys.statement_truncate_len
How much of queries in the process list output to include.
Default is 64.
* sys.debug
Whether to provide debugging output.
Default is 'OFF'. Set to 'ON' to include.
##### Parameters
* in_max_runtime (INT UNSIGNED):
The maximum time to keep collecting data.
Use NULL to get the default which is 60 seconds, otherwise enter a value greater than 0.
* in_interval (INT UNSIGNED):
How long to sleep between data collections.
Use NULL to get the default which is 30 seconds, otherwise enter a value greater than 0.
* in_auto_config (ENUM('current', 'medium', 'full'))
Automatically enable Performance Schema instruments and consumers.
NOTE: The more that are enabled, the more impact on the performance.
If another setting the 'current' is chosen, the current settings
are restored at the end of the procedure.
Supported values are:
** current - use the current settings.
** medium - enable some settings.
** full - enables all settings. This will have a big impact on the
performance - be careful using this option.
##### Example
```SQL
mariadb> TEE diag.out;
mariadb> CALL sys.diagnostics(120, 30, 'current');
...
mariadb> NOTEE;
```
#### ps_setup_disable_background_threads
##### Description
Disable all background thread instrumentation within Performance Schema.
##### Parameters
None.
##### Example
```SQL
mariadb> CALL sys.ps_setup_disable_background_threads();
+--------------------------------+
| summary |
+--------------------------------+
| Disabled 18 background threads |
+--------------------------------+
1 row in set (0.00 sec)
```
#### execute_prepared_stmt
##### Description
Takes the query in the argument and executes it using a prepared statement. The prepared statement is deallocated,
so the procedure is mainly useful for executing one off dynamically created queries.
The sys_execute_prepared_stmt prepared statement name is used for the query and is required not to exist.
##### Parameters
* in_query (longtext CHARACTER SET UTF8):
** The query to execute.
The following configuration option is supported:
* sys.debug
Whether to provide debugging output.
Default is 'OFF'. Set to 'ON' to include.
##### Example
```SQL
mariadb> CALL sys.execute_prepared_stmt('SELECT * FROM sys.sys_config');
+------------------------+-------+---------------------+--------+
| variable | value | set_time | set_by |
+------------------------+-------+---------------------+--------+
| statement_truncate_len | 64 | 2015-06-30 13:06:00 | NULL |
+------------------------+-------+---------------------+--------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
```
#### ps_setup_disable_consumer
##### Description
Disables consumers within Performance Schema matching the input pattern.
##### Parameters
* consumer (VARCHAR(128)): A LIKE pattern match (using "%consumer%") of consumers to disable
##### Example
To disable all consumers:
```SQL
mariadb> CALL sys.ps_setup_disable_consumer('');
+--------------------------+
| summary |
+--------------------------+
| Disabled 15 consumers |
+--------------------------+
1 row in set (0.02 sec)
```
To disable just the event_stage consumers:
```SQL
mariadb> CALL sys.ps_setup_disable_consumer('stage');
+------------------------+
| summary |
+------------------------+
| Disabled 3 consumers |
+------------------------+
1 row in set (0.00 sec)
```
#### ps_setup_disable_instrument
##### Description
Disables instruments within Performance Schema matching the input pattern.
##### Parameters
* in_pattern (VARCHAR(128)): A LIKE pattern match (using "%in_pattern%") of events to disable
##### Example
To disable all mutex instruments:
```SQL
mariadb> CALL sys.ps_setup_disable_instrument('wait/synch/mutex');
+--------------------------+
| summary |
+--------------------------+
| Disabled 155 instruments |
+--------------------------+
1 row in set (0.02 sec)
```
To disable just a specific TCP/IP based network IO instrument:
```SQL
mariadb> CALL sys.ps_setup_disable_instrument('wait/io/socket/sql/server_tcpip_socket');
+------------------------+
| summary |
+------------------------+
| Disabled 1 instruments |
+------------------------+
1 row in set (0.00 sec)
```
To disable all instruments:
```SQL
mariadb> CALL sys.ps_setup_disable_instrument('');
+--------------------------+
| summary |
+--------------------------+
| Disabled 547 instruments |
+--------------------------+
1 row in set (0.01 sec)
```
#### ps_setup_disable_thread
##### Description
Disable the given connection/thread in Performance Schema.
##### Parameters
* in_connection_id (BIGINT): The connection ID (PROCESSLIST_ID from performance_schema.threads or the ID shown within SHOW PROCESSLIST)
##### Example
```SQL
mariadb> CALL sys.ps_setup_disable_thread(3);
+-------------------+
| summary |
+-------------------+
| Disabled 1 thread |
+-------------------+
1 row in set (0.01 sec)
```
To disable the current connection:
```SQL
mariadb> CALL sys.ps_setup_disable_thread(CONNECTION_ID());
+-------------------+
| summary |
+-------------------+
| Disabled 1 thread |
+-------------------+
1 row in set (0.00 sec)
```
#### ps_setup_enable_background_threads
##### Description
Enable all background thread instrumentation within Performance Schema.
##### Parameters
None.
##### Example
```SQL
mariadb> CALL sys.ps_setup_enable_background_threads();
+-------------------------------+
| summary |
+-------------------------------+
| Enabled 18 background threads |
+-------------------------------+
1 row in set (0.00 sec)
```
#### ps_setup_enable_consumer
##### Description
Enables consumers within Performance Schema matching the input pattern.
##### Parameters
* consumer (VARCHAR(128)): A LIKE pattern match (using "%consumer%") of consumers to enable
##### Example
To enable all consumers:
```SQL
mariadb> CALL sys.ps_setup_enable_consumer('');
+-------------------------+
| summary |
+-------------------------+
| Enabled 10 consumers |
+-------------------------+
1 row in set (0.02 sec)
```
To enable just "waits" consumers:
```SQL
mariadb> CALL sys.ps_setup_enable_consumer('waits');
+-----------------------+
| summary |
+-----------------------+
| Enabled 3 consumers |
+-----------------------+
1 row in set (0.00 sec)
```
#### ps_setup_enable_instrument
##### Description
Enables instruments within Performance Schema matching the input pattern.
##### Parameters
* in_pattern (VARCHAR(128)): A LIKE pattern match (using "%in_pattern%") of events to enable
##### Example
To enable all mutex instruments:
```SQL
mariadb> CALL sys.ps_setup_enable_instrument('wait/synch/mutex');
+-------------------------+
| summary |
+-------------------------+
| Enabled 155 instruments |
+-------------------------+
1 row in set (0.02 sec)
```
To enable just a specific TCP/IP based network IO instrument:
```SQL
mariadb> CALL sys.ps_setup_enable_instrument('wait/io/socket/sql/server_tcpip_socket');
+-----------------------+
| summary |
+-----------------------+
| Enabled 1 instruments |
+-----------------------+
1 row in set (0.00 sec)
```
To enable all instruments:
```SQL
mariadb> CALL sys.ps_setup_enable_instrument('');
+-------------------------+
| summary |
+-------------------------+
| Enabled 547 instruments |
+-------------------------+
1 row in set (0.01 sec)
```
#### ps_setup_enable_thread
##### Description
Enable the given connection/thread in Performance Schema.
##### Parameters
* in_connection_id (BIGINT): The connection ID (PROCESSLIST_ID from performance_schema.threads or the ID shown within SHOW PROCESSLIST)
##### Example
```SQL
mariadb> CALL sys.ps_setup_enable_thread(3);
+------------------+
| summary |
+------------------+
| Enabled 1 thread |
+------------------+
1 row in set (0.01 sec)
```
To enable the current connection:
```SQL
mariadb> CALL sys.ps_setup_enable_thread(CONNECTION_ID());
+------------------+
| summary |
+------------------+
| Enabled 1 thread |
+------------------+
1 row in set (0.00 sec)
```
#### ps_setup_reload_saved
##### Description
Reloads a saved Performance Schema configuration, so that you can alter the setup for debugging purposes, but restore it to a previous state.
Use the companion procedure - ps_setup_save(), to save a configuration.
Requires the SUPER privilege for "SET sql_log_bin = 0;".
##### Parameters
None.
##### Example
```SQL
mariadb> CALL sys.ps_setup_save();
Query OK, 0 rows affected (0.08 sec)
mariadb> UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
Query OK, 547 rows affected (0.40 sec)
Rows matched: 784 Changed: 547 Warnings: 0
/* Run some tests that need more detailed instrumentation here */
mariadb> CALL sys.ps_setup_reload_saved();
Query OK, 0 rows affected (0.32 sec)
```
#### ps_setup_reset_to_default
##### Description
Resets the Performance Schema setup to the default settings.
##### Parameters
* in_verbose (BOOLEAN): Whether to print each setup stage (including the SQL) whilst running.
##### Example
```SQL
mariadb> CALL sys.ps_setup_reset_to_default(true)\G
*************************** 1. row ***************************
status: Resetting: setup_actors
DELETE
FROM performance_schema.setup_actors
WHERE NOT (HOST = '%' AND USER = '%' AND ROLE = '%')
1 row in set (0.00 sec)
*************************** 1. row ***************************
status: Resetting: setup_actors
INSERT IGNORE INTO performance_schema.setup_actors
VALUES ('%', '%', '%')
1 row in set (0.00 sec)
...
mariadb> CALL sys.ps_setup_reset_to_default(false)\G
Query OK, 0 rows affected (0.00 sec)
```
#### ps_setup_save
##### Description
Saves the current configuration of Performance Schema, so that you can alter the setup for debugging purposes, but restore it to a previous state.
Use the companion procedure - ps_setup_reload_saved(), to restore the saved config.
The named lock "sys.ps_setup_save" is taken before the current configuration is saved. If the attempt to get the named lock times out, an error occurs.
The lock is released after the settings have been restored by calling ps_setup_reload_saved().
Requires the SUPER privilege for "SET sql_log_bin = 0;".
##### Parameters
* in_timeout (INT): The timeout in seconds used when trying to obtain the lock. A negative timeout means infinite timeout.
##### Example
```SQL
mariadb> CALL sys.ps_setup_save(-1);
Query OK, 0 rows affected (0.08 sec)
mariadb> UPDATE performance_schema.setup_instruments
-> SET enabled = 'YES', timed = 'YES';
Query OK, 547 rows affected (0.40 sec)
Rows matched: 784 Changed: 547 Warnings: 0
/* Run some tests that need more detailed instrumentation here */
mariadb> CALL sys.ps_setup_reload_saved();
Query OK, 0 rows affected (0.32 sec)
```
#### ps_setup_show_disabled
##### Description
Shows all currently disabled Performance Schema configurations.
##### Parameters
* in_show_instruments (BOOLEAN): Whether to print disabled instruments (can print many items)
* in_show_threads (BOOLEAN): Whether to print disabled threads
##### Example
```SQL
mariadb> CALL sys.ps_setup_show_disabled(TRUE, TRUE);
+----------------------------+
| performance_schema_enabled |
+----------------------------+
| 1 |
+----------------------------+
1 row in set (0.00 sec)
+--------------------+
| disabled_users |
+--------------------+
| 'mark'@'localhost' |
+--------------------+
1 row in set (0.00 sec)
+-------------+----------------------+---------+-------+
| object_type | objects | enabled | timed |
+-------------+----------------------+---------+-------+
| EVENT | mysql.% | NO | NO |
| EVENT | performance_schema.% | NO | NO |
| EVENT | information_schema.% | NO | NO |
| FUNCTION | mysql.% | NO | NO |
| FUNCTION | performance_schema.% | NO | NO |
| FUNCTION | information_schema.% | NO | NO |
| PROCEDURE | mysql.% | NO | NO |
| PROCEDURE | performance_schema.% | NO | NO |
| PROCEDURE | information_schema.% | NO | NO |
| TABLE | mysql.% | NO | NO |
| TABLE | performance_schema.% | NO | NO |
| TABLE | information_schema.% | NO | NO |
| TRIGGER | mysql.% | NO | NO |
| TRIGGER | performance_schema.% | NO | NO |
| TRIGGER | information_schema.% | NO | NO |
+-------------+----------------------+---------+-------+
15 rows in set (0.00 sec)
+----------------------------------+
| disabled_consumers |
+----------------------------------+
| events_stages_current |
| events_stages_history |
| events_stages_history_long |
| events_statements_history |
| events_statements_history_long |
| events_transactions_history |
| events_transactions_history_long |
| events_waits_current |
| events_waits_history |
| events_waits_history_long |
+----------------------------------+
10 rows in set (0.00 sec)
Empty set (0.00 sec)
+---------------------------------------------------------------------------------------+-------+
| disabled_instruments | timed |
+---------------------------------------------------------------------------------------+-------+
| wait/synch/mutex/sql/TC_LOG_MMAP::LOCK_tc | NO |
| wait/synch/mutex/sql/LOCK_des_key_file | NO |
| wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_commit | NO |
...
| memory/sql/servers_cache | NO |
| memory/sql/udf_mem | NO |
| wait/lock/metadata/sql/mdl | NO |
+---------------------------------------------------------------------------------------+-------+
547 rows in set (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
```
#### ps_setup_show_disabled_consumers
##### Description
Shows all currently disabled consumers.
##### Parameters
None
##### Example
```SQL
mariadb> CALL sys.ps_setup_show_disabled_consumers();
+---------------------------+
| disabled_consumers |
+---------------------------+
| events_statements_current |
| global_instrumentation |
| thread_instrumentation |
| statements_digest |
+---------------------------+
4 rows in set (0.05 sec)
```
#### ps_setup_show_disabled_instruments
##### Description
Shows all currently disabled instruments.
##### Parameters
None
##### Example
```SQL
mariadb> CALL sys.ps_setup_show_disabled_instruments();
```
#### ps_setup_show_enabled
##### Description
Shows all currently enabled Performance Schema configuration.
##### Parameters
* in_show_instruments (BOOLEAN): Whether to print enabled instruments (can print many items)
* in_show_threads (BOOLEAN): Whether to print enabled threads
##### Example
```SQL
mariadb> CALL sys.ps_setup_show_enabled(TRUE, TRUE);
+----------------------------+
| performance_schema_enabled |
+----------------------------+
| 1 |
+----------------------------+
1 row in set (0.00 sec)
+---------------+
| enabled_users |
+---------------+
| '%'@'%' |
+---------------+
1 row in set (0.01 sec)
+-------------+---------+---------+-------+
| object_type | objects | enabled | timed |
+-------------+---------+---------+-------+
| EVENT | %.% | YES | YES |
| FUNCTION | %.% | YES | YES |
| PROCEDURE | %.% | YES | YES |
| TABLE | %.% | YES | YES |
| TRIGGER | %.% | YES | YES |
+-------------+---------+---------+-------+
5 rows in set (0.01 sec)
+---------------------------+
| enabled_consumers |
+---------------------------+
| events_statements_current |
| global_instrumentation |
| thread_instrumentation |
| statements_digest |
+---------------------------+
4 rows in set (0.05 sec)
+---------------------------------+-------------+
| enabled_threads | thread_type |
+---------------------------------+-------------+
| sql/main | BACKGROUND |
| sql/thread_timer_notifier | BACKGROUND |
| innodb/io_ibuf_thread | BACKGROUND |
| innodb/io_log_thread | BACKGROUND |
| innodb/io_read_thread | BACKGROUND |
| innodb/io_read_thread | BACKGROUND |
| innodb/io_write_thread | BACKGROUND |
| innodb/io_write_thread | BACKGROUND |
| innodb/page_cleaner | BACKGROUND |
| innodb/srv_lock_timeout_thread | BACKGROUND |
| innodb/srv_error_monitor_thread | BACKGROUND |
| innodb/srv_monitor_thread | BACKGROUND |
| innodb/srv_master_thread | BACKGROUND |
| innodb/srv_purge_thread | BACKGROUND |
| innodb/srv_worker_thread | BACKGROUND |
| innodb/srv_worker_thread | BACKGROUND |
| innodb/srv_worker_thread | BACKGROUND |
| innodb/buf_dump_thread | BACKGROUND |
| innodb/dict_stats_thread | BACKGROUND |
| sql/signal_handler | BACKGROUND |
| sql/compress_gtid_table | FOREGROUND |
| root@localhost | FOREGROUND |
+---------------------------------+-------------+
22 rows in set (0.01 sec)
+-------------------------------------+-------+
| enabled_instruments | timed |
+-------------------------------------+-------+
| wait/io/file/sql/map | YES |
| wait/io/file/sql/binlog | YES |
...
| statement/com/Error | YES |
| statement/com/ | YES |
| idle | YES |
+-------------------------------------+-------+
210 rows in set (0.08 sec)
Query OK, 0 rows affected (0.89 sec)
```
#### ps_setup_show_enabled_consumers
##### Description
Shows all currently enabled consumers.
##### Parameters
None
##### Example
```SQL
mariadb> CALL sys.ps_setup_show_enabled_consumers();
+---------------------------+
| enabled_consumers |
+---------------------------+
| events_statements_current |
| global_instrumentation |
| thread_instrumentation |
| statements_digest |
+---------------------------+
4 rows in set (0.05 sec)
```
#### ps_setup_show_enabled_instruments
##### Description
Shows all currently enabled instruments.
##### Parameters
None
##### Example
```SQL
mariadb> CALL sys.ps_setup_show_enabled_instruments();
```
#### ps_statement_avg_latency_histogram
##### Description
Outputs a textual histogram graph of the average latency values across all normalized queries tracked within the Performance Schema events_statements_summary_by_digest table.
Can be used to show a very high level picture of what kind of latency distribution statements running within this instance have.
##### Parameters
None.
##### Example
```SQL
mariadb> CALL sys.ps_statement_avg_latency_histogram()\G
*************************** 1. row ***************************
Performance Schema Statement Digest Average Latency Histogram:
. = 1 unit
* = 2 units
# = 3 units
(0 - 38ms) 240 | ################################################################################
(38 - 77ms) 38 | ......................................
(77 - 115ms) 3 | ...
(115 - 154ms) 62 | *******************************
(154 - 192ms) 3 | ...
(192 - 231ms) 0 |
(231 - 269ms) 0 |
(269 - 307ms) 0 |
(307 - 346ms) 0 |
(346 - 384ms) 1 | .
(384 - 423ms) 1 | .
(423 - 461ms) 0 |
(461 - 499ms) 0 |
(499 - 538ms) 0 |
(538 - 576ms) 0 |
(576 - 615ms) 1 | .
Total Statements: 350; Buckets: 16; Bucket Size: 38 ms;
```
#### ps_trace_statement_digest
##### Description
Traces all instrumentation within Performance Schema for a specific Statement Digest.
When finding a statement of interest within the performance_schema.events_statements_summary_by_digest table, feed the DIGEST MD5 value in to this procedure, set how long to poll for, and at what interval to poll, and it will generate a report of all statistics tracked within Performance Schema for that digest for the interval.
It will also attempt to generate an EXPLAIN for the longest running example of the digest during the interval.
Note this may fail, as:
* Performance Schema truncates long SQL_TEXT values (and hence the EXPLAIN will fail due to parse errors)
* the default schema is sys (so tables that are not fully qualified in the query may not be found)
* some queries such as SHOW are not supported in EXPLAIN.
When the EXPLAIN fails, the error will be ignored and no EXPLAIN output generated.
Requires the SUPER privilege for "SET sql_log_bin = 0;".
##### Parameters
* in_digest VARCHAR(32): The statement digest identifier you would like to analyze
* in_runtime (INT): The number of seconds to run analysis for
* in_interval (DECIMAL(2,2)): The interval (in seconds, may be fractional) at which to try and take snapshots
* in_start_fresh (BOOLEAN): Whether to TRUNCATE the events_statements_history_long and events_stages_history_long tables before starting
* in_auto_enable (BOOLEAN): Whether to automatically turn on required consumers
##### Example
```SQL
mariadb> call ps_analyze_statement_digest('891ec6860f98ba46d89dd20b0c03652c', 10, 0.1, true, true);
+--------------------+
| SUMMARY STATISTICS |
+--------------------+
| SUMMARY STATISTICS |
+--------------------+
1 row in set (9.11 sec)
+------------+-----------+-----------+-----------+---------------+------------+------------+
| executions | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scans |
+------------+-----------+-----------+-----------+---------------+------------+------------+
| 21 | 4.11 ms | 2.00 ms | 0 | 21 | 0 | 0 |
+------------+-----------+-----------+-----------+---------------+------------+------------+
1 row in set (9.11 sec)
+------------------------------------------+-------+-----------+
| event_name | count | latency |
+------------------------------------------+-------+-----------+
| stage/sql/checking query cache for query | 16 | 724.37 us |
| stage/sql/statistics | 16 | 546.92 us |
| stage/sql/freeing items | 18 | 520.11 us |
| stage/sql/init | 51 | 466.80 us |
...
| stage/sql/cleaning up | 18 | 11.92 us |
| stage/sql/executing | 16 | 6.95 us |
+------------------------------------------+-------+-----------+
17 rows in set (9.12 sec)
+---------------------------+
| LONGEST RUNNING STATEMENT |
+---------------------------+
| LONGEST RUNNING STATEMENT |
+---------------------------+
1 row in set (9.16 sec)
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
| thread_id | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scan |
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
| 166646 | 618.43 us | 1.00 ms | 0 | 1 | 0 | 0 |
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
1 row in set (9.16 sec)
// Truncated for clarity...
+-----------------------------------------------------------------+
| sql_text |
+-----------------------------------------------------------------+
| select hibeventhe0_.id as id1382_, hibeventhe0_.createdTime ... |
+-----------------------------------------------------------------+
1 row in set (9.17 sec)
+------------------------------------------+-----------+
| event_name | latency |
+------------------------------------------+-----------+
| stage/sql/init | 8.61 us |
| stage/sql/Waiting for query cache lock | 453.23 us |
| stage/sql/init | 331.07 ns |
| stage/sql/checking query cache for query | 43.04 us |
...
| stage/sql/freeing items | 30.46 us |
| stage/sql/cleaning up | 662.13 ns |
+------------------------------------------+-----------+
18 rows in set (9.23 sec)
+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
| 1 | SIMPLE | hibeventhe0_ | const | fixedTime | fixedTime | 775 | const,const | 1 | NULL |
+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
1 row in set (9.27 sec)
Query OK, 0 rows affected (9.28 sec)
```
#### ps_trace_thread
##### Description
Dumps all data within Performance Schema for an instrumented thread, to create a DOT formatted graph file.
Each resultset returned from the procedure should be used for a complete graph
Requires the SUPER privilege for "SET sql_log_bin = 0;".
##### Parameters
* in_thread_id (INT): The thread that you would like a stack trace for
* in_outfile (VARCHAR(255)): The filename the dot file will be written to
* in_max_runtime (DECIMAL(20,2)): The maximum time to keep collecting data. Use NULL to get the default which is 60 seconds.
* in_interval (DECIMAL(20,2)): How long to sleep between data collections. Use NULL to get the default which is 1 second.
* in_start_fresh (BOOLEAN): Whether to reset all Performance Schema data before tracing.
* in_auto_setup (BOOLEAN): Whether to disable all other threads and enable all consumers/instruments. This will also reset the settings at the end of the run.
* in_debug (BOOLEAN): Whether you would like to include file:lineno in the graph
##### Example
```SQL
mariadb> CALL sys.ps_trace_thread(25, CONCAT('/tmp/stack-', REPLACE(NOW(), ' ', '-'), '.dot'), NULL, NULL, TRUE, TRUE, TRUE);
+-------------------+
| summary |
+-------------------+
| Disabled 1 thread |
+-------------------+
1 row in set (0.00 sec)
+---------------------------------------------+
| Info |
+---------------------------------------------+
| Data collection starting for THREAD_ID = 25 |
+---------------------------------------------+
1 row in set (0.03 sec)
+-----------------------------------------------------------+
| Info |
+-----------------------------------------------------------+
| Stack trace written to /tmp/stack-2014-02-16-21:18:41.dot |
+-----------------------------------------------------------+
1 row in set (60.07 sec)
+-------------------------------------------------------------------+
| Convert to PDF |
+-------------------------------------------------------------------+
| dot -Tpdf -o /tmp/stack_25.pdf /tmp/stack-2014-02-16-21:18:41.dot |
+-------------------------------------------------------------------+
1 row in set (60.07 sec)
+-------------------------------------------------------------------+
| Convert to PNG |
+-------------------------------------------------------------------+
| dot -Tpng -o /tmp/stack_25.png /tmp/stack-2014-02-16-21:18:41.dot |
+-------------------------------------------------------------------+
1 row in set (60.07 sec)
+------------------+
| summary |
+------------------+
| Enabled 1 thread |
+------------------+
1 row in set (60.32 sec)
```
#### ps_truncate_all_tables
##### Description
Truncates all summary tables within Performance Schema, resetting all aggregated instrumentation as a snapshot.
##### Parameters
* in_verbose (BOOLEAN): Whether to print each TRUNCATE statement before running
##### Example
```SQL
mariadb> CALL sys.ps_truncate_all_tables(false);
+---------------------+
| summary |
+---------------------+
| Truncated 44 tables |
+---------------------+
1 row in set (0.10 sec)
```
#### statement_performance_analyzer
##### Description
Create a report of the statements running on the server.
The views are calculated based on the overall and/or delta activity.
Requires the SUPER privilege for "SET sql_log_bin = 0;".
The following configuration options are supported:
* sys.statement_performance_analyzer.limit
The maximum number of rows to include for the views that does not have a built-in limit (e.g. the 95th percentile view).
If not set the limit is 100.
* sys.statement_performance_analyzer.view
Used together with the 'custom' view. If the value contains a space, it is considered a query, otherwise it must be
an existing view querying the performance_schema.events_statements_summary_by_digest table. There cannot be any limit
clause including in the query or view definition if @sys.statement_performance_analyzer.limit > 0.
If specifying a view, use the same format as for in_table.
* sys.debug
Whether to provide debugging output.
Default is 'OFF'. Set to 'ON' to include.
##### Parameters
* in_action (ENUM('snapshot', 'overall', 'delta', 'create_tmp', 'create_table', 'save', 'cleanup')):
The action to take. Supported actions are:
- snapshot Store a snapshot. The default is to make a snapshot of the current content of
performance_schema.events_statements_summary_by_digest, but by setting in_table
this can be overwritten to copy the content of the specified table.
The snapshot is stored in the sys.tmp_digests temporary table.
- overall Generate analyzis based on the content specified by in_table. For the overall analyzis,
in_table can be NOW() to use a fresh snapshot. This will overwrite an existing snapshot.
Use NULL for in_table to use the existing snapshot. If in_table IS NULL and no snapshot
exists, a new will be created.
See also in_views and @sys.statement_performance_analyzer.limit.
- delta Generate a delta analysis. The delta will be calculated between the reference table in
in_table and the snapshot. An existing snapshot must exist.
The action uses the sys.tmp_digests_delta temporary table.
See also in_views and @sys.statement_performance_analyzer.limit.
- create_table Create a regular table suitable for storing the snapshot for later use, e.g. for
calculating deltas.
- create_tmp Create a temporary table suitable for storing the snapshot for later use, e.g. for
calculating deltas.
- save Save the snapshot in the table specified by in_table. The table must exists and have
the correct structure.
If no snapshot exists, a new is created.
- cleanup Remove the temporary tables used for the snapshot and delta.
* in_table (VARCHAR(129)):
The table argument used for some actions. Use the format 'db1.t1' or 't1' without using any backticks (`)
for quoting. Periods (.) are not supported in the database and table names.
The meaning of the table for each action supporting the argument is:
- snapshot The snapshot is created based on the specified table. Set to NULL or NOW() to use
the current content of performance_schema.events_statements_summary_by_digest.
- overall The table with the content to create the overall analyzis for. The following values
can be used:
- A table name - use the content of that table.
- NOW() - create a fresh snapshot and overwrite the existing snapshot.
- NULL - use the last stored snapshot.
- delta The table name is mandatory and specified the reference view to compare the currently
stored snapshot against. If no snapshot exists, a new will be created.
- create_table The name of the regular table to create.
- create_tmp The name of the temporary table to create.
- save The name of the table to save the currently stored snapshot into.
* in_views (SET ('with_runtimes_in_95th_percentile', 'analysis', 'with_errors_or_warnings',
'with_full_table_scans', 'with_sorting', 'with_temp_tables', 'custom'))
Which views to include:
- with_runtimes_in_95th_percentile Based on the sys.statements_with_runtimes_in_95th_percentile view
- analysis Based on the sys.statement_analysis view
- with_errors_or_warnings Based on the sys.statements_with_errors_or_warnings view
- with_full_table_scans Based on the sys.statements_with_full_table_scans view
- with_sorting Based on the sys.statements_with_sorting view
- with_temp_tables Based on the sys.statements_with_temp_tables view
- custom Use a custom view. This view must be specified in @sys.statement_performance_analyzer.view to an existing view or a query
Default is to include all except 'custom'.
##### Example
```SQL
-- To create a report with the queries in the 95th percentile since last truncate of performance_schema.events_statements_summary_by_digest and the delta for a 1 minute period:
--
-- 1. Create a temporary table to store the initial snapshot.
-- 2. Create the initial snapshot.
-- 3. Save the initial snapshot in the temporary table.
-- 4. Wait one minute.
-- 5. Create a new snapshot.
-- 6. Perform analyzis based on the new snapshot.
-- 7. Perform analyzis based on the delta between the initial and new snapshots.
mariadb> CALL sys.statement_performance_analyzer('create_tmp', 'mydb.tmp_digests_ini', NULL);
Query OK, 0 rows affected (0.08 sec)
mariadb> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);
Query OK, 0 rows affected (0.02 sec)
mariadb> CALL sys.statement_performance_analyzer('save', 'mydb.tmp_digests_ini', NULL);
Query OK, 0 rows affected (0.00 sec)
mariadb> DO SLEEP(60);
Query OK, 0 rows affected (1 min 0.00 sec)
mariadb> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);
Query OK, 0 rows affected (0.02 sec)
mariadb> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile');
+-----------------------------------------+
| Next Output |
+-----------------------------------------+
| Queries with Runtime in 95th Percentile |
+-----------------------------------------+
1 row in set (0.05 sec)
...
mariadb> CALL sys.statement_performance_analyzer('delta', 'mydb.tmp_digests_ini', 'with_runtimes_in_95th_percentile');
+-----------------------------------------+
| Next Output |
+-----------------------------------------+
| Queries with Runtime in 95th Percentile |
+-----------------------------------------+
1 row in set (0.03 sec)
...
-- To create an overall report of the 95th percentile queries and the top 10 queries with full table scans:
mariadb> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);
Query OK, 0 rows affected (0.01 sec)
mariadb> SET @sys.statement_performance_analyzer.limit = 10;
Query OK, 0 rows affected (0.00 sec)
mariadb> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile,with_full_table_scans');
+-----------------------------------------+
| Next Output |
+-----------------------------------------+
| Queries with Runtime in 95th Percentile |
+-----------------------------------------+
1 row in set (0.01 sec)
...
+-------------------------------------+
| Next Output |
+-------------------------------------+
| Top 10 Queries with Full Table Scan |
+-------------------------------------+
1 row in set (0.09 sec)
...
-- Use a custom view showing the top 10 query sorted by total execution time refreshing the view every minute using
-- the watch command in Linux.
mariadb> CREATE OR REPLACE VIEW mydb.my_statements AS
-> SELECT sys.format_statement(DIGEST_TEXT) AS query,
-> SCHEMA_NAME AS db,
-> COUNT_STAR AS exec_count,
-> format_pico_time(SUM_TIMER_WAIT) AS total_latency,
-> format_pico_time(AVG_TIMER_WAIT) AS avg_latency,
-> ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg,
-> ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg,
-> ROUND(IFNULL(SUM_ROWS_AFFECTED / NULLIF(COUNT_STAR, 0), 0)) AS rows_affected_avg,
-> DIGEST AS digest
-> FROM performance_schema.events_statements_summary_by_digest
-> ORDER BY SUM_TIMER_WAIT DESC;
Query OK, 0 rows affected (0.01 sec)
mariadb> CALL sys.statement_performance_analyzer('create_table', 'mydb.digests_prev', NULL);
Query OK, 0 rows affected (0.10 sec)
shell$ watch -n 60 "mariadb sys --table -e \"
> SET @sys.statement_performance_analyzer.view = 'mydb.my_statements';
> SET @sys.statement_performance_analyzer.limit = 10;
> CALL statement_performance_analyzer('snapshot', NULL, NULL);
> CALL statement_performance_analyzer('delta', 'mydb.digests_prev', 'custom');
> CALL statement_performance_analyzer('save', 'mydb.digests_prev', NULL);
> \""
Every 60.0s: mariadb sys --table -e " ... Mon Dec 22 10:58:51 2014
+----------------------------------+
| Next Output |
+----------------------------------+
| Top 10 Queries Using Custom View |
+----------------------------------+
+-------------------+-------+------------+---------------+-------------+---------------+-------------------+-------------------+----------------------------------+
| query | db | exec_count | total_latency | avg_latency | rows_sent_avg | rows_examined_avg | rows_affected_avg | digest |
+-------------------+-------+------------+---------------+-------------+---------------+-------------------+-------------------+----------------------------------+
...
```
#### table_exists
##### Description
Tests whether the table specified in in_db and in_table exists either as a regular
table, or as a temporary table. The returned value corresponds to the table that
will be used, so if there's both a temporary and a permanent table with the given
name, then 'TEMPORARY' will be returned.
##### Parameters
* in_db (VARCHAR(64)): The database name to check for the existence of the table in.
* in_table (VARCHAR(64)): The name of the table to check the existence of.
* out_exists ENUM('', 'BASE TABLE', 'VIEW', 'TEMPORARY'): The return value: whether the table exists. The value is one of:
- '' - the table does not exist neither as a base table, view, nor temporary table.
- 'BASE TABLE' - the table name exists as a permanent base table table.
- 'VIEW' - the table name exists as a view.
- 'TEMPORARY' - the table name exists as a temporary table.
##### Example
```SQL
mariadb> CREATE DATABASE db1;
Query OK, 1 row affected (0.07 sec)
mariadb> use db1;
Database changed
mariadb> CREATE TABLE t1 (id INT PRIMARY KEY);
Query OK, 0 rows affected (0.08 sec)
mariadb> CREATE TABLE t2 (id INT PRIMARY KEY);
Query OK, 0 rows affected (0.08 sec)
mariadb> CREATE view v_t1 AS SELECT * FROM t1;
Query OK, 0 rows affected (0.00 sec)
mariadb> CREATE TEMPORARY TABLE t1 (id INT PRIMARY KEY);
Query OK, 0 rows affected (0.00 sec)
mariadb> CALL sys.table_exists('db1', 't1', @exists); SELECT @exists;
Query OK, 0 rows affected (0.00 sec)
+------------+
| @exists |
+------------+
| TEMPORARY |
+------------+
1 row in set (0.00 sec)
mariadb> CALL sys.table_exists('db1', 't2', @exists); SELECT @exists;
Query OK, 0 rows affected (0.00 sec)
+------------+
| @exists |
+------------+
| BASE TABLE |
+------------+
1 row in set (0.01 sec)
mariadb> CALL sys.table_exists('db1', 'v_t1', @exists); SELECT @exists;
Query OK, 0 rows affected (0.00 sec)
+---------+
| @exists |
+---------+
| VIEW |
+---------+
1 row in set (0.00 sec)
mariadb> CALL sys.table_exists('db1', 't3', @exists); SELECT @exists;
Query OK, 0 rows affected (0.01 sec)
+---------+
| @exists |
+---------+
| |
+---------+
1 row in set (0.00 sec)
```
|