查看紀錄檔

  1. 過一段時間,查看紀錄檔,得知從 context 表查詢訪客 (roleid=6) 權限,花費最多查詢時間。
    [root@moodle ~]# mysqldumpslow -s r -t 1 /var/lib/mysql/mysql.slow.log
    SELECT ctx.path,
                       rc.capability, rc.permission
                  FROM context ctx
                  JOIN role_capabilities rc ON rc.contextid = ctx.id
             LEFT JOIN context cctx
                       ON (cctx.contextlevel = 50 AND ctx.path LIKE CONCAT(cctx.path, '/%'))
                 WHERE rc.roleid = '6' AND cctx.id IS NULL;