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

    1,如果整形数据没有负数,如ID号,建议指定为UNSIGNED无符号类型,容量可以扩大一倍。

    2,建议使用TINYINT代替ENUMBITENUMSET

    3,避免使用整数的显示宽度,也就是说,不要用INT(10)类似的方法指定字段显示宽度,直接用INT

    4,字符串的长度相差较大用VARCHAR;字符串短,且所有值都接近一个长度用CHAR

    5,所有字段均定义为NOT NULL。

    6,将大字段、访问频率低的字段拆分到单独的表中存储,分离冷热数据。

    7,禁止在数据库中存储明文密码。

    8,用IN代替OR。SQL语句中IN包含的值不应过多,应少于1000个。

    9,SELECT只获取必要的字段,禁止使用SELECT *。

    10,单张表索引不要太多,建议不超过5个。

    11. 避免建立重复索引和冗余索引
    11.1 重复索引,如:PRIMARY KEY(id),index(id),unique(ID)
    11.2 冗余索引,如:index(a,b,c),indec(a,b),index(a)

    参考文档

     https://blog.csdn.net/hjvgf/article/details/70053239

    https://blog.csdn.net/xyw591238/article/details/51965089?locationNum=1&fps=1

    https://www.awaimai.com/1146.html#int-display-width

  • 相关阅读:
    LeetCode Power of Three
    LeetCode Nim Game
    LeetCode,ugly number
    LeetCode Binary Tree Paths
    LeetCode Word Pattern
    LeetCode Bulls and Cows
    LeeCode Odd Even Linked List
    LeetCode twoSum
    549. Binary Tree Longest Consecutive Sequence II
    113. Path Sum II
  • 原文地址:https://www.cnblogs.com/wen-zi/p/9132367.html
Copyright © 2011-2022 走看看