In Teradata I can use a statement like ...
collect statistics on my_table column(col1)
This will gather stats on the table and store them in DBC views like ColumnStats, IndexStats and MultiColumnStats. I'm also under the impression that the optimizer (parsing engine) will find the statistics when they are available and use them instead of estimated table cardinality/index value counts to make better decisions on how to execute a query.
This all sounds great, but I have some questions.
- are there any disadvantages to using
collect stats
? - When is it appropriate/inappropriate to use collect statistics in your SQL scripting?
- What's the performance benefit to collect statistics on a field that's already indexed?
- How long are statistics stored for (table, volatile tables)?
- Any other comments concerning
collect statistics
would be appreciated.