View refresh after collect stats

Database
Enthusiast

View refresh after collect stats

Hi,

Lets say am collecting stats for a table and once when i have done that, do i need to refresh its corresponding view?

Regards

Sunny

2 REPLIES
Enthusiast

Re: View refresh after collect stats

Not, you can request the views or make selects from the tables at once.

Regards.

Teradata Employee

Re: View refresh after collect stats

With a Teradata view, there is nothing to refresh. A view does not materialize the underlying data. It does not store data about the underlying tables. It is compiled on the fly as a query references the view and the query is built from the sum of all the referenced views, then turned into an optimized plan using the underlying stats as the query is being optimized.

For some queries Teradata keeps those plans in a cache to optimize repetitive use of the same query. When this is the case and stats are collected or the data is changed significantly or the DDL is changed, Teradata automatically spoils those cache entries so the query will get replanned with the new information - no action on the part of the developer/dba/user.

It is possible to build a materialized view via Teradata's join index capability. When a join index is in place, stats are sometimes colleccted on the JI itself and sometimes collected on the base table. Again, the current stats will always be used at the time the query is parsed without requiring any rebuilding/refreshing of the JI.