DWHPro Insights

Insights

327 technical articles on Teradata, Snowflake, Databricks, SQL tuning and data warehouse architecture — written from production experience, not vendor decks.

Optimizing Teradata Requests with Group-AMP Operations for Improved Performance

Illustration of a stopwatch dial on an orange paint-splash background

All-AMP describes participating AMPs, not a mandatory full-table or subtable scan. NUSI access can be narrowed by other predicates and maps; inspect the actual access steps. Group-AMP operations optimize requests by minimizing the number of active AMPs. These operations fall between single-AMP and all-AMP operations. The Optimizer employs group-AMP for data retrieval and joins. A …

Read more

Learn Teradata Indexing Techniques in this 2-Hour Video Course

Illustration of a glossy orange database cylinder with data fragments across its surface

This course focuses on Teradata indexing techniques. In this two-hour video, you will learn about Teradata’s architecture and Full Table Scans, different types of Primary Index Access such as UPI and NUPI, diverse Secondary Index Access including USI and NUSI, and Join Indexes. This historical video introduction covers indexing topics. The embedded video itself was …

Read more

Teradata ASCII: Built-in Function and Legacy CHAR2HEXINT Example

Illustration of a stopwatch dial on an orange paint-splash background

Introduction

The tested Teradata release supports SELECT ASCII('B');, which returned 66. The CHAR2HEXINT expression below is a legacy encoding-dependent example, not a necessary replacement for the built-in function.

The solution is as follows:

We use the Teradata SQL function CHAR2HEXINT to obtain a hexadecimal value for a character. Our objective is to convert this hexadecimal value to its decimal counterpart, which signifies the character’s ASCII code.

The following legacy expression demonstrates the calculation for this specific character and encoding.

SELECT
CASE SUBSTRING(CHAR2HEXINT('B') FROM 3 FOR 1)
WHEN '0' THEN 0
WHEN '1' THEN 1
WHEN '2' THEN 2
WHEN '3' THEN 3
WHEN '4' THEN 4
WHEN '5' THEN 5
WHEN '6' THEN 6
WHEN '7' THEN 7
WHEN '8' THEN 8
WHEN '9' THEN 9
WHEN 'A' THEN 10
WHEN 'B' THEN 11
WHEN 'C' THEN 12
WHEN 'D' THEN 13
WHEN 'E' THEN 14
WHEN 'F' THEN 15
END * 16 +
CASE SUBSTRING(CHAR2HEXINT('B') FROM 4 FOR 1)
WHEN '0' THEN 0
WHEN '1' THEN 1
WHEN '2' THEN 2
WHEN '3' THEN 3
WHEN '4' THEN 4
WHEN '5' THEN 5
WHEN '6' THEN 6
WHEN '7' THEN 7
WHEN '8' THEN 8
WHEN '9' THEN 9
WHEN 'A' THEN 10
WHEN 'B' THEN 11
WHEN 'C' THEN 12
WHEN 'D' THEN 13
WHEN 'E' THEN 14
WHEN 'F' THEN 15
END

Using a CASE statement, the query extracts two hexadecimal digits with the SUBSTRING function and converts them to decimal values. It then calculates the character’s ASCII code by multiplying the first digit’s decimal value by 16 and adding the second digit’s decimal value.

Conclusion

Prefer the documented ASCII function when its semantics match the task. The legacy workaround returned 66 for B with CHAR2HEXINT yielding 0042 in the tested context. Its fixed substring positions are not a general solution for arbitrary character sets or Unicode characters.

Why Teradata DBAs Should Prioritize Housekeeping the DBC AccessRights Table

Illustration of a person in a suit standing beside a database cylinder

As any experienced Teradata DBA will tell you, some tables in the Teradata dictionary (DBC) need housekeeping. But some customer sites that I have worked with ignore table DBC.AccessRights. If you have ever analyzed this table on a Teradata system, you will almost certainly spot two things quickly. Do not modify DBC.AccessRights directly. Fewer rows …

Read more

Is Teradata Compression Worth Your Time and Effort?

Illustration of a stopwatch dial on an orange paint-splash background

Teradata DBMS offers various compression options to save disk space and improve performance. But, the cost of implementing the compression takes man-time. This article discusses the cost vs. benefit of compression and suggests carefully considering the compression setting when designing new or modifying existing tables.

Benefits of Organizing Stored Procedures into Chapters and Steps

Illustration of a glossy orange database cylinder with data fragments across its surface

I made organizing Stored Procedures into Chapters and Steps a principle. These separation points are marked by comments and variables used in performance and result logging. A step refers to a technical or conceptual task that cannot be further divided without losing the abstraction of Stored Procedures or the main task. Examples of a step …

Read more

Protected by Security by CleanTalk