How to use an index with the clause 'in '.

Hi all

I have a sql statement with "" * in the clause * "."

for example:
select emp_id from emp where ename in ("vikas", "krishna", "John", "scott");
When I check the plan explain he uses the index here even if the statistics was entered. He always goes for the full table scan.
There is an index created for the ename column.

Please tell me a technique on how to make use of the index here.


Thank you and best regards,
Vikas Krishna

Vikas,

What version of Oracle you are running.
CLAUSE IN will use the index as appropriate.
In your example Optimizer may decide to use FTS (Full Tablle Scan) for various reasons. May be that the table is very small.
SE for example below where he uses an index on the CLAUSE IN...
The essential point being that I made "wide enough" table (in this case including a column of type CHAR) makes use of INDEX more effective than a FTS.

select * from v$version where rownum < 2;
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

create table bigt (c int, s char(100));

insert into bigt select level, 'X' from dual connect by level < 501;

create index bigt_in1 on bigt (c );

exec dbms_stats.GATHER_TABLE_STATS('SUDHAKAR', 'BIGT');

explain plan for select c,s from bigt
where c in (1,2,3,43,5);

select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT

Plan hash value: 238667275

-----------------------------------------------------------------------------------------
| Id  | Operation                    | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |          |     5 |   520 |     3   (0)| 00:00:01 |
|   1 |  INLIST ITERATOR             |          |       |       |            |          |
|   2 |   TABLE ACCESS BY INDEX ROWID| BIGT     |     5 |   520 |     3   (0)| 00:00:01 |
|*  3 |    INDEX RANGE SCAN          | BIGT_IN1 |     5 |       |     2   (0)| 00:00:01 |
-----------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - access("C"=1 OR "C"=2 OR "C"=3 OR "C"=5 OR "C"=43)

VR,
Sudhakar B.

Tags: Database

