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.

  • 相关阅读:
    poj 2253
    POJ 3273
    python基本运算符
    python基本数据类型以及常量变量
    pycharm的快捷键
    计算机基础
    day100 scrapy请求传参 中间件 去重规则 分布式爬虫
    day99 爬虫 scrapy介绍 结构介绍
    day98 爬虫 selenium
    day97 爬虫bs4
  • 原文地址:https://www.cnblogs.com/lynnge/p/5671536.html
Copyright © 2011-2022 走看看