Oracle 5.0 Reference Manual page 703

Table of Contents

Advertisement

and converts it to this expression:
EXISTS (SELECT 1 FROM ... WHERE
)
Each
is a special function that evaluates to the following values:
trigcond(X)
when the "linked" outer expression
X
when the "linked" outer expression
TRUE
Note that trigger functions are not triggers of the kind that you create with
Equalities that are wrapped into
optimizer. Most optimizations cannot deal with predicates that may be turned on and off at query
execution time, so they assume any
moment, triggered equalities can be used by those optimizations:
• Reference optimizations:
[646],
[646], or
ref
eq_ref
• Index lookup-based subquery execution engines:
unique_subquery
• Table-condition generator: If the subquery is a join of several tables, the triggered condition will be
checked as soon as possible.
When the optimizer uses a triggered condition to create some kind of index lookup-based access
(as for the first two items of the preceding list), it must have a fallback strategy for the case when the
condition is turned off. This fallback strategy is always the same: Do a full table scan. In
output, the fallback shows up as
mysql>
EXPLAIN SELECT t1.col1,
->
t1.col1 IN (SELECT t2.key1 FROM t2 WHERE t2.col2=t1.col2) FROM t1\G
*************************** 1. row ***************************
id: 1
select_type: PRIMARY
table: t1
...
*************************** 2. row ***************************
id: 2
select_type: DEPENDENT SUBQUERY
table: t2
type: index_subquery
possible_keys: key1
key: key1
key_len: 5
ref: func
rows: 2
Extra: Using where; Full scan on NULL key
If you run
EXPLAIN EXTENDED
*************************** 1. row ***************************
Level: Note
Code: 1003
Message: select `test`.`t1`.`col1` AS `col1`,
<in_optimizer>(`test`.`t1`.`col1`,
<exists>(<index_lookup>(<cache>(`test`.`t1`.`col1`) in t2
on key1 checking NULL
where (`test`.`t2`.`col2` = `test`.`t1`.`col2`) having
trigcond(<is_not_null_test>(`test`.`t2`.`key1`))))) AS
`t1.col1 IN (select t2.key1 from t2 where t2.col2=t1.col2)`
from `test`.`t1`
Optimizing
SELECT
subquery_where
AND trigcond(oe_1=ie_1)
AND ...
AND trigcond(oe_N=ie_N)
is not
oe_i
oe_i
trigcond()
trigcond(X)
trigcond(X=Y [OR Y IS NULL])
ref_or_null
[647]
or
index_subquery
Full scan on NULL key
followed by
SHOW
683
Statements
NULL
is
NULL
functions are not first class predicates for the query
to be an unknown function and ignore it. At the
can be used to construct
[647]
table accesses.
trigcond(X=Y)
[647]
accesses.
in the
Extra
WARNINGS, you can see the triggered condition:
CREATE
TRIGGER.
can be used to construct
EXPLAIN
column:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents