Teradata Stale Statistics

2
942

 

When the degree to which a given set of statistics is a good representation of the current table demographics is under scrutiny, I often experience that people rely solely on the collection date.

Some tables will not have Teradata stale statistics even if you never refresh them. Just think about lookup tables which are quite static. For other tables, various degrees of changes can occur, with some fields having ever-expanding value ranges and others a constant share of only a few codes. How can get a better picture about statistics and find out if they are stale?  There are several possibilities. Maybe the easiest could be to just run a simple query on the table and using a WHERE CONDITION on the column which should be tested.

SELECT * FROM TABLE WHERE TEST_COLUMN = ‘X’;

Compare the number of estimated records (you can see this number in the Teradata Administrator) with the real number returned and you know if the statistics are stale.

Note that you cannot expect the optimizer to be right down to the individual row on any occasion, but the divergence should not be any larger than a small one-digit percentage,  depending on the overall table size.

Our Reader Score
[Total: 3    Average: 4.7/5]
Teradata Stale Statistics written by Roland Wenzlofsky on March 7, 2014 average rating 4.7/5 - 3 user ratings

2 COMMENTS

  1. Hi Alan,

    One example comes to my mind:

    In case the Teradata system configuration changes (for example, by adding nodes) and rows of a PPI Table are distributed to new partitions.

    This happens for example if you are using the HASHING functions of Teradata in the PARTITIONG definition of your table DDL:

    HASHAMP(HASHBUCKET(HASHROW(column)))

    As a bigger system has more AMPS, rows are distributed differently to the partitions and the statistics become stale and have to be recollected.

    This is an example, where the table content stayed the same but statistics became stale.

  2. I was once advised to recollect statistics on all the static ‘lookup’ tables held in a database, on a monthly basis, ‘just in case’ the statistics needed refreshed…needless to say, I never saw a reason to do this as it never had any impact. Would there ever be a case where statistics become ‘stale’ and therefore ignored by the optimizer in such circumstances?

LEAVE A REPLY

Please enter your comment!
Please enter your name here