zoukankan      html  css  js  c++  java
  • mysql卡顿处理

    MySQL - 锁等待超时与information_schema的三个表:
    -- 1.information_schema.innodb_trx–当前运行的所有事务
    select *,trx_mysql_thread_id from information_schema.innodb_trx ;

    -- information_schema.innodb_locks–当前出现的锁
    select * from information_schema.innodb_locks;

    -- information_schema.innodb_lock_waits–锁等待的对应关系
    select * from information_schema.innodb_lock_waits;

    -------------------------------------------------------------------------------------------
    伟哥:命令是用来查看当前运行的所有事务:
    SELECT
    trx_state,
    trx_started,
    trx_mysql_thread_id,
    trx_query,
    concat(
    'kill ',
    trx_mysql_thread_id,
    ';'
    )
    FROM
    information_schema.innodb_trx
    ORDER BY
    trx_started -- limit 50


    show processlist 看看有没有锁表
    kill id
    kill 34116988;kill 50403077; kill 50508905

    -------------------------------------------------------------------------------------------
    //常用
    select * from information_schema.innodb_trx where trx_state = 'LOCK WAIT';

    SELECT a.* FROM information_schema.processlist a where command <> 'sleep' ORDER BY time desc

    select * from information_schema.processlist where time> 60 and user='srapp_stsj';

    SELECT
    concat('kill',' ', id,';')
    FROM
    information_schema. PROCESSLIST a
    WHERE
    command <> 'sleep'
    AND info LIKE 'select%'
    AND time > 60
    and user = 'srapp_stsj'
    ORDER BY
    time DESC
    ----------------------------
    SELECT
    concat('kill',' ', id,';')
    FROM
    information_schema. PROCESSLIST a
    WHERE
    command <> 'sleep'
    AND info LIKE 'select%'
    AND time > 60
    and user = 'srapp_stsj'
    ORDER BY
    time DESC
    ------------------------------
    SELECT
    *
    FROM
    information_schema. PROCESSLIST a
    WHERE
    command <> 'sleep'
    AND info LIKE 'select%'
    AND time > 60
    and user = 'srapp_stsj'
    ORDER BY
    time DESC

    EXPLAIN
    select * from sr_main where sys_scbj = '0' and mdjlx = 'ls_jz' and sys_spzt = 2
    and mhzsfz = '330219193210200010'

    EXPLAIN
    select 1 from sr_main where 1
    ---------------------------------------
    SELECT
    *
    FROM
    information_schema. PROCESSLIST a
    WHERE
    command <> 'sleep'
    AND info LIKE 'select%'
    AND time > 60
    and user = 'srapp_stsj'
    ORDER BY
    time DESC


    SELECT
    concat('kill',' ', trx_mysql_thread_id,';')
    FROM
    information_schema.innodb_trx

  • 相关阅读:
    第五届“飞思卡尔”智能车竞赛分赛区赛后总结
    最佳编程语录
    通过UserAgent判断智能手机(设备,Android,IOS)
    Sql Server 系统存储过程分析 2 数据库引擎存储过程
    OutputCache 导致页面下载的解决办法
    w3wp.exe(IIS ) CPU 占用 100% 的常见原因及解决办法
    过滤并替换页面html输出
    Sql Server 系统存储过程分析 1 目录存储过程
    Sql Server 监控 Job 执行情况
    OutPutCache 自定义缓存:session、登录用户、cookie 等
  • 原文地址:https://www.cnblogs.com/tongcc/p/14428962.html
Copyright © 2011-2022 走看看