Vous êtes sur la page 1sur 20

EXPLAIN

spool n

Identifies a spool file, which is a


temporary file used to contain data
during an operation.

Spool 1 is normally used to hold a


result before it is returned to the user.
Spools 2, 3, etc., contain
intermediate data that produces a
result.

spool_n.Field
Identifies the field of the spooled
rows that is being used in a join
constraint or comparison
operation.
For example:
PERSONNEL.Employee.EmpNo =
Spool_2.MgrNo

the estimated time is


nn seconds.

The time shown is not clock


seconds; you should consider it to
be an arbitrary unit of measure
that compares different operations.

which is duplicated on all


AMPs

Relocating data in preparation for


a join.

which is redistributed by
hash code to all AMPs

Relocating data in preparation for


a join.

two-AMP RETRIEVE step by way of unique


index #n

A row of a table is selected based


on a unique secondary index:

A single row in the Unique Secondary


Index subtable is selected using the
index value that hashes to the AMP
on which the subtable row is stored.
The hash value in the index row ID
determines the AMP on which the
data row is stored.

SORT to order Spool n


by row hash

Rows in the spool file are sorted by


hash code to put them the same
order as rows in the primary table,
or in another spool file on the
same AMP, with which they are to
be matched

SORT to order Spool n by row hash


and the sort key in spool field1
eliminating duplicate rows

Rows in the spool file are sorted by hash code


using a uniqueness sort to eliminate duplicate
rows. Uniqueness is based on the data in field1.
The contents of field1 depend on the query and
may comprise any of the following:

A concatenation of all the fields in the spool row (used


for queries with SELECT DISTINCT or that involve a
UNION, INTERSECT, EXCEPT, or MINUS operation).
A concatenation of the row IDs that identify the data
rows from which the spool row was formed (used for
complex queries involving subqueries).

SORT to order Spool 1 by


the sort key in spool
field1

Rows in the spool file are sorted by


the value in field1. The contents of
field1 are determined by the
column or columns defined in the
ORDER BY or WITH...BY clause of
the request being processed.

SORT to partition Spool


n by rowkey

The optimizer determined that a spool


file is to be partitioned based on the
same partitioning expression as a table
to which the spool file is be joined.
That is, the spool is to be sorted by
rowkey (partition and hash).
Partitioning the spool file in this way
allows for a faster join with the
partitioned table. n is the spool
number.

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

BMSMS is a method for handling


weakly selective secondary
indexes that have been ANDed;
NUSI bit mapping.

Query

Explain

BMSMS

On each nonunique secondary index subtable, each data row ID is assigned a


number from 0-32767.
This number is used as an index into a
bit map in which the bit for each
qualifying row is turned on.
BMSMS indicates that the intersection of
sets of qualifying rows is computed by
applying the logical AND operation to the
bitmap representation of the sets.

we do a SMS (set
manipulation step)

Combine rows under control of a


UNION, EXCEPT, MINUS, or
INTERSECT operator.

we do an ABORT test

An ABORT or ROLLBACK statement


was detected.

QUERY
EXPLAIN
SELECT Name, EmpNo
FROM Employee
WHERE EmpNo IN
(SELECT EmpNo
FROM Charges)
ORDER BY Name ;

EXPLAIN

1) First, we lock a distinct PERSONNEL."pseudo table" for


read on a RowHash to prevent global deadlock for
PERSONNEL.charges.
2) Next, we lock a distinct PERSONNEL."pseudo table" for
read on a RowHash to prevent global deadlock for
PERSONNEL.employee.
3) We lock PERSONNEL.charges for read, and we lock
PERSONNEL.employee for read.
4) We do an all-AMPs RETRIEVE step from
PERSONNEL.charges by way of an all-rows scan with no
residual conditions into Spool 2, which is redistributed by
hash code to all AMPs. Then we do a SORT to order Spool
2 by row hash and the sort key in spool field1 eliminating
duplicate rows. The size of Spool 2 is estimated to be 12
rows. The estimated time for this step is 0.15 seconds.

EXPLAIN

5) We do an all-AMPs JOIN step from


PERSONNEL.employee by way of an all-rows scan with
no residual conditions, which is joined to Spool 2 (Last
Use). PERSONNEL.employee and Spool 2 are joined
using an inclusion merge join, with a join condition of
("PERSONNEL.employee.EmpNo = Spool_2.EmpNo").
The result goes into Spool 1, which is built locally on the
AMPs. Then we do a SORT to order Spool 1 by the sort
key in spool field1. The size of Spool 1 is estimated to be
12 rows. The estimated time for this step is 0.07
seconds.
-> The contents of Spool 1 are sent back to the user as
the result of statement
1. The total estimated time is 0 hours and 0.23 seconds.

Vous aimerez peut-être aussi