优化必懂概念-基数

1、概念
某一列唯一键的数量叫做基数。

2、举例
性别列,该列只分男女,so 这一列的基数为2。

3、测试
SYS@orcl> select count(distinct owner),count(distinct object_id),count(*) from t;

COUNT(DISTINCTOWNER) COUNT(DISTINCTOBJECT_ID)   COUNT(*)
-------------------- ------------------------ ----------
                  20                    83962      83962

    t表的总行数为83962,owner列的基数为20,object_id的基数83962,说明owner列有大量的重复值。object_id很有可能是主键。

    SYS@orcl> select owner,count(*) from t group by owner order by 2 desc;

OWNER                            COUNT(*)
------------------------------ ----------
SYS                                 37365
PUBLIC                              33339
SYSMAN                               3554
APEX_030200                          2561
ORDSYS                               2513
MDSYS                                1447
XDB                                  1167
SYSTEM                                611
CTXSYS                                389
WMSYS                                 333
EXFSYS                                312
ORDDATA                               257
DBSNMP                                 57
FLOWS_FILES                            13
OUTLN                                  10
ORDPLUGINS                             10
ORACLE_OCM                              8
SI_INFORMTN_SCHEMA                      8
APPQOSSYS                               5
ROIDBA                                  3

20 rows selected.

SYS@orcl> 

标题名称:优化必懂概念-基数
URL分享:http://myzitong.com/article/ihcjph.html