Optimization criteria

You can set specific optimization criteria for each session. The optimization criteria represent specific algorithms or relational techniques that may or may not be considered when Adaptive Server creates a query plan. By setting individual optimization criteria on or off, you can fine-tune the query plan for the current session.

NoteEach optimization goal has default settings for each optimization criterion. Resetting optimization criteria may interfere with the default settings of the current optimization goal and produce an error message—although Adaptive Server will honor the new setting. Sybase recommends that you set individual optimization criteria only rarely and with caution if it is necessary to fine-tune a particular query. Overriding optimization goal settings in this way can overly complicate query administration. Always set optimization criteria after setting any existing session level optgoal setting; an explicit optgoal setting could return an optimization criteria to its default value. See “Default optimization criteria” for more information.

Setting optimization criteria

Use the set command to enable or disable individual criteria.

For example, to enable the hash join algorithm, enter:

set hash_join 1

To disable the hash join algorithm, enter:

set hash_join 0

To enable one option and disable another, enter:

set hash_join 1, merge_join 0

Criteria descriptions

Most criteria described here decides whether a particular query engine operator can be used in the final plan chosen by the optimizer. The optimization criteria are:

The query processor will re-enable a default algorithm if all the algorithms of a relational operator are disabled. For example, if all join algorithms (nl_join, m_join, and h_join) are disabled, the query processor will enable nl_join.

The query processor can also re-enable nl_join for semantic reasons: for example, if the joining tables are not connected through equijoins.

Default optimization criteria

Each optimization goal – fastfirstrow, allrows_oltp, allrows_mixed, allrows_dss – has a default setting (on or off) for each optimization criterion. For example, the default setting for merge_join is off for fastfirstrow and allrows_oltp, and on for allrows_mixed and allrows_dss. See Table 5-4 for a list of default settings for each optimization criteria.

Sybase recommends that you reset the optimization goal and evaluate performance before changing optimization criteria. Change optimization criteria only when necessary to fine-tune a particular query.

Table 5-4: Default settings for optimization criteria

Optimization criteria

fastfirstrow

allrows_oltp

allrows_mixed

   allrows_dss

append_union_all

1

1

1

1

bushy_search_space

0

0

0

1

distinct_sorted

1

1

1

1

distinct_sorting

1

1

1

1

group_hashing

1

1

1

1

group_sorted

1

1

1

1

hash_join

0

0

0

1

hash_union_distinct

1

1

1

1

index_intersection

0

0

0

1

merge_join

0

0

1

1

merge_union_all

1

1

1

1

multi_gt_store_ind

0

0

0

1

nl_join

1

1

1

1

opp_distinct_view

1

1

1

1

parallel_query

1

0

1

1

store_index

1

1

1

1