zoukankan      html  css  js  c++  java
  • MYSQL调优

    4核8G内存配置文件

    explain SQL 查看SQL索引使用情况。

    my.cnf
    skip-external-locking
    skip-name-resolve
    back_log=384
    key_buffer_size=512M
    max_allowed_packet=4M
    thread_stack=256k
    table_cache=614k
    sort_buffer_size=6M
    read_buffer_size=4M
    join_buffer_size=8M
    myisam_sort_buffer_size=64M
    thread_cache_size=64
    query_cache_size=64M
    tmp_table_size=256M
    max_connections=768
    max_connect_errors=1000
    wait_timeout=10
    thread_concurrency=4
    innodb_additional_mem_pool_size=4M
    innodb_log_buffre_size=2M
    innodb_thread_concurrency=4
    read_rnd_buffer_size=16M

    查看次数最多的20条SQL   : mysqldumpslow -s c -t 20 host -slow.log

    查看最大连接数: show variables like 'max_connections';

    当前连接数:show global status like 'Max_used_connections';

    查看索引使用率:show global status like 'key_read%';     key_reads/key_read_requests * 100%。

    查看临时表的使用情况:show global status like 'created_tmp%';

    查看在内存上的临时表:show variables where Variable_name in ('tmp_table_size', 'max_heap_table_size');  如果超过该值将写入硬盘

    查看mysql进程使用情况:Threads_created  如果过大说明一直在创建进程浪费资源,需要加大:thread_cache_size=64.

    mysql> show global status like 'Thread%';
    +-------------------+-------+
    | Variable_name     | Value |
    +-------------------+-------+
    | Threads_cached    | 9     |
    | Threads_connected | 11    |
    | Threads_created   | 7092  |
    | Threads_running   | 1     |
    +-------------------+-------+
    4 rows in set (0.00 sec)

    tuning-primer.sh mysql 报表  优化检测工具:http://www.cnblogs.com/zengkefu/p/5638666.html  wget http://www.day32.com/MySQL/tuning-primer.sh

    查看表索引使用情况:explain select * from xxxxxx

              查看:rows  项 扫描数据行记录。

              key:索引项目。

  • 相关阅读:
    ADSL PPPoE出错详解及宽带连接中的一些错误代码含义
    2007年世界顶级防火墙排名(附下载地址)
    Asp.net Mvc问题索引
    .NET 操作GPRS Model的类库 ATSMS
    .NET 3.5多个工程编译的DOS命令
    Google Chrome浏览器JS执行效率惊人 实测比IE快十几倍
    FTP文件同步工具(FTP_File_Synchronizer) 源代码
    [转载] ORACLE中SQL查询优化研究
    ext的grid导出为excel 方法
    数据库分页SQL语句
  • 原文地址:https://www.cnblogs.com/cp-miao/p/5777364.html
Copyright © 2011-2022 走看看