Cardinality
原创maclean_007 ©著作权
©著作权归作者所有:来自51CTO博客作者maclean_007的原创作品,请联系作者获取转载授权,否则将追究法律责任
The terms "high cardinality" and "low cardinality" are frequently used when discussing table columns. A high cardinality column means that a column has many unique values. For example, a primary key column is a high cardinality column since each value is, by definition, unique. A low cardinality column is the opposite. For example, a column representing sex only has two possible values (Male and Female).
High cardinality columns are often great candidates to be the first (and sometimes only) column in an index. This is due to the fact that the index will only request a small number of rows from the table.
Low cardinality columns are more difficult to index correctly. For example, consider the following query:
select * from employee where sex='F';
Without an index, this query will perform a full table scan. >This seem undesirable. However, adding an index will reduce the number of rows retrieved by the table, but may actually take much longer due to the index usage. In this case, a normal b-tree index is probably a bad idea. New features offered by database vendors (such as Oracle's bitmap and key compressed indexes) might be better solutions for low cardinality columns.
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
elasticsearch global 、 filters 和 cardinality 聚合
此处简单记录一下 `global` 、 `filters`和`cardinality`的聚合操作。
elasticsearch filters聚合 global聚合 cardinality聚合 es聚合 -
MySQL技术内幕 InnoDB存储引擎:Cardinality
并不是所有在查询条件中出现的列都需要添加索引,对于什么时候添加B+树索引,一般的经验是,在访问表
mysql innodb 引擎 Cardinality 索引