Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8391427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:15:30+00:00 2026-06-09T19:15:30+00:00

In a table in our Oracle installation we have a table with an index

  • 0

In a table in our Oracle installation we have a table with an index on two of the columns (X and Y). If I do a query on the table with a where clause only touching column X, will Oracle be able to use the index?

For example:

Table Y:
Col_A,
Col_B,
Col_C,

Index exists on (Col_A, Col_B)

SELECT * FROM Table_Y WHERE Col_A = 'STACKOVERFLOW';

Will the index be used, or will a table scan be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:15:32+00:00Added an answer on June 9, 2026 at 7:15 pm

    It depends.

    You could check it by letting Oracle explain the execution plan:

    EXPLAIN PLAN FOR 
       SELECT * FROM Table_Y WHERE Col_A = 'STACKOVERFLOW';
    

    and then

    select * from table(dbms_xplan.display);
    

    So, for example with

    create table table_y (
      col_a varchar2(30),
      col_b varchar2(30),
      col_c varchar2(30)
    );
    
    create unique index table_y_ix on table_y (col_a, col_b);
    

    and then a

    explain plan for
      select * from table_y
      where col_a = 'STACKOVERFLOW';
    
    select * from table(dbms_xplan.display);
    

    The plan (on my installation) looks like:

    ------------------------------------------------------------------------------------------
    | Id  | Operation                   | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |            |     1 |    51 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| TABLE_Y    |     1 |    51 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | TABLE_Y_IX |     1 |       |     1   (0)| 00:00:01 |
    ------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access("COL_A"='STACKOVERFLOW')
    

    ID 2 shows you, that the index TABLE_Y_IX is indeed used for an index range scan.

    If on another installation Oracle chooses to use the index is dependend on many things. It’s Oracle’s query optimizer that makes this decision.

    Update If you feel you’re be better off (performance wise, that is) if Oracle used the index, you might want to try the + index_asc(...) (see index hint)

    So in your case that would be something like

    SELECT /*+ index_asc(TABLE_Y TABLE_Y_IX) */ * 
      FROM Table_Y 
     WHERE Col_A = 'STACKOVERFLOW';
    

    Additionally, I would ensure that you have gathered statistics on the table and its columns. You can check the date of the last gathering of statistics with a

    select last_analyzed from dba_tables where table_name = 'TABLE_Y';
    

    and

    select column_name, last_analyzed from dba_tab_columns where table_name = 'TABLE_Y';
    

    If there are no statistics or if they’re stale, make yourself familiar with the dbms_stats package to gather such statistics.

    These statistics are the data that the query optimizer relies on heavily to make its decisions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our Oracle database, I have a table (say MYTABLE) with column VALUE_NUMBER of
In our Oracle database we have a table called RULES, with a field called
I have an Oracle (10.2.0.4) database table with a column which is encrypted by
In iOS apps, we have to register nib files with our table view before
We have a table that is used for assessment-values in our tool where each
I have a table containing data about some users. Many of them use our
I have a large (multi-GB) data file exported from an Oracle table. I want
In our application, we have two sets of tables: One set of working tables
Is there any way to move an column in an Oracle table from last
I am using Oracle 10g Enterprise edition. A table in our Oracle database stores

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.