When you use an
N-way join,
SPD Server returns what_join$ and why_join$ information for each pairwise
join of the N-way join.
execute(reset
details="why_join$what_join$"
_method jointech_pref=none)
by sasspds;
execute (create table tblout
as select *
from tablea, tableb, tablec
where a1 = a2
and a2 = a3)
by sasspds;
**WHY_JOIN( 1)?: Plan a Inner Join
**WHY_NIDX( 1)?: No INDEX on join column
**WHY_MERG( 1)?: Index join not selected, do merge join
**WHY_JOIN( 2)?: Plan a Inner Join
**WHY_JOIN( 2)?: INDEX available on 1 tables
**WHY_JOIN( 2)?: Index Join pass 1
**WHY_JOIN( 2)?: Inner table [X0000010].TABLEA Index a1
**WHY_JOIN( 2)?: Idx dup_ratio(1.00) > indexselectivity(0.70)
**WHY_INDX( 2)?: Favorable inner table index dup_ratio
SPDS_NOTE: PROC SQL planner chooses indexed join.
**WHY_HASH( 1)?: merge xformed to hash join, num_hashjoins=1
SPDS_NOTE: PROC SQL planner chooses hash join.
**WHY_HASH( 1)?: Inset optimization, hashkeys(100) le hashinsetsize(1024)
The what_join$ details
produce two SPD Server notes. The first note in the SAS log above
reads
PROC SQL planner chooses indexed join
,
and the second note reads
PROC SQL planner chooses hash
join
. These notes indicate that two pairwise joins
were required for the query: an index join and a hash join.
The why_join$ details
show how each pairwise join was planned. The order of the join is
indicated by the additional numeric values in the log.
WHY_JOIN(
1)
is the first pairwise join plan, and
WHY_JOIN(
2)
is the second pairwise join plan. It is a good idea
to include the DETAILS="why_join$_what_join$" switch in
your reset command when you create an
N-way
join. It adds helpful information to the SAS log that enables you
to easily determine which tables are involved in each pairwise join
of the
N-way join.
The _method for the
above join is as follows:
SPDS_NOTE: SQL execution methods chosen are:
sqxcrta
sqxjndx(2)
sqxjhsh(1)
sqxsrc ( [X0000010].TABLEB )
sqxsrc ( [X0000010].TABLEC )
sqxsrc ( [X0000010].TABLEA )
The method information
shows that TABLEB and TABLEC will be used by the sqxjhsh (hash join)
method, and the results of the join will be used with TABLEA for the
sqxjndx (index join) method. The numeric in the join method chosen
matches up with the numeric in the why_join$ information. In other
words, the sqxjhsh(1) hash join method was selected as the result
of the WHY_JOIN(1) plan, and the sqxjndx(2) index join method was
selected as a result of the WHY_JOIN(2) plan.