zoukankan      html  css  js  c++  java
  • 检查mysql表碎片化脚本

     1 #!/bin/sh
     2 
     3 echo -n "MySQL username: " ; read username
     4 echo -n "MySQL password: " ; stty -echo ; read password ; stty echo ; echo
     5 
     6 mysql -u $username -p"$password" -NBe "SHOW DATABASES;" | grep -v 'lost+found' | while read database ; do
     7 mysql -u $username -p"$password" -NBe "SHOW TABLE STATUS;" $database | while read name engine version rowformat rows avgrowlength datalength maxdatalength indexlength datafree autoincrement createtime updatetime checktime collation checksum createoptions comment ; do
     8 if [ "$datafree" -gt 0 ] ; then
     9 fragmentation=$(($datafree * 100 / $datalength))
    10 echo "$database.$name is $fragmentation% fragmented."
    11 fi
    12 done
    13 done

    运行结果:

    jinyuanbao.mk_activity_shop is 263% fragmented.
    jinyuanbao.mk_coupon is 113% fragmented.
    jinyuanbao.mk_dispatch_coupon is 263% fragmented.
    jinyuanbao.mk_first_order is 88% fragmented.
    jinyuanbao.notice is 159% fragmented.
    jinyuanbao.open_oauth is 159% fragmented.
    jinyuanbao.order_platform_activity_map is 113% fragmented.
    jinyuanbao.payway is 4% fragmented.
    jinyuanbao.profile_info is 159% fragmented.
    jinyuanbao.push_info is 5% fragmented.
    jinyuanbao.push_tag is 21% fragmented.
    jinyuanbao.relation_notice is 25% fragmented.
    jinyuanbao.return_condition is 46% fragmented.
    jinyuanbao.sec_level_domain is 159% fragmented.
    jinyuanbao.sendsms is 2% fragmented.
    jinyuanbao.shop_category is 59% fragmented.
    jinyuanbao.shop_customer is 88% fragmented.
    jinyuanbao.shop_goods is 0% fragmented.
  • 相关阅读:
    echarts 变量a、b、c、d的含义
    JS实现字符点点loading效果
    ES6的异步 async promise
    ES6中Promise封装ajax的写法
    ES6 set数据结构举例
    notepad++ 正则替换 字符串开始 字符串结束
    php去除bom
    jquery-ui Datepicker 创建 销毁
    Vue-cli3 WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB)
    XManager product key
  • 原文地址:https://www.cnblogs.com/martinjinyu/p/4310676.html
Copyright © 2011-2022 走看看