• mysql优化相关


    逆范式:1对多的时候应当尽可能的把冗余放在1那边

    show status

    show variables

    关心以com开头的命令 show status like 'com%'

    show session status like 'com_select';  //本次会话
    show global status like 'com_select';    //从启动到现在

    show Connections   试图连接数据库的次数

    show global status like 'uptime';  服务器启动时间

    ________________________________________慢查询

    show global status like 'slow_queries';  //查看慢查询次数,默认是十秒

    show variables like 'long_query_time';//查看慢查询设置 默认10s

    //设置慢查询时间(本次有效)
    set long_query_time = 1;

    my.ini最后增加

      log-slow-queries = D:\wamp\mysql_slow_query.log
      long_query_time=5

    linux下注意写权限的问题

      show variables like '%slow%';
      执行结果会把是否开启慢查询、慢查询的秒数、慢查询日志等信息打印在屏幕上。

     SELECT SLEEP(10);//测试下慢查询

    导入大量数据时最好禁用索引

    alter table table_name  disable keys;                    alter table table_name  enable keys;

    查看见表SQL:
    show create table table_name;


    对于 myisam数据库,需要定时清理
    optimize table 表名

    用连接代替子查询
    使用join,mysql不需要在内存中国年创建临时表

    如果想要 or 用到索引则,or的条件必须都加索引


    在精度要求较高的项目中,用定点数来来保存,以保证准确性


    查看索引的使用情况
    show status like 'handler_read';

    handler_read_key:  高了好
    handler_read_rnd_next: 低了好

  • 相关阅读:
    影响历史进程的三只苹果
    C语言实现的RSA算法程序(使用GMP)
    C++实现的大整数分解Pollard's rho算法程序
    Java实现的大整数分解Pollard's rho算法程序
    素性测试算法
    素性测试AKS算法程序
    C++实现的Miller-Rabin素性测试程序
    为什么天朝互联网的三巨头是BAT
    KMP模式匹配算法程序(Python,C++,C)
    I00014 汉若塔问题的C++程序
  • 原文地址:https://www.cnblogs.com/siqi/p/2665798.html
Copyright © 2020-2023  润新知