Selecting all columns makes oracle use more indexes than only selectng one?

I have 3 queries here that differ only slightly, conceptually, but the plans are massively different. What I cant work out is that the difference is only in the select list.. The fields referenced in the where clause are properly indexed for this purpose
SELECT
  scc.expiry_date
FROM
  bw3.int_file_log_details  ifld
  INNER JOIN
  bw3.svc_card_status_change scsc
  USING
    (institution_number, file_number)
  INNER JOIN bw3.svc_client_cards scc
  USING
    (card_number)
WHERE
  institution_number = '00000001' AND
  file_number = '00002504'This one above does a full table scan of SCC, over 3.5 million records
SELECT
  card_number
FROM
  bw3.int_file_log_details  ifld
  INNER JOIN
  bw3.svc_card_status_change scsc
  USING
    (institution_number, file_number)
  INNER JOIN bw3.svc_client_cards scc
  USING
    (card_number)
WHERE
  institution_number = '00000001' AND
  file_number = '00002504'This one above does an index fast full scan of SCC's pk (which is cardnumber), as does doing a "SELECT null as dummy FROM..."
SELECT
FROM
  bw3.int_file_log_details  ifld
  INNER JOIN
  bw3.svc_card_status_change scsc
  USING
    (institution_number, file_number)
  INNER JOIN bw3.svc_client_cards scc
  USING
    (card_number)
WHERE
  institution_number = '00000001' AND
  file_number = '00002504'This one above does the index range scan of the columns mentioned in the where clause and two index unique scans to link in IFLD and SCC (because they are joined on their PKs)
I would expect all queries to run this way and completes in ~0.01 seconds
Now, I get that oracle will sometimes use only an index instead of a table access when the requested data can be got from the index, but the actual query is pulling data from some columns not in indexes, so must be accessed in the table:
SELECT
  scsc.card_prod_data as "Field1",
  substr(card_number,1,4)||' '||
    substr(card_number,5,4)||' '||
    substr(card_number,9,4)||' '||
    substr(card_number,13,4)||' '||
    substr(card_number,17) as "Field2",
  '                           ' as "Field3",
  scc.emboss_line_1 as "Field4",
  scc.emboss_line_2 as "Field5",
  TO_CHAR(TO_DATE(scc.last_issued_date, 'YYYYMMDD'), 'MM/YY ')||
    TO_CHAR(TO_DATE(scc.expiry_date, 'YYYYMMDD'), 'MM/YY  ')||
    '    ' as "Field6",
  'B'||
    card_number||
    '^'||
    RPAD('0', 27, ' ')||
    '^'||
    to_char(to_date(scc.expiry_date, 'YYYYMMDD'), 'YYMM')||
    service_category_code||
    '000000000000' as "Field7",
  card_number||
    '='||
    to_char(to_date(scc.expiry_date, 'YYYYMMDD'), 'YYMM')||
    service_category_code||
    '000000000000' as "Field8",
  card_number as "Field9",
  scsc.cvv_cvc2 as "Field10"
FROM
  bw3.int_file_log_details  ifld
  INNER JOIN
  bw3.svc_card_status_change scsc
  USING
    (institution_number, file_number)
  INNER JOIN bw3.svc_client_cards scc
  USING
    (card_number)
WHERE
  institution_number = '00000001' AND
  file_number = '00002504'This query above, which uses some data from all tables, does a table full scan of SCC, yet if I SELECT * FROM.. I get the expected index usage and table access by index rowid for all tables..
Why is oracle doing an FTS when I choose only some columns, yet doing index access when I select * ?
Edited by: charred on Oct 5, 2010 11:37 AM

