zoukankan      html  css  js  c++  java
  • MySQL index

    dont create index on each column

    for multicolumn index, the column order matters for B-Tree index

    UNIQUE and PRIMARY KEY are constraints, not indexes. Though most databases implement these constraints by using an index. The additional overhead of the constraint in addition to the index is insignificant, especially when you count the cost of tracking down and correcting unintentional duplicates when (not if) they occur.

    Indexes are usually more effective if there you have a high selectivity. This is the ratio of number of distinct values to the total number of rows.

    For example, in a column for Social Security Number, you may have 1 million rows with 1 million distinct values. So the selectivity is 1000000/1000000 = 1.0 (although there are rare historical exceptions, SSN's are intended to be unique).

    But another column in that table, "gender" may only have two distinct values over 1 million rows. 2/1000000 = very low selectivity.

    So create index on non-unique column may slow down the query.

  • 相关阅读:
    nuget
    C#枚举中使用Flags特性
    情感分析
    docker
    core部署
    脱壳系列_2_IAT加密壳_详细分析(含脚本)
    安全公司-* * * *-面试题:_ 安卓逆向分析分享
    18_ShadowWalker
    17_页面异常接管
    16_TLB与流水线
  • 原文地址:https://www.cnblogs.com/lynnge/p/5671536.html
Copyright © 2011-2022 走看看