Understanding MaxValueLength and Its Importance in Teradata Statistics

What Is MaxValueLength Used For?

At times, gathering statistics on character columns of considerable width becomes necessary, such as VARCHAR(1000).

Prior to Teradata Release 13.10, statistics histograms were created using only the initial 16 bytes of a column, disregarding and truncating the remaining bytes.

The value “012345678901234567890” was deemed equal to “0123456789012345,” resulting in both producing identical statistical data.

Ultimately, this resulted in inaccurate statistics, and troubleshooting the issue proved to be arduous.

How MaxValueLength Improves Teradata Statistics

Teradata has introduced a solution to mitigate this issue. The new feature enables the user to define the number of bytes or characters to be considered when generating statistics histograms. This feature is called MaxValueLength.

MAXVALUELENGTH n
Specifies the maximum size for histogram values such as MinValue, ModeValue, MaxValue, etc.

Character and VARCHAR columns specify a character count for statistics, while all other data types specify a byte count.

To expand the scope of collected statistics, execute the following command and specify the desired number of bytes or characters to include. For instance, if you wish to include 100 bytes (assuming that CustomerId is an INTEGER), use the following option:

COLLECT STATISTICS USING MAXVALUELENGTH 100 COLUMN (CustomerId) ON Customer;

Related Services

⚡ Need Help Optimizing Your Data Platform?

We cut data platform costs by 30–60% without hardware changes. 25+ years of hands-on tuning experience.

Explore Our Services →

📋 Considering a Move From Teradata?

Get a personalized migration roadmap in 2 minutes. We have migrated billions of rows from Teradata to Snowflake, Databricks, and more.

Free Migration Assessment →

📊 Data Platform Migration Survey

Help us map where the industry is heading. Results are public — see what others chose.

1. What is your current data platform?

2. Where are you migrating to (or evaluating)?

Migrating FROM
Migrating TO

Thanks for voting! Share this with your network.

Follow me on LinkedIn for daily insights on data warehousing and platform migrations.

Stay Ahead in Data Warehousing

Get expert insights on Teradata, Snowflake, BigQuery, Databricks, Microsoft Fabric, and modern data architecture — delivered to your inbox.

1 thought on “Understanding MaxValueLength and Its Importance in Teradata Statistics”

  1. Can you show some examples in T13.10?

    So if I have a T1(col1 char(16),col2 char(20)), will the stats on (col1,col2) ignore col2? What does help stats show.

    Reply

Leave a Comment

DWHPro

Expert network for enterprise data platforms. Senior consultants, project teams built for your challenge — across Teradata, Snowflake, Databricks, and more.

📍Vienna, Austria & Jacksonville, Florida

Quick Links
Services Team Teradata Book Blog Contact Us
Connect
LinkedIn → [email protected]
Newsletter

Join 4,000+ data professionals.
Weekly insights on Teradata, Snowflake & data architecture.