Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Posts
    37

    Unanswered: Short question about creating indexes

    Hi,

    I'm a little confused whether I need or don't need to create an index and need your advice.

    The situation is as follows :

    Orders :
    -----------
    ID
    DepartmentID
    DateOfOrder
    Price

    Now, I have a web page which lists the orders of the department of the logged-in user.
    That's why this table already has an index like this :

    Index1 :
    ------------
    DepartmentID
    DateOfOrder

    But now, our customer wants a report, where I have to go the other way, list the total price at one day, as in :

    select count(*) from orders where creation = <today> group by DepartmentID

    should I crate an index like :
    Index2 :
    ----------
    DateOfOrder
    DepartmentID

    or would Oracle be clever enough to use Index 1 ?
    (I personally think, this doesn't have anything to do with the capability of Oracle, but rather with the understanding of indexes, but I'm not sure).

    Do I have to create Index 2 ?

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by msegmx View Post
    or would Oracle be clever enough to use Index 1
    Run EXPLAIN PLAN and you will know.

  3. #3
    Join Date
    Oct 2002
    Posts
    37

    Cool

    Thanks for the tip, that helped !!

Posting Permissions

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