Cardinality表示唯一值的个数 -----------这段话的英文不知道谁翻译的明显是有问题的 
show keys in a; 这个字段Cardinality =18. (该表总记录44万 只有值只有2个 'Y' 'N')
如果Cardinality表示唯一值的个数 那么这里他的值应该是2或者3 ('Y' 'N' NULL). 但是从mysql执行得到该Cardinality =18.有谁能解释吗 ???

解决方案 »

  1.   


    Cardinality An estimate of the number of unique values in the index. This is updated by running ANALYZE TABLE or myisamchk -a. Cardinality is counted based on statistics stored as integers, so the value is not necessarily exact even for small tables. The higher the cardinality, the greater the chance that 
    这段英语显然和你看到的并不一样!一个关于索引中唯一量的 估计值 ,(我也不知道怎么翻译,可以的汉语),你需要知道的是,这是一个估计值。
    另外你可以用 analyze table table1 分析一下后再看 show index 的结果。
      

  2.   

    简单的说,Cardinality就是一个统计值,通常用于统计列。
    比如sum(*), 方差之类的。
      

  3.   

    感谢。  他仅仅是一个估计estimate 。忘了补充一点 ,我的上面的表是 innodb ,上面英文的是 running ANALYZE TABLE or myisamchk -a.
    说明是仅对myisam有效但我的表总记录44万 只有值只有2个 'Y' 'N') 。 这给 2或3  与show keys in a;估计出来的值18  出入会那么大 吗 ???按照这个意思 ,这个索引都不应该建立。  
      

  4.   

    实际上程序加上了索引 sql执行飞快的有时候不能相信的这些。  必须看实际情况