Similar Questions

  • How to use windows scan with the new canon printer is connected and the copy and printing, but can't seem to be able to use the technique of scan windows

    How to use windows scan with my new canon MX 922 printer.  It is conncected and copying and printing but can't seem to use the windows scan option, the cannon that which for me is slow thanks

    All in one, type printers (print, copy, scan) usually have a very specific set of instructions during the installation.  If not followed exactly the probability is that the scanner will not work.

    Canon: http://www.usa.canon.com/cusa/consumer

    Download and read the Setup instructions for your model, have you followed the instructions exactly, more precisely when to connect the printer / scanner during installation of the software process?

    J W Stuart: http://www.pagestart.com

  • How to use module Downloadthemall with the new edition of Firefox?

    I installed the new version of Firefox, but now can't use the Downloadthemall application. Please notify.

    Make sure you have the latest version of installed DownThemAll - https://addons.mozilla.org/firefox/addon/downthemall

    If you have the latest version, which is the real problem you're having with DownThemAll? Are there any error messages?

  • Can we use type multiset and with the clause the two

    Please let me know how to use the multiset type and with the clause.

    You need more inlining, as for example in:

    SQL> select *
    from table (cast (multiset (select *
                                from (with t as (select deptno from dept)
                                      select * from t)) as sys.dbms_debug_vc2coll))
    /
    COLUMN_VALUE
    ----------------------------------------
    10
    20
    30
    40
    50                                      
    
    5 rows selected.
    
  • How it warns Oracle to use an index for the join of two tables...

    How to prevent the Oracle to use an index for the join of two tables to get a view online that is used in an update statement?

    O.K. I think I should explain what I mean:

    When you join two tables that have many entries sometimes there're better is not to use an index on the column that is used as a criterion to join.

    I have two tables: table A and table B.

    Table A has 4,000,000 entries and table B has 700,000 entries.

    I have a join of two tables with a numeric column as join criteria.

    There is an index on this column in A table.

    So I instead of
      where (A.col = B.col)
    I want to use
      where (A.col+0 = B.col)
    in order to avoid Oracle using the index.

    When I use the join in a select query, it works.

    But when I use the join as inline in an update statement I get the error ORA-01779.

    When I remove the '+ 0' the update statement works. (The column is unique in table B).

    Any ideas why this happens?

    Thank you very much in advance for any help.

    Hartmut cordially

    You plan to use a NO_INDEX hint as shown here: http://www.psoug.org/reference/hints.html

  • How to open a file with the extension .odg using Vista?

    How to open a file with the extension .odg using Vista?

    Hi Defiant503,

    Thank you for visiting the forums of answers.microsoft.com.

    I did some research and a file ending with .odg is an OpenDocument Document OpenOffice/StarOffice (Ver 2) of graphics by Sun Microsystems, Inc.    This means that in order to open this file, you will need this program to open it.  You will not be able to open this file with Vista.

    I hope this information helps.

    Kavita M
    Microsoft Answers Support Engineer
    Visit the Microsoft Answers Feedback Forum site
    and let us know what you think.

  • WITH the clause can be used with an insert statement?

    Hello

    Can I use a SQL with a clause of an insert

    Something like
    create table tem (l number)
    
    insert into tem
    (l)
    (with 
      t0  as 
      (Select exp_amt as t0 from exp_main)
    select t0 from t0)
    The declaration itself works fine, but it throws the following error with insert
    Error at Command Line:8 Column:17
    Error report:
    SQL Error: ORA-32034: unsupported use of WITH clause
    32034. 00000 -  "unsupported use of WITH clause"
    *Cause:    Inproper use of WITH clause because one of the following two reasons
               1. nesting of WITH clause within WITH clause not supported yet
               2. For a set query, WITH clause can't be specified for a branch.
               3. WITH clause can't sepecified within parentheses.
    *Action:   correct query and retry
    The reason why I use this format is because we strive to produce sqls to Analytics and queries are generally formed like this. So instead of change requests in bulk, I was hoping that we were able to insert it.

    Please notify

    Thank you
    Sun

    Published by: ryansun on August 14, 2012 01:59

    >
    create table tem (general number);
    table created TEM.

    insert into tem (l)
    with t0
    as
    (Select 1 as double t0)
    Select t0 t0;

    1 inserted rows.

  • How can I restart firefox with the same tabs and windows?

    How can I restart firefox with the same tabs and windows?

    It is not in the file menu or tools. I get nothing when searching for help. FF still knows how to do it, say to update extensions.

    I know that I can do by saving my session, coming out, reboot and restore the session but is there a single command to do this?

    Thank you. -David

    I have attached a screenshot showing how to select restore automatic session just above the setting of the Home Page where it says "When Firefox starts".

    With this set, you can restart Firefox manually out using the menu-

    • "3-bar" menu button > button "power".
    • (menu bar) File > Exit

    -and then restart Firefox.

    If you want a real reboot with a click of button, you can check something on the Add-ons site: https://addons.mozilla.org/firefox/

  • How can I sync lightning with the iphone calendar?

    How can I sync lightning with the iphone calendar? I saw online that I need to use a google calendar? I added google calendar as they described, but I have no idea where from here

    To synchronize with the iPhone (also known as iCalendar) schedule you must use a calendar based on a cloud. If you already have the lightning, install the addon Google provider and Setup Google Calendar. If you have already done so, go to settings on your iPhone. In the e-mail box, Contacts and calendars, add your Google account and turn on the calendar. This will synchronize your Google Calendar with the iPhone.

  • How to use spell checking with magic mouse

    How to use spell checking with magic mouse

    Hello

    The mouse is not intended to be used with the spell checker.

    The mouse settings available in system preferences > mouse

    Spelling and grammar can be checked in the Edit menu in most applications.

    In addition, shortcuts keyboard.

    Command:

    And the command;

  • How to remove a shortcut with the command line?

    How to remove a shortcut with the command line?

    How to make a backup of the local users and groups with command line?

    You delete a shortcut, just as you would remove any other file.  A shortcut will end with the extension ".lnk".  So assuming you are trying to remove the shortcut named "Shortcut.lnk" which appears to the user 'Bob's Office, you use the button Delete (del) or 'clear' command by specifying the full path to the file.  (Remember to put filename in quotes if there is a space anywhere in the path or name) as in:

    del "C:\documents and settings\Bob\Desktop\Shortcut.lnk".

    What kind of a backup 'users and groups' you want to do?  If there is a backup of the users and groups as written in the registry, a good registry as C:\WINDOWS\ERUNT backup program that will make the command line.  If you are trying to backup all users and their data as well, then you are better off with a backup program.

    HTH,
    JW

  • How a microwave oven interferes with the WIFI signal?

    MICRO-WIFI INTERFERENCE

    Please explain THAT HOW A MICROWAVE actually INTERFERES with the laptop WIFI signal...  How to turn off the oven microwave takes the PC adapter, for example?  When the microwave oven is off and don't use it, should also be disconnected? In the equipped cafes in WIFI, are microwave ovens, degrading the quality of the signal?

    I thank very you much for your comments.
    Joe

    This is caused by the fact that both microwave and most wifi routers operate at a frequency of 2.4 Ghz, there is a setting on some wifi routers that allow you to operate at 5 GHz, but this frequency moves not by walls well, insofar as they interfere, the microwave should not disseminate its frequency outside the oven microwave and most of the routers wifi broadcast in all the directions, radio waves can bounce off the walls and envelope the room and other areas as well, this isn't a line of site, so unless you have your computer very close to the microwave you should not receive any interference at all. or course, if you stick the router inside the microwave.

    Hope this helps,
    -Ray
  • I had CS5 on a computer that has crashed with WIndows 7. How to restore my CS5 with the backup files?

    I had CS5 on a computer that has crashed with WIndows 7. How to restore my CS5 with the backup files?

    Available downloadable Setup files:

    Download and installation help links Adobe

    Help download and installation to Prodesigntools links can be found on the most linked pages.  They are essential; especially steps 1, 2 and 3.  If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions".

  • How to use JavaScript to limit the number of boxes to check the user can select a PDF form?

    How to use JavaScript to limit the number of boxes to check the user can select a PDF form?

    Here's the working solution

    Please rename all the boxes like chkBox0, chkBox1... .chkBox30 (must start with 0)

    Value of exports of each checkbox must be "Yes" (default value is Yes)

    Place this Code at the level of the Javascript Document

    -Code JavaScript document-

    var counter = 0;                Checked the meter

    -Count boxes checked again when the document is closed and reopened.

    for (var i = 0; i)<= 30;="">

    If (getField("chkBox"_+_i).value == 'Yes') {}

    Counter += 1;

    }

    }

    -The function of validation-

    function validateCheckBox(name,value) {}

    If (value == 'Yes' & meter)<>

    Counter += 1;

    } else if (value == 'Off') {}

    counter = 1;

    } else {}

    getField ("name") .value = "Off";

    App.Alert ("you can select only four checkboxes");

    }

    }

    -End of Document Javascript-

    Now put this line in the MouseUp event all checkboxes

    Box - Code MouseUp event.

    validateCheckBox (event.target.name, event.target.value);

    //----------------------------------------------------------------------------------

    Hope this will help

    Kind regards

    Post edited by: Mohammad Irfan

  • How to remove a step with the polygon Lasso tool

    How to remove a step with the polygon Lasso tool

    In PS, all you have to do is to hit the DELETE key and you can go back a little with the polygon Lasso tool. How to accomplish this in Fireworks?

    Another option that gives you a lot of control is to use the tool pen instead of the polygon lasso. Because it's a vector path, you can refine the outline very easily using the tools of feather and Subselects and when you are satisfied with the result, click on modify > convert a path to the top. You can even choose to keep or delete the vector path in the preferences panel.

    HTH

Maybe you are looking for