Selectivity of indexes?
For a query linking these tables:
int_file_log_details <-> svc_card_status_change <-> svc_client_cards
I'm expecting Oracle to:
Use an index range scan of the index on svc_card_status_change that is a nonunique index of institution_number and file number. Selectivity of this index is:
1 institution number in the entire table
59 distinct file numbers in the entire table
4.1million records in the entire table
From there, with the records it found, to use index unique scan of the PKs of int_file_log_details (file_number: 1 record required) and PK of svc_client_cards (card_number: poetntially thousands of records required)
I can understand if oracle might decide it can get 69k records out of 4.1 million faster by FTS the cards table rather than having the indirection of the index... what I cannot understand is:
If I select all the data from the query (SELECT *) it does unique index scans for the 2 records
If I select say, only one non-indexed non-joined column from each table, oracle prefers a FTS of the cards table..
Is oracle not realising that there are only 2 records I need out of cards? Why would select * differ? Is it that oracle thinks "select * is a large amount of data, so it'll be faster to use the index and target certain rows" vs "select one_column can be garnered more quickly by scanning the table and generating a lower overall memory load" ?

Similar Messages

  • Can oracle use more memory than pga+sga

    Hi Experts,
    If I have set pga 1GB and SGA 2GB then Could oracle use more than 3GB RAM from OS.
    Thanks,
    Please Ignore if seems to be very basic question..

    Yes.
    The PGA_AGGREGATE_TARGET is only a target. On a busy system, a system with frequently changing SQL patterns , Oracle may sometimes attempt to allocate a higher value.
    I presume that you are on 32-bit Windows. You will hit ORA-4030 errors occassionally because Oracle on Windows is a single process (multi-threaded) and Windows limits the memory the process can address.
    I suggest that you reduce your P_A_T.
    Hemant K Chitale

  • How to select all columns in a trigger?

    I add a "before delete" trigger on a table, in order to insert the records to a backup table before they are deleted.
    but I cannot write like this : insert into t_backup select * from :old;
    The table has more than 30 columns so I don't want to select them one by one, how can I select all columns?

    Yes, it is possible by writing something like this :
    where col1 = :old.col1; But it is not directly supported. First, we need a package to remember all the OLD records:.... and please see below link for complete code in action :
    http://www.dbforums.com/oracle/925729-trigger-back-up-data.html
    What I am doing here, just copying the code and replacing "emp" with "test" (The table name on which I am going to apply this using notepad find and replace):
    SQL> select * from test_backup;
    no rows selected
    SQL> select * from test;
             A
             1
             2
             4
             5
    SQL> select * from test_backup;
    no rows selected
    SQL>
    create or replace package test_trg_pkg as
      type test_type is table of test%ROWTYPE index by binary_integer;
      test_tab test_type;
    end;
    create or replace trigger test_bds before delete on test
    begin
      test_trg_pkg.test_tab.delete;
    end;
    create or replace trigger test_adr after delete on test
    for each row
    declare
      -- To allow us to select the old values
      pragma autonomous_transaction;
    begin
      select *
      into   test_trg_pkg.test_tab(test_trg_pkg.test_tab.COUNT+1)
      from   test
      where  a = :old.a;  <----- Here you have to give your column name.
    end;
    create or replace trigger test_ads after delete on test
    begin
      for i in 1..test_trg_pkg.test_tab.COUNT loop
        insert into test_backup values test_trg_pkg.test_tab(i);
      end loop;
    end;
    SQL> delete from test where a=1;
    1 row deleted.
    SQL> select * from test_backup;
             A
             1
    SQL> delete from test where a=2;
    1 row deleted.
    SQL> select * from test_backup;
             A
             1
             2
    SQL>Regards
    Girish Sharma

  • What is the difference betwwen SELECT ALL Column and Select Speceific Colum

    Hi All,
    If the block size of the database is 8K and average row length is 2K and if we select all column of the table the I/O show that it had read more blocks then compare to
    specific column of the same table. Why is this?
    Secondly if Oracle brings a complete block is the db buffer cache, while reading block from disk, they why there is a difference of block count in two queries.
    This difference reveals to me when I check the EXPLAIN PLAN for two different queries against the same table but one select all columns and the other one select specific column.
    Kindly help me in clearing this confusion.
    Regards,
    Kamran

    user1514587 wrote:
    >
    Usually, indexes are smaller (contain fewer blocks) than the table - ergo, select empno from emp could be satisfied by reading fewer blocks.
    what if there is a composite Index on a table containing 3 to 4 columns and the size of table is in 100 of GB and Index size itself is vey large then I think Oracle will go for FTS and small Index scan will be expensive. Kindly Share your thoughts.
    Regards,
    KamranHandle:     user1514587
    Status Level:     Newbie (5)
    Registered:     May 9, 2011
    Total Posts:     21
    Total Questions:     13 (12 unresolved)
    I think you wastes everyone's time here since you rarely get answer to any posted question

  • I used to give my photo's keywords. Most of the time I have several photo's for the same keyword and it was possible to select all those photo's and give them the keyword in one move. Since of few weeks I can't do that anymore and I find it very annoying.

    I used to give my photo's keywords. Most of the time I have several photo's for the same keyword and it was possible to select all those photo's and give them the keyword in one move. Since of few weeks I can't do that anymore and it's very annoying. What can I do to get back to the former situation?

    . Since of few weeks I can't do that anymore and it's very annoying. What can I do to get back to the former situation?
    Check, if you have the "Primary Only" option enabled. Then keywords will only be applied to the "Primary Image":
    See:                  Keywords or ratings are applied only to one of the selected images - why?
    Uncheck the little square button with the "1".

  • Firevault: "Your homefolder is using more space than required"

    I would like to ask for some help. After every log-out, Firevault tells me that "Your homefolder is using more space than required" (or something between that lines). What can I do?
    Thank you for the help.

    Hi Morales,
    Unless you have a need for military-level security, FileVault is overkill. It slows your computer because all sorts of cache and preference files are repeatedly encrypted and decrypted, and because filevault is saving all your files in a big "container file," disk and directory errors that would otherwise be minor can cause massive data loss on a filevault-ed computer.
    To keep SOME files secure, an encrypted, password protected disk image is a better idea. You can make encrypted disk images with Applications/Utilities/Disk Utility. Do File > New > Disk Image from Folder.
    John

  • Does tethering my iPad to my iPhone 4s use more data than using an iPad that has its own data plan?

    Does tethering my iPad to my iPhone 4s use more data than using an iPad that has it's own data plan?

    No, it won't work.. the Airports are not media devices.. they have no brains .. no media extensions.. and itunes must be running on a computer.
    You can however watch movies from storage but not with itunes..
    See how people use tools like VLC to get around Apple's built in iTunes limitations.
    http://www.videolan.org/vlc/download-ios.html
    https://itunes.apple.com/gb/app/vlc-streamer/id410031728?mt=8

  • Why cant i open all my bookmarks in a new tab? only the ones visible above me, not the ones that show up when i click in the arrow to the upper right?

    why cant i open all my bookmarks in a new tab? only the ones visible above me, not the ones that show up when i click in the arrow to the upper right?

    Uninstall the Ask toolbar and it should work again. There is a compatibility issue with the Ask toolbar and Firefox that prevents new tabs from being opened.
    There are a couple of places to check for the Ask toolbar:
    * Check the Windows Control panel for the Ask Toolbar - http://about.ask.com/apn/toolbar/docs/default/faq/en/ff/index.html#na4
    * Also check your list of extensions, you may be able to uninstall it from there - https://support.mozilla.com/kb/Uninstalling+add-ons

  • Selecting all columns from table in a model query

    I have written a model query which joins 4 tables, applies some rules and returns updated rows by selecting 4 columns out of this. Currently it works fine because all 4 columns are from MODEL aliases. Now I need to select 16 more columns in the same query but none of these columns is added in MODEL aliases. When I tried selecting these columns I got oracle error ORA - 32614. Can someone please guide me to include these columns in the same model query?
    I tried couple of options but no luck. Here are those options for ready reference:
    1. I cannot nest existing model query into another select because there are no columns avaiable to join in output of current query to map with other records.
    2. I cannot include all 16 columns in MODEL aliases because some of these columns are actually output of user defined functions.
    I am using Oracle database version 11g Release 11.2.0.1.0.
    Edited by: Anirudha Dhopate on Jan 23, 2011 5:43 PM

    Thank you Avijit for your reply. There is a syntax error on the ON in this part of the statement which I don't know how to fix - I tried messing around with another INNER JOIN but am not confident that I'm doing the right thing:
    SENAlertType.SENAlertTypeIDONClassMember.ClassMemberStudentID
    Thanks for your help! I will need to do some more bedtime reading on joins.
    Daniel

  • "Can select all" option in Oracle BI Publisher

    Hi,
    I created a parameter in my report in Oracle BI Publisher and I selected "Multiple selection" and "Can select all" for this parameter.
    My data model is a sql query where I use this parameter in the "IN" condition like:
    where customer_name in (:customer)
    When I select in the prompt one or two or more values to "customer_name", results are correct. But when I select "All" I don't obtain results.
    I noted when I select "All" is passed the "NULL" value. I don't have "All values passed" and "NULL value passed" checkboxes.
    My Oracle BI Publisher version is 10.1.3.2.
    Can someone help me?

    Hi,
    You can give range values in the Query designer.
    You can include variable selection where user can enter the selections with their own selections.
    Let us know if you still have any issues.
    Reg
    Pra

  • ALV GRID-how to select all the check boxes using push button

    Hai All,
    I displayed ALV grid & every record contains one check box as first column.
    If user clicks on one push button all the check boxes needs to selected.
    Could any one tell me how to do this?
    Regards,
    Bhaskar

    Hi Bhaskar,
       Try this code :
    *" Table declarations...................................................
    TABLES :
      spfli.                              " Flight Schedule
    *" Data declarations...................................................
    Work variables                                                      *
    DATA :
      w_checkbox  TYPE c,                  " Check Box
      w_checkbox1 TYPE c,                  " Check Box
      w_lineno    LIKE sy-lilli,           " Current Line No
      w_lines     TYPE i.                  " No. Of Records in Int.Table
    Internal table to hold Flight Schedule data                         *
    DATA :
       t_spfli LIKE
      STANDARD TABLE
            OF spfli.
    Structure to hold Function Codes                                    *
    DATA :
      fs_fcode LIKE LINE OF t_fcode.
                          TOP-OF-PAGE EVENT                             *
    TOP-OF-PAGE.
      PERFORM top_of_page.
                       START-OF-SELECTION EVENT                         *
    START-OF-SELECTION.
      PERFORM fetch_spfli_data.
      SET PF-STATUS 'YMENU1'.
      DESCRIBE TABLE t_spfli LINES w_lines.
      fs_fcode = 'EXIT'.
      APPEND fs_fcode TO t_fcode.
      fs_fcode = 'SELECT'.
      APPEND fs_fcode TO t_fcode.
      fs_fcode = 'DESELECT'.
      APPEND fs_fcode TO t_fcode.
      fs_fcode = 'RETRIEVE'.
      APPEND fs_fcode TO t_fcode.
                        AT USER-COMMAND EVENT                           *
    AT USER-COMMAND.
      PERFORM user_command.
    FORM top_of_page .
      WRITE :/50 'Flight Schedule Information'(008).
      ULINE.
      FORMAT COLOR 1.
      WRITE :/10 'Carrier ID'(001),
              25 'Connection ID'(002) ,
              43 'Airport From'(003),
              59 'Airport To'(004),
              74 'Departure Time'(007),
              93 'Arrival Time'(011),
             106 space.
    ENDFORM.                               " FORM TOP_OF_PAGE
    FORM fetch_spfli_data .
      SELECT carrid                        " Carrier ID
             connid                        " Connection ID
             airpfrom                      " Airport From
             airpto                        " Airport To
             deptime                       " Departure Time
             arrtime                       " Arrival Time
        FROM spfli
        INTO CORRESPONDING FIELDS OF
       TABLE t_spfli.
      IF sy-subrc EQ 0.
        PERFORM display_spfli_data.
      ENDIF.                               " IF SY-SUBRC EQ 0
    ENDFORM.                               " FORM FETCH_SPFLI_DATA
    FORM display_spfli_data .
      SORT t_spfli BY carrid ASCENDING.
      LOOP AT t_spfli INTO spfli.
        FORMAT COLOR 2.
        WRITE :/2 w_checkbox AS CHECKBOX,
                  spfli-carrid   UNDER text-001,
                  spfli-connid   UNDER text-002,
                  spfli-airpfrom UNDER text-003,
                  spfli-airpto   UNDER text-004,
                  spfli-deptime  UNDER text-007,
                  spfli-arrtime  UNDER text-011.
      ENDLOOP.                             " LOOP AT T_SPFLI...
    ENDFORM.                               " FORM DISPLAY_SPFLI_DATA
    FORM user_command .
      CASE sy-ucomm.
        WHEN 'SELECT'.
          w_checkbox1 = 'X'.
          DO w_lines TIMES.
            w_lineno = sy-index + 3.
            READ LINE w_lineno FIELD VALUE w_checkbox.
            IF w_checkbox = '*'.
              CONTINUE.
            ELSE.
              MODIFY LINE w_lineno FIELD VALUE w_checkbox FROM w_checkbox1.
            ENDIF.                         " IF W_CHECKBOX = '*'
          ENDDO.                           " DO W_LINES TIMES.
        WHEN 'DESELECT'.
          w_checkbox1 = ' '.
          DO w_lines TIMES.
            w_lineno = sy-index + 3.
            READ LINE w_lineno.
            IF w_checkbox = '*'.
              CONTINUE.
            ELSE.
              MODIFY LINE w_lineno FIELD VALUE w_checkbox FROM w_checkbox1.
            ENDIF.                         " IF W_CHECKBOX = '*'
          ENDDO.                           " DO W_LINES TIMES.
        WHEN 'RETRIEVE'.
          w_checkbox = ' '.
          DO w_lines TIMES.
            w_lineno = sy-index + 3.
            READ LINE w_lineno FIELD VALUE w_checkbox INTO w_checkbox.
            IF w_checkbox = 'X'.
              PERFORM fetch_sflight_data.
              PERFORM display_sflight_data.
            ENDIF.                         " IF W_CHECKBOX = 'X'
          ENDDO.                           " DO W_LINES TIMES.
      ENDCASE.                             " CASE SY-UCOMM
    ENDFORM.                               " FORM USER_COMMAND
    This report gives you the SPFLI Data and places a check box in front of each record. When u click on select all button it will select all the records. And if you click on deselect all it will deselect all the records. When you are trying this maintain the pf-status 'YMENU1' and give the function codes as in the code.
    Regards,
    Swapna.

  • How do you SELECT ALL on a page (used to CTRL L-CLICK in margin then mouse over selection)?

    In Pages 4x you could hold CTRL+LEFTMOUSE while in the margin area then select multiple things on that page you were looking by mousing over them (including selecting all).  Now you have to go one item at a time to delete? Is there a work-around?

    Ghazgkull wrote:
    . ctrl+clicking in iTunes selects all.
    No, it does not. You are still incorrect.
    ctrl + click does NOT select anything.
    It checks all boxes when you ctrl click on one box.
    If you want to select a bunch of consecutive songs...
    Select one then Shift click another, This will select all items from the first selection to the last selection.
    This is just plain nutty and is normally achieved on Windows 7 using ctrl+a,
    No it doesn't
    ctrl + a selects all.
    You are not selecting anything when you check all boxes. You are sinmply checking all boxes.

  • Why should we select all key fields when using for all entries

    Hi,
    Why should we select all key fields in our select query when using for all entries statement?
    I read about for all entries but this point was not clear in any post.
    Please explain me
    Regards,
    Subhashini

    Dear Subhasini,
    It is because FOR ALL ENTRIES deletes the duplicate entries before populating the target internal table.
    Please do an F1 on FOR ALL ENTRIES & read the SAP documentation.
    I mean how duplicate entries will not get deleted when we use this?
    Quite simple, if you select  all key fields then each entry will be unique & there will not be any duplicate entries to delete !!
    BR,
    Suhas
    Edited by: Suhas Saha on Oct 16, 2009 9:41 AM

  • MIRO select all column items on PO Reference tab

    I have a user running 4.6C that wants to select all items in a specific column at the same time rather than having to select each one individually.  I have found the documentation to change the column sequence but I can not find anything regarding how to do this.  Is there a way to do this other than creating a customized user exit or ABAP code?  Thanks

    Please check these answered links:
    Re: Hide Fields in MIRO
    Miro
    MIRO
    Edited by: Afshad Irani on May 6, 2010 8:42 AM

  • How to select (all black) image outline using script

    hi all,
    we have thousands of clipart images to convert from wmf to png. We need to apply some processing to each image. We do this by selecting the black outline with contiguous off so it selects all the black. We then inverse the selection and apply processing to the remaining color parts of the image, leaving the black untouched. We can easily automate all of the steps excluding the first black outline selection.
    anybody have any idea how we can do this?
    alternatively should we do this in illustrator when we do the conversion from wmf to png and create layers there?
    thanks.

    Thanks Michael, we're trying this now.
    Yes images are very similar in the fact that the have a complex hand drawn pure black outline with gradient colour inside.
    This gradient being a WMF is only linited to 16 steps, so the banding occurs. This is especially noticable when enlarged.
    so the purpose of the surface blur processing is to smooth this banding in the output png image, but keep the black outline sharp and crisp.
    Below is a sample of one of the images done manually. now only 5999 to go
    original wmf: https://dl.dropbox.com/u/40046102/Aardvark%20v2.wmf
    Imported PNG from WMF through Illustrator, note the colour banding in the blue fill:
    when smoothed in photoshop:

