Optimizing Teradata SQL Queries by Avoiding Full Table Scans and Utilizing Secondary Indexes
May 14, 2023 3:00 pm
Hi,
Boosting your SQL query performance can be as simple as rethinking the use of functions like COALESCE in the WHERE clause:
SELECT * FROM DWHPRO.INDEX_USAGE
WHERE COALESCE(TheStartDate,TheEndDate) = DATE'2022-10-10';
When used on indexed columns, it can hinder the effective use of indexes, leading to full table scans.
By avoiding such functions or replacing them with direct column references, we can allow the optimizer to leverage indexes more effectively, significantly speeding up query execution:
Best Regards,
Roland - DWHPro