Re: Informix data fragmentation or RAID disk
Posted in 1995
> SELECT * FROM nomaccounts ORDER BY co_code, nom_code;>
>And 'sqexplain.out' should show that the index on co_code, nom_code is
>being used and so far as I have been able to tell (by looking in
>$DBTEMP (we use SE) ) *no* temporary tables etc. are created.
>
>However...
>
> SELECT * FROM nomaccounts WHERE co_code = 1 ORDER BY nom_code>
>fails to use the index! Altering the ORDER BY to match the index solves
>the problem.
Yes, even if some index components are constant you still have to list
them in the order by. One of the most effective ways of speeding SQL
based programs is to generate explain files and *read* them. If you
do a lot of ordering supposedly on indexes you could reduce disk traffic
significantly - and remember that file creation/deletion involves
operations that are done synchronously on many filesystems too.
Mike
--
Here is wisdom. Let him that hath understanding count the number
of the beast: for it is the number of a man; and his number is
Voice: +44 1734 890403 Fax: +44 1734 891192