Explain Facility at Teradata for a Query

download Explain Facility at Teradata for a Query

of 13

Transcript of Explain Facility at Teradata for a Query

  • 8/13/2019 Explain Facility at Teradata for a Query

    1/13

    EXPLAINExplains your executions steps

  • 8/13/2019 Explain Facility at Teradata for a Query

    2/13

    Explain? whats that? A keyword.

    Main benefits

    Thats means---its a good way to learn aboutsystem

  • 8/13/2019 Explain Facility at Teradata for a Query

    3/13

    Where it comes from?

    Optimizer needs info about:1)TD configuration environment

    2)Data demographics

  • 8/13/2019 Explain Facility at Teradata for a Query

    4/13

    Simplest Example

    1) First, we do a single-AMPRETRIEVEstep from STUDENTS.customerby

    way of the uniqueprimaryindex "STUDENTS.customer.Customer_Number

    = 2100" with no residual conditions. The estimated time for this

    step is 0.01 seconds.

    -> The row is sent directly back to the user as the result of

    statement 1. The total estimated time is 0.01 seconds.

    BUT IF

    EXPLAINSEL* FROMcustomer;

    EXPLAIN SEL* FROMcustomerWHEREcustomer_number=2100;

  • 8/13/2019 Explain Facility at Teradata for a Query

    5/13

    1) First, we locka distinct STUDENTS."pseudo table" for readon a

    RowHashto prevent global deadlock for STUDENTS.customer.2) Next, we lockSTUDENTS.customerfor read.

    3) We do an all-AMPs RETRIEVEstep from STUDENTS.customerby way of

    an all-rows scanwith no residual conditions into Spool 1

    (all_amps), which is builtlocallyon the AMPs. The size of Spool

    1 is estimated with low confidence to be 202 rows (15,958 bytes).The estimated time for this step is 0.03 seconds.

    4) Finally, we send out an END TRANSACTION step to all AMPs involved

    in processing the request.

    -> The contents of Spool 1are sent back to the user as the result of

    statement 1. The total estimated time is 0.03 seconds.

  • 8/13/2019 Explain Facility at Teradata for a Query

    6/13

    Some key statements

    ... Pseudo Table Locks

    ... (Last Use)

    ... with no residual conditions

    ... END TRANSACTION

    ... by way of the sort key in spool field1 (dbname.tablename.colname)

    ... We do an ABORT test

    ... We execute the following steps in parallel...

  • 8/13/2019 Explain Facility at Teradata for a Query

    7/13

    Cont ... which is redistributed by hash code to all AMPs

    (dbname.tablename.colname)

    ... which is duplicated on all AMPs

    ... (one_amp) or (group_amps) or (all_amps)

    ... ("NOT (table_name.column_name IS NULL)")

    ... eliminating duplicate rows ...

    we do SMS(set manipulation steps)

    ... we do a BMSMS (bit map set manipulation step)

  • 8/13/2019 Explain Facility at Teradata for a Query

    8/13

    Cont . . . with high confidence . . .

    . . . with low confidence . . .

    . . . with no confidence . . .

    . . . with index join confidence . . .

  • 8/13/2019 Explain Facility at Teradata for a Query

    9/13

    Explaining CREATE

  • 8/13/2019 Explain Facility at Teradata for a Query

    10/13

    Explaining macros

  • 8/13/2019 Explain Facility at Teradata for a Query

    11/13

    Contd

    1) First, we lock a distinct MyDB."pseudo table" for read on a RowHash to prevent

    global deadlock for MyDB.Employee.

    2) 2) Next, we lock MyDB.Employee for read.

    3) 3) We do an all-AMPs RETRIEVE step from MyDB.Employee by way of an all-

    rows scan with a condition of ("MyDB.Employee.Dept_Number = :dept_no")into Spool 1 (group_amps), which is built locally on the AMPs. The size of Spool

    1 is estimated with low confidence to be 19 rows (1,463 bytes). The estimated

    time for this step is 0.02 seconds.

    4) 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.02 seconds.

    EXPLAIN USING (dept_no INTEGER) EXECUTE Dept_List (:dept_no);

  • 8/13/2019 Explain Facility at Teradata for a Query

    12/13

    Some PPI Terminologies a single partition of or n partitions of

    SORT to partition Spool m by rowkey

    a rowkey-based

    enhanced by dynamic partition

  • 8/13/2019 Explain Facility at Teradata for a Query

    13/13

    PPI vs. NPPI