# Changing plans (hint hint)

- ## Most database systems provide a way to influence the execution plan

  - typically via ‘hints’

- ## Oracle supports a very large and complex range of hints

  - Hints must be contained within special comments /*+ … */
  - SELECT /*+ INDEX(table1 index1) */ foo, bar
    FROM table1 WHERE key1=1 AND key2=2 AND key3=3;

- ## MySQL has a very limited set of hints

  - Hints can optionally be placed inside comments /*! … */
  - SELECT foo, bar FROM table1 /*! USE INDEX (key1,key2) */
    WHERE key1=1 AND key2=2 AND key3=3;

- ## Use sparingly! Generally as a last resort.

  - A hint may help now but later schema (or data) changes may make it worse.
  - Usually best to let the optimizer do its job

## .

Previous slide | Next slide | Back to first slide | View graphic version