Query will not use indexes

  • Why will this query not find any indexs?

    select

      (select Points from scoring s1 WHERE s1.userID=s.userid AND s1.weekNum=1),                 

      s.rank

    From scoring s      

    where s.groupid=3392 and s.weeknum=8 and rank>0 and rank<=40 order by rank

    I want the rank column of the returned rows to be from week 8 and the points column to be from week 1.

    This query is not fining any indexes!  Is there a better way to do this?

  • This was removed by the editor as SPAM

  • What indexes are on the table? How many rows? Are you sure statistics are up to date?

  • There could be several different answers to your question. How many rows are in the table? How often is the table updated or new information inserted? What are the current indexes? Have you established a benchmark on the difference between using an index and not using it?

    Quand on parle du loup, on en voit la queue

  • If you have access to BOL (2004) please look for the item FROM and look for the chapter TABLE HINT There you can find your answer ( I hope )

    GKramer

    The Netherlands

  • I've found that if I transfer the passed in parameters to local variables declared in the stored procedure where this query is called, the query does find the indexes on the table. 

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply