Download Performance Guide for Informix Dynamic Server, Version 7.3

Transcript
Join Order
Join Order
The order that tables are joined in a query is extremely important. A poor join
order can cause query performance to decline noticeably.
The following SELECT statement calls for a three-way join:
SELECT C.customer_num, O.order_num
FROM customer C, orders O, items I
WHERE C.customer_num = O.customer_num
AND O.order_num = I.order_num
The optimizer can choose one of the following join orders:
■
Join customer to orders. Join the result to items.
■
Join orders to customer. Join the result to items.
■
Join customer to items. Join the result to orders.
■
Join items to customer. Join the result to orders.
■
Join orders to items. Join the result to customer.
■
Join items to orders. Join the result to customer.
For an example of how the database server executes a plan according to a
specific join order, refer to “An Example of How Query Plans Are Executed”
on page 7-10.
How OPTCOMPIND Affects the Query Plan
The OPTCOMPIND setting influences the access plan that the optimizer
chooses for single and multitable queries, as the following sections describe.
Single Table Query
For single-table scans, when OPTCOMPIND is set to 0, or when OPTCOMPIND
is set to 1 and the current transaction isolation level is Repeatable Read, the
optimizer considers the following access plans:
■
If an index is available, the optimizer uses it to access the table.
■
If no index is available, the optimizer considers scanning the table in
physical order.
Queries and the Query Optimizer 7-7