Oracle 5.0 Reference Manual page 704

Table of Contents

Advertisement

The use of triggered conditions has some performance implications. A
expression now may cause a full table scan (which is slow) when it previously did not. This is the price
paid for correct results (the goal of the trigger-condition strategy was to improve compliance and not
speed).
For multiple-table subqueries, execution of
the join optimizer doesn't optimize for the case where the outer expression is NULL. It assumes that
subquery evaluations with
otherwise. On the other hand, if the outer expression might be
performance penalty.
To help the query optimizer better execute your queries, use these tips:
• A column must be declared as
optimizer.)
• If you don't need to distinguish a
execution path. Replace a comparison that looks like this:
outer_expr
with this expression:
(outer_expr
Then
NULL IN (SELECT ...)
[880]
AND
8.3.1.15.
Optimization
LIMIT
In some cases, MySQL handles a query differently when you are using
using HAVING:
• If you are selecting only a few rows with LIMIT, MySQL uses indexes in some cases when normally
it would prefer to do a full table scan.
• If you use
first
row_count
using an index, this is very fast. If a filesort must be done, all rows that match the query without the
clause must be selected, and most or all of them must be sorted, before it can be ascertained
LIMIT
that the first
found, there is no need to sort any remainder of the result set, and MySQL does not do so.
• When combining
unique rows.
• In some cases, a
and then calculating summaries until the key value changes. In this case,
not calculate any unnecessary
• As soon as MySQL has sent the required number of rows to the client, it aborts the query unless you
are using SQL_CALC_FOUND_ROWS.
LIMIT 0
using one of the MySQL APIs, it can also be employed for obtaining the types of the result columns.
(This trick does not work in the MySQL Monitor (the
in such cases; you should instead use
set
• When the server uses temporary tables to resolve the query, it uses the
to calculate how much space is required.
8.3.1.16. How to Avoid Table Scans
Optimizing
on the left side are very rare, even if there are statistics that indicate
NULL
NOT NULL
IN (SELECT
inner_expr
IS NOT NULL) AND
(outer_expr
parts as soon as the expression result is clear.
with
LIMIT row_count
rows of the sorted result, rather than sorting the entire result. If ordering is done by
rows have been found. In either case, after the initial rows have been
row_count
LIMIT row_count
can be resolved by reading the key in order (or doing a sort on the key)
GROUP BY
GROUP BY
quickly returns an empty set. This can be useful for checking the validity of a query. When
Statements
SELECT
NULL IN (SELECT ...)
if it really is. (This also helps other aspects of the
from
subquery result, you can easily avoid the slow
NULL
FALSE
FROM ...)
IN (SELECT
will never be evaluated because MySQL stops evaluating
BY, MySQL ends the sorting as soon as it has found the
ORDER
with DISTINCT, MySQL stops as soon as it finds
values.
mysql
SHOW COLUMNS
684
NULL IN (SELECT ...)
will be particularly slow because
but never actually is, there is no
NULL
inner_expr
FROM ...))
LIMIT row_count
LIMIT row_count
program), which merely displays
or
for this purpose.)
DESCRIBE
LIMIT row_count
and not
row_count
does
Empty
clause

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents