Quantcast
Channel: Teradata Developer Exchange - Blog activity for carrie's blog
Viewing all articles
Browse latest Browse all 1058

Tips on using Sampled Stats - comment by carrie

$
0
0

Santanu,
 
You cannot actually apply USING SAMPLE to summary stats, which are the table-level statistics new in 14.0.  I'm guessing you meant you were collecting sampled stats on a column or index of the table.
 
When you attach USING SAMPLE to a collect stats statement and then collect stats on that column, the resulting histogram will be treated the same was as if full stats had been collected.   The sampling option only has an impact during the collection of statistics, and not how those stats are used.  The optimizer will use the number of distinct values in the histogram to base its estimates on the row count that will come out of an aggregation process if sample or full stats have been collected on the GROUP BY column(s).
 
Whether or not sampled stats are as beneficial as collecting full stats in your case will depend on the degree of skew in the GROUP BY column.  You could run an explain and look at the query plan row count estimate with sampled stats, then collect full stats and see if the estimate has changed very much.  
 
Thanks, -Carrie


Viewing all articles
Browse latest Browse all 1058

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>