Subject How to check if index selectivity is out of date?
Author Salvatore Besso
hello all,

a question that maybe for someone is obvious, but not for me.

With this query:

SELECT RDB$INDEX_NAME, RDB$STATISTICS FROM RDB$INDICES
WHERE RDB$SYSTEM_FLAG IS NULL;

I obtain a series of values or states representing selectivity of every
non-system index. If RDB$STATISTICS is null this should mean that
selectivity has never been updated from database creation, and that's ok.
But if RDB$STATISTICS contains a value, how can I know if this value is out
of date?

Should selectivity recomputation be performed periodically for best
performance? If yes at which intervals? I thought to query RDB$INDICES just
to retrieve an out of date indicator (if possible) and suggest a
recomputation for indexes that are out of date.

Last question: Should indexes be rebuilt periodically for best performance
also?

Thank you and best regards
Salvatore