# The best laid plans

- ## Query optimisation is hard

  - Intelligent high quality cost based query optimisation is really hard!

- ## Know your optimiser

  - Oracle, Informix, Sybase, DB2, SQL Server etc. all slightly different.

- ## Check what it's doing

  - Use tools to see the plans used for your queries - very helpful

- ## Help it along

  - Most 'big name' databases have a mechanism to analyse and store the key distributions of indices to help the optimiser make good plans.
    - Important for tables with ‘skewed’ (uneven) key distributions
    - Beware: keep it fresh, old key distributions might be worse than none
  - Some also allow you to embed 'hints' into the SQL as comments
    - Beware: take it easy, over hinting hinders dynamic optimisation

## .

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