Oracle 5.0 Reference Manual page 1721

Table of Contents

Advertisement

For MERGE, the text of a statement that refers to the view and the view definition are merged such that
parts of the view definition replace corresponding parts of the statement.
For TEMPTABLE, the results from the view are retrieved into a temporary table, which then is used to
execute the statement.
For UNDEFINED, MySQL chooses which algorithm to use. It prefers
possible, because
MERGE
temporary table is used.
A reason to choose
TEMPTABLE
temporary table has been created and before it is used to finish processing the statement. This might
result in quicker lock release than the
blocked as long.
A view algorithm can be
• No
clause is present in the
ALGORITHM
• The
statement has an explicit
CREATE VIEW
ALGORITHM = MERGE
this case, MySQL generates a warning and sets the algorithm to UNDEFINED.
As mentioned earlier,
MERGE
statement that refers to the view. The following examples briefly illustrate how the
works. The examples assume that there is a view
CREATE ALGORITHM = MERGE VIEW v_merge (vc1, vc2) AS
SELECT c1, c2 FROM t WHERE c3 > 100;
Example 1: Suppose that we issue this statement:
SELECT * FROM v_merge;
MySQL handles the statement as follows:
becomes
v_merge
t
becomes
vc2, which corresponds to
*
vc1,
• The view
clause is added
WHERE
The resulting statement to be executed becomes:
SELECT c1, c2 FROM t WHERE c3 > 100;
Example 2: Suppose that we issue this statement:
SELECT * FROM v_merge WHERE vc1 < 100;
This statement is handled similarly to the previous one, except that
and the view
< 100
WHERE
connective (and parentheses are added to make sure the parts of the clause are executed with correct
precedence). The resulting statement to be executed becomes:
SELECT c1, c2 FROM t WHERE (c3 > 100) AND (c1 < 100);
Effectively, the statement to be executed has a
WHERE (select WHERE) AND (view WHERE)
If the
algorithm cannot be used, a temporary table must be used instead.
MERGE
used if the view contains any of the following constructs:
• Aggregate functions
View Processing Algorithms
is usually more efficient and because a view cannot be updatable if a
explicitly is that locks can be released on underlying tables after the
algorithm so that other clients that use the view are not
MERGE
for three reasons:
UNDEFINED
CREATE VIEW
is specified for a view that can be processed only with a temporary table. In
is handled by merging corresponding parts of a view definition into the
clause is added to the statement
(SUM()
[972],
[971],
MIN()
1701
MERGE
statement.
ALGORITHM = UNDEFINED
that has this definition:
v_merge
c1, c2
vc1 < 100
clause using an
WHERE
clause of this form:
WHERE
[971],
MAX()
COUNT()
over
if
TEMPTABLE
clause.
algorithm
MERGE
becomes
c1
[880]
AND
cannot be
MERGE
[970], and so forth)

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents