행위

"선택도 카디널리티 Selectivity vs. Cardinality"의 두 판 사이의 차이

DB CAFE

1번째 줄: 1번째 줄:
 
== 선택도 와 카디날리티 조회 SQL ==
 
== 선택도 와 카디날리티 조회 SQL ==
 
<source lang=sql>
 
<source lang=sql>
select column name
+
select column_name
 
     , num_distinct
 
     , num_distinct
 
     , num_nulls
 
     , num_nulls
     , 1/num distinct selectivity
+
     , 1/num_distinct selectivity
     , round (1/num distinct * t.num_rows, 2) cardinality
+
     , round(1/num_distinct * t.num_rows, 2) cardinality
 
   from user_tables t
 
   from user_tables t
 
     , user_tab_columns c
 
     , user_tab_columns c
  where t.table name = :tbl
+
  where t.table_name = :tbl
 
   and c.table_name = t.table_name
 
   and c.table_name = t.table_name
 
  order by column_id ;
 
  order by column_id ;
 
</source>
 
</source>

2023년 1월 3일 (화) 22:13 판

thumb_up 추천메뉴 바로가기


선택도 와 카디날리티 조회 SQL[편집]

select column_name
     , num_distinct
     , num_nulls
     , 1/num_distinct selectivity
     , round(1/num_distinct * t.num_rows, 2) cardinality
  from user_tables t
     , user_tab_columns c
 where t.table_name = :tbl
   and c.table_name = t.table_name
 order by column_id ;