문제

How to measure selectivity for composite index. I know how to measure selectivity of a single column for a index. But if I want to use multiple columns to create composite index, how do I measure the selectivity in order to decide.

도움이 되었습니까?

해결책

If, by "selectivity for composite index", you mean, how many rows, on average, will be returned when I specify values for Col1, Col2, ... ColN, then you can calculate that with:

SELECT COUNT(*) / SUM(C) FROM 
  (
    SELECT COL1, COL2, ... COLN, COUNT(*) C
    FROM TABLE
    GROUP BY COL1, COL2, ... COLN
  )
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top