博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL index
阅读量:5322 次
发布时间:2019-06-14

本文共 1054 字,大约阅读时间需要 3 分钟。

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.

转载于:https://www.cnblogs.com/lynnge/p/5671536.html

你可能感兴趣的文章
zoj 1232 Adventure of Super Mario
查看>>
Oracle 序列的应用
查看>>
1201 网页基础--JavaScript(DOM)
查看>>
组合数学 UVa 11538 Chess Queen
查看>>
uva 10004 - Bicoloring
查看>>
oracle job
查看>>
Redis常用命令
查看>>
C语言 · Sine之舞
查看>>
C语言 · 简单加法
查看>>
好用的在线Markdown编辑器
查看>>
wtforms
查看>>
EFCode First 导航属性
查看>>
嵌入式Linux开发
查看>>
Swift语法初见
查看>>
XML学习笔记(二)-- DTD格式规范
查看>>
前端基础之html
查看>>
I - Agri-Net - poj 1258
查看>>
git 的回退
查看>>
IOS开发学习笔记026-UITableView的使用
查看>>
Confluence配置数据库
查看>>