Home | Previous Page | Next Page   SQL Statements > SET OPTIMIZATION >

Examples

The following example shows optimization across a network. The central database (on the midstate database server) is to have LOW optimization; the western database (on the rockies database server) is to have HIGH optimization.

CONNECT TO 'central@midstate';
SET OPTIMIZATION LOW;
SELECT * FROM customer;
CLOSE DATABASE;
CONNECT TO 'western@rockies';
SET OPTIMIZATION HIGH;
SELECT * FROM customer;
CLOSE DATABASE;
CONNECT TO 'wyoming@rockies';
SELECT * FROM customer;

The wyoming database is to have HIGH optimization because it resides on the same database server as the western database. The code does not need to re-specify the optimization level for the wyoming database because the wyoming database resides on the rockies database server like the western database.

The following example directs the Dynamic Server optimizer to use the most time to determine a query plan, and to then return the first rows of the result as soon as possible:

SET OPTIMIZATION LOW;
SET OPTIMIZATION FIRST_ROWS;
SELECT lname, fname, bonus
FROM sales_emp, sales
WHERE sales.empid = sales_emp.empid AND bonus > 5,000
ORDER BY bonus DESC

Related Information

Related statements: SET EXPLAIN, SET ENVIRONMENT , and UPDATE STATISTICS

For information on other methods by which you can alter the query plan of the Dynamic Server optimizer, see Optimizer Directives.

For more information on how to optimize queries, see your IBM Informix Performance Guide.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]