zoukankan      html  css  js  c++  java
  • mysql优化初探

    这里用的是Mysql5.6.34win64版本

    设计数据库

    3F范式

    分库分表

    垂直分割

    水平分割取模算法

    修改配置


    下面是我的配置文件

    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
    # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
    # *** default location during install, and will be replaced if you
    # *** upgrade to a newer version of MySQL.
    
    [mysqld]
    
    character_set_server = utf8
    
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
    log_bin=ON
    #错误日志
    #log_error=D:Program Filesmysql-5.6.34-winx64datalogserr.log
    #全查询日志 
    #log_output=FILE  
    
    #不启用的话慢日志查询会存在数据表中
    general_log=on
    general_log_file=query.log
    
    #慢查询日志
    slow_query_log=on   
    long_query_time=2
    #时间为2s
    slow_query_log_file=slowquery.log
    
    
    # These are commonly set, remove the # and set as required.
     basedir = D:Program Filesmysql-5.6.34-winx64
    # 日志存放目录
     datadir = D:Program Filesmysql-5.6.34-winx64data
     port = 3306
    # server_id = .....
    
    #二进制日志配置,第二、三行配置最后一个binlog-bin和binlog是不加后缀的文件名,不加后缀的话有妙用
    server_id=1
    #log_bin=D:Program Filesmysql-5.6.34-winx64datain_loginlog-bin
    #log_bin_index=D:Program Filesmysql-5.6.34-winx64datain_loginlog
    
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M 
    
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
    
    

    索引

    当数据有重复的时候,如何降低幂等

    唯一索引

    定位慢查询

    日志配置在上面,将慢查询时间设置好(默认是10秒),重启mysql服务,之后如果超过设定时间,就会记录在log日志中。

  • 相关阅读:
    (转)我是一个小线程
    Gson本地和服务器环境不同遇到的Date转换问题 Failed to parse date []: Invalid time zone indicator
    Bigdecimal 比较equals与compareTo
    springboot jpa mongodb 多条件分页查询
    springboot Consider defining a bean of type 'xxx' in your configuration
    mongodb you can't add a second
    java8 获取某天最大(23:59:59)和最小时间(00:00:00)
    java volatile详解
    SpringBoot dubbo之class is not visible from class loader
    springboot dubbo filter之依赖注入null
  • 原文地址:https://www.cnblogs.com/adroitwolf/p/14310059.html
Copyright © 2011-2022 走看看