- Connect to the Teradata database using SQLA or Studio.
- Write SHOW in front of the query and execute it to get the list of all objects in the query, with their definitions.
- Once you have the DDLs of all the objects, check the columns involved in joins.
- Execute EXPLAIN for the query by pressing F6 in SQLA or writing EXPLAIN in front of the query and pressing F5.
- In EXPLAIN, check for extremely high estimated rows or extremely low estimated rows and time; if these estimations are not in relation to table statistics, refresh the stats on the columns:
/*High Estimated Explain*/1) We do an all-AMPs RETRIEVE step from SYSDBA.FC in view SYSDBA.SITES by way of an all-rows scan with no residual conditions into Spool 7 (all_amps) ...