Re: force a query to an index

From: Tony <andrewst_at_onetel.net.uk>
Date: 14 Mar 2003 07:13:06 -0800
Message-ID: <c0e3f26e.0303140713.1e2d9379_at_posting.google.com>


Miko_at_boehrer.de (Ralf) wrote in message news:<fa624200.0303130434.1a750860_at_posting.google.com>...
> Hi,
>
> I want to use an index-hint within a select-statement.
> But it doesn't work.
> Can you please tell me what I did wrong ?
>
> I have a table (field: "Id" and "Nr").
> I have 2 indexes "ind_Nr" and "ind_Id" and did the following statement:
>
> select /*+ index (ind_Nr) */
> id,Nr
> from table
> where Nr > 4711
> and Rownum < 3;

Your hint syntax is wrong. It should be:

select /*+ index (table ind_Nr) */

   id,Nr
 from table
 where Nr > 4711
 and Rownum < 3;

Of course, it is still only a hint, not guaranteed to work, and therefore you should put in the ORDER BY clause also. Received on Fri Mar 14 2003 - 16:13:06 CET

Original text of this message