Steps To Improve Teradata Query Performance
Steps To Improve Teradata Query Performance
TCS Confidential
Teradata tips to
improve
performance
DC/ SC/ Geo/Practice: Best Practice
Name of the project/support fn: General
Name of the author: Savitha C V
Date Created:07-Oct-2012
7 February 2013
Description
Project / Context
The implementing teradata tips during coding will improve
performance and reduce performance cases when we move
code to production.
Purpose
1. Teradata query performance will increase
2. Reduce performance issues
3. Customer satisfaction will increase due to less issues
7 February 2013
How we did it
Teradata Performance Tuning - Basic step
Performance tuning thumb rules. Here are very basic steps which are used to
Performance Tuning any given query in given environment . As a prerequisite , make sure
- user has proper select rights and actual profile settings
- Enough space available to run and test the queries
1. Run explain plan (pressing F6 or EXPLAIN sel * ,)
Then see for potential information like
- No or low confidence
- Product joins conditions
- By way of an all row scan - FTS
- Translate
- Execution time is more than 3 mins
7 February 2013
How we did it
Teradata Performance Tuning - Basic Tips
Also check for
- Distinct or group by keywords in SQL query
- In/ not in keywords and check for the list of values generated for the same
7 February 2013
How we did it
Teradata Performance Tuning - Basic Tips contd.
B. collects stats
- Run command "diagnostic help stats on for the session"
- Gather information on columns on which stats has to be collected
- Collect stats on suggestions columns
- Also check for stats missing on PI, SI or columns used in joins - "help
stats <database name>.<table name>
- Make sure stats are re-collected when at-least 10% of data
changes
- remove unwanted stats or stat which hardly improves performance
of the queries
- Collect stats on columns instead of indexes since index dropped will
drop stats as well!!
- collect stats on index having multiple columns, this might be helpful
when these columns are used in join conditions
- Check if stats are re-created for tables whose structures have
some
changes
- Refresh your stats and make sure you have stats collected on the where
and ON criteria. Make sure you have stats collected on your NUSI.
7 February 2013
How we did it
Teradata Performance Tuning - Basic Tips contd.
c. Full table scan scenarios
- Try to avoid FTS scenarios as, it might take very long time to access
all the data in every amp in the system
- Make sure SI is defined on the columns which are used as part of
joins or Alternate access path.
-Collect stats on SI columns else there are chances where optimizer
might go for FTS even when SI is defined on that particular column
D. Global Temporary Tables usage
- Use GTTs where huge amount of data might be in the spool, through a
derived table or a volatile table. The advantage of GTT is that you can
collect stats on the join columns.
- For your information we can collect stats on Volatile temporary tables in
Teradata Version 13
7 February 2013
How we did it
Teradata Performance Tuning - Basic Tips contd.
1.Use EXISTS AND NOT EXISTS instead of IN and NOT IN function when we
have large data to improve performance
2. Use group by function instead of DISTINCT to avoid full table scan
3. Run the command below and then run EXPLAIN plan on that query to get
recommended stats for the particular query
DIAGNOSTIC HELPSTATS ON FOR SESSION;
4. To get a more detailed explain plan, run the command below before executing
EXPLAIN:
DIAGNOSTIC VERBOSEEXPLAIN ON FOR SESSION;
7 February 2013
Benefits
Issues will reduce due to which customer satisfaction will
increase. Good practice to follow up the steps while
coding
7 February 2013
Contact Info
Name : Savitha C V
Employee No. : 210055
Email ID : [email protected]
7 February 2013