zoukankan      html  css  js  c++  java
  • 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: 低了好

  • 相关阅读:
    inotify+rsync做实时同步
    JAVA序列化和反序列化
    初识iBatis
    《Spring in action》之高级装配
    《Spring in action》之装配Bean
    原根
    数论知识
    线性(欧拉)筛
    Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) E DNA Evolution
    Fibonacci
  • 原文地址:https://www.cnblogs.com/siqi/p/2665798.html
Copyright © 2011-2022 走看看