Maybe you are looking for

  • FBL5N t code and BSEG table is showing wrong contract number

    Hi, The proces flow is contract number>sales order>DMR-->Invoice Now when I am checking the VBFA table it's showing correct contract number against invoices but FBL5N t code and BSEG table are showing wrong contract numbers. Why FBL5N and BSEG table

  • Purchased Playlist Not Updating

    Running iOS 7.0.1 on an iPhone 5s My music app is not automatically downloading any new purchases, despite automatic downloads being turned on. Furthermore, it's not adding anything purchased on my iPhone to the "Purchased" playlist, it's simply goin

  • Bluetooth adapter for itouch w/ full avrcp profile???

    I read somewhere that the Jabra A125s (with internal ipod BT switched off) gives you the full AVRCP profile abilities, not just play pause stop and volume but also next/previous song. Can anyone confirm this for an ipod touch 2nd gen with firmware 3.

  • Block Movement type 122 for T code MBRL

    All SAP Gurus, I want to block the movement type 122 for T code MBRL. For this I used T code OMJJ, but here it is not showing MBRL as used T code. If MBRL is not specified in OMJJ for 122, then how MBRL t code is allowed for movement type 122. Please

  • My ibook keeps popping at me!

    Hi everyone! I have a dual usb iBook that has recently started popping every now and again - not a click but a pop! I also have problems with it freezing, especially when I'm using my usb wireless dongle. I have tried a clean reinstall, taking everyt