Foxhound is the better* Database Monitor for SQL Anywhere.
*better: More thorough, more relevant, more effective.
...more Alerts, more All Clears, more details, more control in your hands.
|
[Home] | [Table of Contents] | [Previous Section] | [Next Section] |
Breck Carter
Last modified: February 12, 1998
mail to: bcarter@bcarter.com
An index will help optimize an ORDER BY clause if it is sorted in the same or exactly opposite direction as the ORDER BY clause. For a single-column index and ORDER BY clause this boils down to a simpler rule: it doesn't matter whether you use ASC or DESC when defining the index. Either choice will make the ORDER BY run faster.
It gets a bit more complicated for multi-column indexes and ORDER BY clauses. Figure 14 shows that an ASC index on two columns helps speed up queries that specify the same value of ASC or DESC for both columns, but not if the ORDER BY says ASC for one column and DESC for the other.
Figure 14 - Multi-Column Index And ORDER BY
|
If the ORDER BY says ASC for one column and DESC for the other, then the index must say the same thing for it to be useful. It doesn't matter which column gets the ASC and which gets the DESC, what matters is that the index as a whole must be sorted in the same or exactly opposite direction as the ORDER BY clause.
[Home] | [Table of Contents] | [Previous Section] | [Next Section] |