Results 1 to 5 of 5

Thread: Force Index Use

  1. #1
    Join Date
    Jun 2003
    Location
    cape town, south africa
    Posts
    102

    Unanswered: Force Index Use

    Hi

    I have a reporting procedure that fetches a great deal of data
    and is currently taking too long to retrieve the results (40 sec).
    Looking at the execution plan, I see SQL is not using some of the indexes I added especially for the queries benefit (ie.time column), usually it uses the clustered composite PK.
    Does anyone know how I can force SQL to use a particular index on
    a query?

    advice appreciated...

    Thanks
    Desmond

  2. #2
    Join Date
    Jun 2003
    Location
    cape town, south africa
    Posts
    102
    no worries.., got it...(BOL)
    Desmond

  3. #3
    Join Date
    Sep 2003
    Posts
    522
    after table name or table alias in SELECT clause and/or in JOIN clause put (INDEX=index_name)

  4. #4
    Join Date
    Jun 2003
    Location
    cape town, south africa
    Posts
    102
    thanks...still needed the syntax!
    des

  5. #5
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    Originally posted by DesmondX
    thanks...still needed the syntax!
    des
    Check this:

    drop table test13
    go
    create table test13(id int identity primary key, code varchar(10))
    go
    create index i_test13 on test13 (code)
    go
    select * from test13 with(index(i_test13))
    select * from test13 (index=i_test13)

Posting Permissions

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