Beruflich Dokumente
Kultur Dokumente
What is EXPLAIN?
For each query executed in the database, PE will generate a execution plan i.e step-by-step process to
fetch the data or to complete the task
The EXPLAIN facility provides an "English" translation of the plan the SQL Optimizer develops to service
a request.
If we pass an explain command in front of a query statement or Simply Press F6 key, there are a several
estimated confidence messages that the optimizer will relay to the user is
Keyword Explanation
Pseudo tables are the dummy tables, Whenever we place a request which
Locking involves full table scan and needs data to be retrieved from all AMPS then the
Pseudo parsing engine identifies a gatekeeper AMP which can command all other AMP
Table to lock for a particular request from the user and does not allow multiple user to
access the same table to prevent global deadlock
Locking Indicates that an ACCESS, READ, WRITE, or EXCLUSIVE lock has been
table for placed on the table
Select - Read
All operatins related to data like insert,update,delete - Wrire
All operations realted to definition change i.e ALTER (adding new column,droping new
column),DROP,CREATE - Exclusive
Locking Indicates that an ACCESS, READ, or WRITE, lock is placed on rows read or
rows for written
All AMPs All AMPs are receiving the AMP steps and are involved in providing the answer
retrieve set
Join Types
The fastest join possible. It uses a UPI to retrieve a single row after using a UPI
Nested join
or a USI in the WHERE to reduce the join to a single row.
Rows of one table are matched to the other table on common domain columns
Merge join
after being sorted into the same sequence, normally Row Hash
Product Rows of one table are matched to all rows of another table with no concern for
join domain match
ROWID A very fast join. It uses the ROWID of a UPI to retrieve a single row after using
join a UPI or a USI in the WHERE to reduce the join to a single row.
1. First, we lock a distinct SQL_CLASS."pseudo table" for read on a RowHash to prevent global deadlock
for SQL_CLASS.Emp_Table.
4. Finally, we send out an END TRANSACTION step to all AMPs involved in processing the request.
-> The contents of Spool 1 are sent back to the user as the result of statement 1. The total estimated time
is 0.03 seconds.
If you see all-AMPs RETRIEVE by way of an all-rows scan in your plan, that means teradata is doing a
Full Table Scan. So it is reading every row in the table.
In the Emp_table, Emp_no is the Unique Primary Index. So USI used in where clause. So it gives Single-
AMP retrieve by way of the Unique Primary Index. This is the fastest query!
5 We do an all-AMPs JOIN step from SQL_CLASS.Dept by way of a RowHash match scan, which is
joined to Spool 2 (Last Use) by way of a RowHash match scan. SQL_CLASS.Dept and Spool 2 are
joined using a merge join, with a join condition of ("Dept_No = SQL_CLASS.Dept.Dept_No").