This is an old revision of the document!


Administration: Indexing Strategies

Basic Strategies

Optimizing Ordering

Ordering is usually optimized by creating an index containing all of the columns in the ORDER BY clause. The order of the column in the index must match the order of the columns in the ORDER BY clause. At present, only ascending ORDER BY clauses are optimized.

Example 1. Single-column ORDER BY clauses

In this example, the ORDER BY clause is optimized using the same index used for processing criteria.

select     NAME, ADDRESS1, ADDRESS2, PHONE 
  from     INDIVIDUALS
  where    STATE in ('CA','CO') and NAME = 'John'
  order by STATE

The STATE index will be used to satisfy both the criteria and the ORDER BY clause.

Example 2. Multi-column ORDER BY clauses

In this example, the ORDER BY clause will be optimized with a multi-column index.

select     NAME, ADDRESS1, ADDRESS2, PHONE 
  from     INDIVIDUALS
  where    STATE in ('CA','CO') and NAME = 'John'
  order by STATE, CITY

A multi-column Omnidex index containing STATE and CITY, in that order, will optimize this ORDER BY clause.

Additional Resources

See also:

 
Back to top
admin/indexing/basicstrategies/orderby.1294958789.txt.gz ยท Last modified: 2012/10/26 14:52 (external edit)