Results 1 to 3 of 3

Thread: Index usage

  1. #1
    Join Date
    Dec 2003

    Unanswered: Index usage

    In a query which returns detail information, if a field included in the ORDER BY clause is indexed, is that index ever used:

    select ...
    from ...
    order by <indexed field>

    How about a query with a GROUP BY and/or an ORDER BY? Would an index included in either clause speed up the return of the resultset?

    select <indexed field>, count(*)
    from ...
    group by <indexed field>
    order by <indexed field>

    I'm trying to set aside some rules for Developers, so that resultsets are returned in the minimum amount of time, and there's been some confusion lately as to whether indexed fields in the above situations are used to enhance performance.


  2. #2
    Join Date
    Aug 2004
    If the indexed field is the first or only field in the ORDER BY clause, then the optimizer will usually use the index to sort it. There may be some exceptions for special situations (especially if you have JOINs or sub-queries), but normally it will. It's a good idea to always have an index for any field(s) you are going to use in an ORDER BY.

  3. #3
    Join Date
    Jan 2004
    Yes. Index will also help to save disk IO.
    When the columns indexed are included in group clause,Sybase will execute nomathing scan.With index(clustered and noclustered),sybase will scan all leaf level of index,rather than scanning table.
    Last edited by enhydraboy; 08-18-04 at 21:30.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts