Is Index Required?

Hi All,
I have a table B with Column ID (Primary Key ) with Reference on table A with Column ID (PK).
Is it required to create Index for this foreign key of Table B?
Thanks,
Jacob

user545846 wrote:
Hi All,
I have a table B with Column ID (Primary Key ) with Reference on table A with Column ID (PK).
Is it required to create Index for this foreign key of Table B?
Thanks,
JacobIt is a good concept to always index a foreign key column.
One reason is that if you delete a record from the parent table then oracle issues a "select null from childtable where fk_column = Parentkey;" this select is needed to prevent the delete when child records exists. Without an index this select will be doing a full table scan on the child table and the delete will be very slow.
If the FK column in the child table is also the PK in the child table (strange concept but possible) then you have the index provided by the PK constraint automatically. You can't add a second index to this column then.
Edited by: Sven W. on Aug 7, 2009 1:50 PM

Similar Messages

  • Calendar attributes and indexes required from the Directory server

    What LDAP attributes must be accessible for search and read by any other
    Calendar user?
    <P>
    This is the list of 43 LDAP attributes that are searched and read by other
    Calendar users:
    <P>
    nscalaccess, nscalaccessdomain, nscaladmd,
    nscaldefaultnotereminder, nscaldefaultreminder, nscaldefaulttaskreminder,
    nscaldisplayprefs, nscalhost, nscalflags, nscallanguageid, nscalnodealias,
    nscalnotifmechanism, nscaloperatingprefs, nscalorgunit2, nscalorgunit3,
    nscalorgunit4, nscalpasswordrequired, nscalprmd, nscalrefreshprefs,
    nscalresourcecapacity, nscalresourcenumber, nscalserverversion,
    nscalsysopcanwritepassword, nscaltimezone, nscalxitemid, cn, employeenumber,
    facsimiletelephonenumber, generationqualifier, givenname, initials, mail, ou,
    sn, postaladdress, telephonenumber, title, userpassword, member, uniquemember,
    c, objectclass, o
    <P>
    The following attributes must be indexed on the Directory (Supplier or Consumer)
    Server:
    <P>
    aci pres
    changenumber eq
    cn pres, eq, sub
    member eq
    nsCalXItemId pres,eq,sub
    owner eq
    seealso eq
    uid pres, eq, sub
    uniquenumber eq

    Best way to do this is...
    1) Right click on the desired database.
    2) Select Tasks options.
    3) Select Generate Scripts Option.
    4) Select all the tables / views / procedures / functions you need using the options.
    5) Script to a single file (which is better) or script to single file per object(which you will end up with lots of files)..
    6) Done.. you have the SQL Script which you can use...
    Please mark as answer, if this has helped you solve the issue.
    Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.

  • Rebuild Indexes required everyday

    We are running Core Banking Application on Oracle 11g R1 on AIX. Recently while we do banking day end activity, we have to rebuild the indexes to improve the performance. if we perform end of day activity without rebuilding the indexes it takes around 4 hours. After rebuilding indexes it takes around 2 hours. We need to know why we have perform rebuild everyday. Everyday approximately 5000 records are inserted.

    This is the forum for the SQL Developer Data Modeler product.  I suggest you ask your question on the General Database Discussions forum: General Database Discussions
    or on the forum for your Banking application.

  • I have a manual that contains headings and index entries that contain less than and greater than characters, and . The Publish to Responsive HTML5 function escapes these correctly in the main body of the text but does not work correctly in either the C

    I have a manual that contains headings and index entries that contain less than and greater than characters, < and >. The Publish to Responsive HTML5 function escapes these correctly in the main body of the text but does not work correctly in either the Contents or the Index of the generated HTML. In the Contents the words are completely missing and in the index entries the '\' characters that are required in the markers remain in the entry but the leading less than symbol and the first character of the word is deleted; hence what should appear as <dataseries> appears as \ataseries\>. I believe this is a FMv12 bug. Has anyone else experienced this? Is the FM team aware and working on a fix. Any suggestions for a workaround?

    The Index issue is more complicated since in order to get the < and > into the index requires the entry itself to be escaped. So, in order to index '<x2settings>' you have to key '\<x2settings\>'. Looking at the generated index entry in the .js file we see '<key name=\"\\2settings\\&gt;\">. This is a bit of a mess and produces an index entry of '\2settings\>'. This ought to be '<key name=\"&amp;lt;x2settings&amp;gt;\" >'. I have tested this fix and it works - but the worst of it is that the first character of the index entry has been stripped out. Consequently I cannot fix this with a few global changes - and I have a lot of index entries of this type. I'm looking forward to a response to this since I cannot publish this document in its current state.  

  • How to create a local partition index asign its storage tablespace

    hi
    i see the syntax about create local context index
    quote:
    Syntax for CONTEXT Indextype
    Use this indextype to create an index on a text column. You query this index with the CONTAINS operator in the WHERE clause of a SELECT statement. This index requires manual synchronization after DML.
    CREATE INDEX [schema.]index on [schema.]table(column) INDEXTYPE IS ctxsys.context [ONLINE]
    LOCAL [(PARTITION [partition] [PARAMETERS('paramstring')]
    [, PARTITION [partition] [PARAMETERS('paramstring')]])]
    [PARAMETERS(paramstring)] [PARALLEL n] [UNUSABLE];
    and i try the under code ,all failed.
    SQL&gt; create index html2_idx on HTML2(newsdescription) indextype is ctxsys.contex
    t local (partition indx parameters('lexer my_lexer'),partition indx01 tablespace
    users01 parameters('lexer my_lexer'),partition indx02 tablespace users02 param
    eters('lexer my_lexer'),partition indx03 tablespace users03 parameters('lexer m
    y_lexer') );
    ERROR:ORA-29850
    could anybody show some demo sql code creating partition context index asign its storage tablespace
    thanks

    try:
    create index html2_idx on HTML2(newsdescription) indextype is ctxsys.contex
    t local (
    partition indx parameters('lexer my_lexer'),
    partition indx01 parameters('storage users01_stg lexer my_lexer'),
    partition indx02 parameters('storage users02_stg lexer my_lexer'),
    Create storage preferences users01, users02, .. with I, K, ... attributes for tablespace users01, users02, ...
    Btw, ¿does anyone know whats the upper limit of partitions for a domain index? I've read in OTN they were 9999 but it crashes me (oracle 9.2.0.1) when I have 255... ¿has anyone tried this?

  • Help me with Points to be noted While creating a Secondary Index.

    Hi,
    There is a Secondary index created on a Z table which already have 9 secondary indexes. This is the 10th index that is created.
    The Index is created as follows
    MANDT             Client
    DOCNUM_REF     Document number
    The Table data is huge and it is more than 4Lakh records.
    I have done the following analyses.
    1) The fields to be used are not in any other indexes.
    2) The Data is mostly different, i.e. The document reference field is having distinct data
      select a~docnum a~werks_o a~docnum_ref a~natop
             a~m_icms a~m_ipi
             b~lgort_out b~mov_est
             b~item b~matnr
        appending table ti_requisicoes
        from zsytmm_reqnfcb as a
       inner join zsytmm_reqnfit as b
          on a~branch_o eq b~branch_o
         and a~requi    eq b~requi
         and a~mask     eq b~mask
         for all entries in ti_doc_saida_del
       where a~docnum_ref   eq ti_doc_saida_del-docnum.
    What else I need to check , so that the index improves the performance. The table is using in 300 reports.

    Ravishankar Lanjewar wrote:
    @SAP LEARNER,
    >
    > There is a Secondary index created on a Z table which already have 9 secondary
    > indexes. This is the 10th index that is created.
    >
    >
    > I will not recommand to create index any more on this table. If you want to create secondary index for on above table which you have mention. You don't create index only for hamper of performance of single program/report.
    >
    > Don't create more than 4 to 5 index on sinlge table.
    >
    > Refere the tread Link:[Why to create Secondary index ?|Re: When is a secondary index used (in select or where)]
    Sounds like another myth that is widely spread across SAP community.
    Remember, complex systems like modern DBMS do not like generalizations. I personally know standard SAP tables with 9 standard secondary indexes. In the meantime the hardware became fast enough to update several secondary indexes without really significant problems. Of course indexes require space, of course one should create indexes that are not similar and differ from each other with more than one field for example. In other words, think before creating!
    But it's again incorrect to say "do not create because you already have 9 others". You did not even ask what fields are in the affected table, what are the existing indexes.
    Ravishankar Lanjewar wrote:
    > I will recommand to delete all the index and create 4 to 5 fresh index while doing analysis for all SQL statement using where use list  depends on where condition of SQL.
    I am now trying to imagine the effort to analyze 300 reports using this table and all corresponding selects. And probably you will drop supporting indexes for several reports. Some of them may be CEO/CFO-relevant reports that will run minutes/hours instead of seconds. And I would like to see the reaction of CEO when he finds out that it was the result of your "optimization" activities.

  • Need some advice with indexing and search server in multihomed environment.

    Hi,
    I want to introduce the JISS (java indexing and search server). We have an multihomed environment with two frontends for convergence and imap/pop proxy service and two mail stores in a cluster HA environment
    (Sun cluster 3.2, messaging server 7u3-15.01, convergence 1.0-12.01 running on glassfish 2.1.1). The directory servers (multimaster) are on speperated servers.
    I viewed the jiss deployment pages in the wiki (http://wikis.sun.com/display/CommSuite/Indexing+and+Search+Service+Deployment+Planning), but they are more confusing than helpful.
    My questions are as follows:
    Can I put the jiss web service on the convergence server (to share the same glassfish server?
    Is it better to put the indexing part of JISS on a seperate server or on the convergence server or better on the mail store servers?
    Can I run the JMQ broker in an HA environment on the cluster? Is it possible to run JMQ together with messaging server in the same cluster group?
    Can JISS index two mail stores (I didn't find anything in the config guide)?
    Best Regards,
    Ruediger

    ruediger_kunze wrote:
    I want to introduce the JISS (java indexing and search server). We have an multihomed environment with two frontends for convergence and imap/pop proxy service and two mail stores in a cluster HA environmentI would recommend holding off until the next release (Communication Suite 7 update 1) as ISS update 1 provides a large number of useful enhancement.
    I viewed the jiss deployment pages in the wiki (http://wikis.sun.com/display/CommSuite/Indexing+and+Search+Service+Deployment+Planning), but they are more confusing than helpful.
    My questions are as follows:
    Can I put the jiss web service on the convergence server (to share the same glassfish server?Yes. This is the scenario used in the single-host-install guide:
    http://wikis.sun.com/display/CommSuite7/Sun+Java+Communications+Suite+7+on+a+Single+Host
    Is it better to put the indexing part of JISS on a seperate server or on the convergence server or better on the mail store servers?This is answered in the Deployment Planning guide:
    "Indexing requires significant CPU resources, thus, it is best to install the indexing service on a separate host dedicated to an ISS single server installation. If this is not an option, then install ISS on the back-end host as a single server installation, and install GlassFish Server as well for ISS."
    Can I run the JMQ broker in an HA environment on the cluster? Is it possible to run JMQ together with messaging server in the same cluster group?This article may help:
    http://wikis.sun.com/display/CommSuite/Deploying+GlassFish+Message+Queue+in+a+Highly+Available+Environment
    Can JISS index two mail stores (I didn't find anything in the config guide)?When you Bootstrap the account you point at the mailhost that the account resides on:
    http://wikis.sun.com/display/CommSuite/Administering+Indexing+and+Search+Service
    "Creating New ISS Accounts"
    Regards,
    Shane.

  • Indexing ORDSignatures

    I have an installation of Oracle 9i Standard on WinXP upon which I have a set of valid ORDImages and valid ORDSignatures in a table.
    I wish to index the ORDSignatures in order to perform colour/pattern matching at a reasonable speed. I have done this before on 8i Enterprise Edition, and indeed in development on 9i Enterprise Edition.
    However... in 9i Standard when I attempt to create the index I get the error:
    "ORA-00439: Feature not enabled: Bit-mapped indexes".
    Either I've got a silly installation (in which case please just tell me, it does happen) or ...
    Oracle's licensing policy is missing something here since if interMedia is included in 9i Standard including the Image/Pattern Matching and yet it's content is not indexable then it does rather defeat the object doesn't it?
    I am presuming here from the error message that an ORDSignature index requires a feature not included with Standard ed, although the Oracle feature list doesn't say intermedia requires bitmap indexes as a pre-requisite.
    Any info/thoughts appreciated,
    Jason "Images are just another data type" Kane.

    Hi Jason,
    This is the case. All features of interMedia work with Standard edition except image indexing. As you have observed, indexing of ORDImageSignature requires Bit-mapped indexes which are only available with Enterprise Edition.
    This information is documented, but we need to make this information more prominent.
    Sue

  • Why do I use condition indexes? How do you activate them?

    Hi all
    Why do I use condition indexes? How do you activate them?
    thanks all

    You can create and use condition indices. You can use these indices to display, change and create condition records with reference. This transaction can include condition records with several condition types and tables. For example, you can use a condition index if you want to see all condition records that apply to a particular product regardless of whether the records are prices or discounts. In this case, you can use one of the standard condition indexes. Or you may want to see a list of condition records that contain a particular sales deal and a material from a user-specified list of products. To display this information, you can create your own condition index.
    Creating a condition index is similar to creating a condition table. In Customizing for Sales, you select the combination of fields that you want in the index key. The system automatically proposes a list of permitted fields to choose from. The fields you specify for the key can have a maximum combined length of 100 characters.
    The activation function displays a list of all available condition indexes and indicates which are active. The system can use a condition index only when it is activated. Before you can use the indexes that are delivered in the standard version, you must first activate them in Customizing for Sales. Some indices are activated automatically during generation. In addition, you must specify one of the following index updating requirements for each condition index:
    Requirement 1: The index is updated when the user provides data for all fields in the index
    Requirement 2: The index is updated when the user provides data for at least the first index field

  • Drop - recreate indexes

    I have a table with more than a 100 million records in production.
    There are a total of 6 indexes on the table out of which 4 are bitmap indexes.
    At the end of the year the table is populated with data. I am not aware of how many records are inserted into the table at once.
    I have done some statistical analysis in the development environment though according to which dropping and recreating indexes is feasible if the number of records inserted at once is less than 500.
    But the table count in development is only 7 million, far less than the production.
    Please advise what is the best possible way. Is there a need to drop and recreate indexes and if yes are all indexes required to drop or only the bitmap ones.
    Note: I am using oracle 10g database
    Edited by: 834445 on Feb 13, 2011 1:45 AM

    834445 wrote:
    I have a table with more than a 100 million records in production.
    There are a total of 6 indexes on the table out of which 4 are bitmap indexes.
    At the end of the year the table is populated with data. I am not aware of how many records are inserted into the table at once.
    I have done some statistical analysis in the development environment though according to which dropping and recreating indexes is feasible if the number of records inserted at once is less than 500.
    But the table count in development is only 7 million, far less than the production.
    Please advise what is the best possible way. Is there a need to drop and recreate indexes and if yes are all indexes required to drop or only the bitmap ones.
    Note: I am using oracle 10g database
    Always a difficult call to make, but doing some experiments as you are doing is a good start.
    Other points to consider - how much down-time are you given for this load, or are people expecting to access the table while it's going on - does the table get more rows added bit by bit over the course of the year - is there a big delete that happens before or at about the same time as the big insert.
    How big are the indexes (the b-tree ones particularly) compared to the total size of the cache ? On a normal insert Oracle will update b-tree indexes row by row with the table, and this can lead to a very large amount of random I/O if the indexes can't stay in the cache; what are your options for using special mechanisms (like SQL*Load, direct path insert, append hints etc.)
    Is your test representative of the real load - what do you know about patterns of data distribution and ordering as the data is loaded: how many distinct values are there in each bitmap index - if the number of distinct values similar to (or larger then) the number of rows in an array then you might end up inserting one row per value in the index for each array, and this could make the index grow unreasonably and generate a lot of redo - if your arraysize is (say) inserting 20 rows per bitmap key then the impact might be much less dramatic. This means you might choose to drop a couple of bitmap indexes while loading but keep the others.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    A general reminder about "Forum Etiquette / Reward Points": http://forums.oracle.com/forums/ann.jspa?annID=718
    If you never mark your questions as answered people will eventually decide that it's not worth trying to answer you because they will never know whether or not their answer has been of any use, or whether you even bothered to read it.
    It is also important to mark answers that you thought helpful - again it lets other people know that you appreciate their help, but it also acts as a pointer for other people when they are researching the same question, moreover it means that when you mark a bad or wrong answer as helpful someone may be prompted to tell you (and the rest of the forum) what's so bad or wrong about the answer you found helpful.

  • Index related queries

    1.I need to check the size of an index in a database.
    Is the below query i am using the correct one.
    select sum(bytes)/1024/1024 IdxsizMb from dba_segments where segment_type='INDEX' and segment_name = 'XXX';
    2.How can I know which indexes are used and which are unused and create a report out of the same.
    I am using 10g.
    3.What will be the best option to reclaim space used by unused indexes,compressing or dropping those.
    please let me know your suggestions.

    user610910 wrote:
    I am using the below query to check index usage statistics.
    I queried some tables and checked that these were accessing some indexes in explain plan.
    Still the index count given by the below query is not increasing.
    Can anyone suggest me a better alternative.The query is based on your AWR repository. Unfortunately the AWR by default captures only the Top N SQLs, so using this approach is likely to miss a lot of indexes and therefore is unreliable (and it's not reasonable either to re-configure your AWR to capture all SQLs).
    You can use the index monitoring feature of Oracle to find out if an index is used or not, but you need to be careful: There are circumstances where the monitoring doesn't show the index usage despite the index is being used resp. required by the application.
    Among these cases are: Indexes used to index foreign key constraints (used to avoid table lock / contention in case of parent key modifications), unique indexes required to enforce unique/primary keys and indexes that might not be used at all but are used by the optimizer to work out an efficient execution plan (so dropping the unused index might change an execution plan, and not necessarily for the better).
    Check the documentation on how to enable/use/disable the index monitoring feature.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • How to use secondry index

    Hi Experts,
    I have a requirement to improve the performance of report,So i got some select querys there non primery keys are used for table VBAK,VBAP,LIKP,LIPS so i want to create secondry index for that,Any one can help me for that means after create secondry index how to use that index in report and for create secondry index required any MANDT field or Not.
    Thanks.

    Hello Ram,
    Before creating secondary index you need to know the below points.
    1) Do not create more indices on table
    2) What is the frequency of table access
    3) You should not create too much columns(should be less than 120 characters)
    4) Cant you use existing indices?
    5) DML operation will be delayed if you create index
    Before moving to Production system please consider below the points.
    1) Ask BASIS to create index in DB level then move your DDIC transport which will be faster
    2) While creating index if the DB size is like more than 500 GB then downtime is required
    Regards,
    Vadamalai A

  • Difference between indexes

    Hi ,
    What is difference between normal index and domain index?
    Please help.
    Thanks.

    >
    What is difference between normal index and domain index?
    >
    Domain indexes are custom indexes that you provide the code to manage: create, update, delete values.
    Normal indexes are the indexes that Oracle makes available out-of-the-box as standard functionality.
    If you need to index non-relational data or have unique indexing requirements (e.g. to index binary data) Oracle provides Data Cartridge functionality that allows you to extend Oracle to include your own indexing code.
    The link to the Data Cartridge doc that marcusrangle provided gives the domain index definition at the top.
    See Overview of Indextypes and Domain Indexes
    >
    Overview of Indextypes and Domain Indexes
    A domain index is an index designed for a specialized domain, such as spatial or image processing. Users can build a domain index of a given type after the designer creates the indextype. The behavior of domain indexes is specific to an industry, a business function, or some other special purpose; you must specify it during cartridge development.

  • Windows 8 hangs or freezes whenever search for anything

    Rebuild the Index
    Whenever you try to search for something in windows, its indexing which find the things quickly and brings that to you.If indexing is disabled or corrupt computer won't be able to search and will not present the search results.Windows uses the index to perform very fast searches on your computer.
    The index requires almost no maintenance. However, if the index can't find a file that you know exists in an indexed location, you might need to rebuild the index. Rebuilding the index can take several hours, and searches might be incomplete until the index is fully rebuilt.
    Go to Control panel and open Indexing Options.
    Click the Advanced button at the bottom of the Indexing Options window. This displays a new window titled Advanced Options.
    Click the Index Settings tab if it isn’t selected already.
    Click the Rebuild button to delete and rebuild the file index.
    Click OK to confirm.
    For more information on Advance indexing option you can read article on microsoft's website http://windows.microsoft.com/en-in/windows7/change​-advanced-indexing-options
    Step 2 will always fix this issue but just in case its not helpful try the next Step 3.
    3.Check the Registry Value
    Manual Fix 1 
    1. Press Windows Key + R to get the run dialogue box.
    2. Type "regedit.exe" in the box and hit enter.
    3. Using the box on the left, navigate to the following directory:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
    4. We need to change a registry called "Start_SearchFiles" to a value of 2. If you are like me, yours is already 2. We need to reset this so what we are going to do it change it to 0, then back to 2.
    5. Double-click Start_SearchFiles or right-click and select "Modify" to get the edit box. Change the number under "Value data" to 0 then click "Ok".
    6. Repeat step 5, changing the value back to 2.
    7. Restart your computer.
    Manual Fix 2
    Using the above information navigate to the following directory: Read More on http://bookingtohosting.blogspot.com/2015/04/windo​ws-8-hangs-or-freezes-whenever.html

    Hi,
    Regarding current information we can't say that it related to this exe file.
    We need to use Clean boot mode and Safe mode to test the results:
    Please first restart the Windows in Clean boot and see if the issue still persists after reboot:
    How to perform a clean boot
    http://support.microsoft.com/kb/929135
    If the issue doesn’t appear, you can determine which one can be the cause by using dichotomy in MSconfig. Checking on half of Non-Microsoft service and restart, determining which half of the services cause the issue and repeating to check half of the problematic
    half services.
    If the issue still persists in Clean boot mode, please test in Safe mode.
    Let me know the results in Safe mode.
    If we cannot identify this issue in Clean boot and safe mode, please help to collect the boot trace and let's see what cause this issue:
    Windows Performance Toolkit: Simple Boot Logging
    http://www.autoitconsulting.com/site/performance/windows-performance-toolkit-simple-boot-logging/
    You can upload the etl file from this tool for our research.
    Kate Li
    TechNet Community Support

  • Why is LOWER function producing a cartesian merge join, when UPPER doesn't?

    Hi there,
    I have an odd scenario that I would like to understand correctly...
    We have a query that is taking a long time to run on one of our databases, further investigation of the explain plan showed that the query was in fact producing a Cartesian merge join even though there is clearly join criteria specified. I know that the optimiser can and will do this if it is a more efficient way of producing the results, however in this scenario it is producing the Cartesian merge on two unrelated tables and seemingly ignoring the Join condition...
    *** ORIGINAL QUERY ***
    SELECT count(*)
    FROM    srs_sce sce,
                srs_scj scj,
                men_mre mre,
                srs_mst mst,
                cam_smo cam,
                ins_spr spr,
                men_mua mua,
               temp_webct_users u
    WHERE sce.sce_scjc = scj.scj_code
    AND sce.sce_stuc = mre.mre_code
    AND mst.mst_code = mre.mre_mstc
    AND mre.mre_mrcc = 'STU'
    AND mst.mst_code = mua.mua_mstc
    AND cam.ayr_code = sce.sce_ayrc
    AND cam.spr_code = scj.scj_sprc
    AND spr.spr_code = scj.scj_sprc
    -- Ignored Join Condition
    AND LOWER(mua.mua_extu) = LOWER(u.login)
    AND SUBSTR (sce.sce_ayrc, 1, 4) = '2008'
    AND sce.sce_stac IN ('RCE', 'RLL', 'RPD', 'RIN', 'RSAS', 'RHL_R', 'RCO', 'RCI', 'RCA');
    *** CARTESIAN EXPLAIN PLAN ***
    SELECT STATEMENT  CHOOSECost: 83                                               
         20 NESTED LOOPS  Cost: 83  Bytes: 176  Cardinality: 1                                          
              18 NESTED LOOPS  Cost: 82  Bytes: 148  Cardinality: 1                                     
                   15 NESTED LOOPS  Cost: 80  Bytes: 134  Cardinality: 1                                
                        13 NESTED LOOPS  Cost: 79  Bytes: 123  Cardinality: 1                           
                             10 NESTED LOOPS  Cost: 78  Bytes: 98  Cardinality: 1                      
                                  7 NESTED LOOPS  Cost: 77  Bytes: 74  Cardinality: 1                 
    NOTE: The Cartesian product is performed on the men_mre & temp_webct_users tables not the men_mua mua & temp_webct_users tables specified in the join condition.
                                       4 MERGE JOIN CARTESIAN  Cost: 74  Bytes: 32  Cardinality: 1            
                                            1 TABLE ACCESS FULL EXETER.TEMP_WEBCT_USERS Cost: 3  Bytes: 6  Cardinality: 1       
                                            3 BUFFER SORT  Cost: 71  Bytes: 1,340,508  Cardinality: 51,558       
                                                 2 TABLE ACCESS FULL SIPR.MEN_MRE Cost: 71  Bytes: 1,340,508  Cardinality: 51,558 
                                       6 TABLE ACCESS BY INDEX ROWID SIPR.SRS_SCE Cost: 3  Bytes: 42  Cardinality: 1            
                                            5 INDEX RANGE SCAN SIPR.SRS_SCEI3 Cost: 2  Cardinality: 3       
                                  9 TABLE ACCESS BY INDEX ROWID SIPR.SRS_SCJ Cost: 1  Bytes: 24  Cardinality: 1                 
                                       8 INDEX UNIQUE SCAN SIPR.SRS_SCJP1 Cardinality: 1            
                             12 TABLE ACCESS BY INDEX ROWID SIPR.INS_SPR Cost: 1  Bytes: 25  Cardinality: 1                      
                                  11 INDEX UNIQUE SCAN SIPR.INS_SPRP1 Cardinality: 1                 
                        14 INDEX UNIQUE SCAN SIPR.SRS_MSTP1 Cost: 1  Bytes: 11  Cardinality: 1                           
                   17 TABLE ACCESS BY INDEX ROWID SIPR.MEN_MUA Cost: 2  Bytes: 14  Cardinality: 1                                
                        16 INDEX RANGE SCAN SIPR.MEN_MUAI3 Cost: 2  Cardinality: 1                           
              19 INDEX RANGE SCAN SIPR.CAM_SMOP1 Cost: 2  Bytes: 28  Cardinality: 1                                     After speaking with data experts I realised one of the fields being LOWERed for the join condition generally always had uppercase values so I tried modifying the query to use the UPPER function rather than the LOWER one originally used, in this scenario the query executed in seconds and the Cartesian merge had been eradicated which by all accounts is a good result.
    *** WORKING QUERY ***
    SELECT count(*)
      FROM srs_sce sce,
           srs_scj scj,
           men_mre mre,
           srs_mst mst,
           cam_smo cam,
           ins_spr spr,
           men_mua mua,
           temp_webct_users u
    WHERE sce.sce_scjc = scj.scj_code
       AND sce.sce_stuc = mre.mre_code
       AND mst.mst_code = mre.mre_mstc
       AND mre.mre_mrcc = 'STU'
       AND mst.mst_code = mua.mua_mstc
       AND cam.ayr_code = sce.sce_ayrc
       AND cam.spr_code = scj.scj_sprc
       AND spr.spr_code = scj.scj_sprc
    -- Working Join Condition
       AND UPPER(mua.mua_extu) = UPPER(u.login)
       AND SUBSTR (sce.sce_ayrc, 1, 4) = '2008'
       AND sce.sce_stac IN ('RCE', 'RLL', 'RPD', 'RIN', 'RSAS', 'RHL_R', 'RCO', 'RCI', 'RCA');
    *** WORKING EXPLAIN PLAN ***
    SELECT STATEMENT  CHOOSECost: 13                                                    
         20 SORT AGGREGATE  Bytes: 146  Cardinality: 1                                               
              19 NESTED LOOPS  Cost: 13  Bytes: 146  Cardinality: 1                                          
                   17 NESTED LOOPS  Cost: 12  Bytes: 134  Cardinality: 1                                     
                        15 NESTED LOOPS  Cost: 11  Bytes: 115  Cardinality: 1                                
                             12 NESTED LOOPS  Cost: 10  Bytes: 91  Cardinality: 1                           
                                  9 NESTED LOOPS  Cost: 7  Bytes: 57  Cardinality: 1                      
                                       6 NESTED LOOPS  Cost: 6  Bytes: 31  Cardinality: 1                 
                                            4 NESTED LOOPS  Cost: 5  Bytes: 20  Cardinality: 1            
                                                 1 TABLE ACCESS FULL EXETER.TEMP_WEBCT_USERS Cost: 3  Bytes: 6  Cardinality: 1       
                                                 3 TABLE ACCESS BY INDEX ROWID SIPR.MEN_MUA Cost: 2  Bytes: 42  Cardinality: 3       
                                                      2 INDEX RANGE SCAN EXETER.TEST Cost: 1  Cardinality: 1 
                                            5 INDEX UNIQUE SCAN SIPR.SRS_MSTP1 Cost: 1  Bytes: 11  Cardinality: 1            
                                       8 TABLE ACCESS BY INDEX ROWID SIPR.MEN_MRE Cost: 2  Bytes: 26  Cardinality: 1                 
                                            7 INDEX RANGE SCAN SIPR.MEN_MREI2 Cost: 2  Cardinality: 1            
                                  11 TABLE ACCESS BY INDEX ROWID SIPR.SRS_SCE Cost: 3  Bytes: 34  Cardinality: 1                      
                                       10 INDEX RANGE SCAN SIPR.SRS_SCEI3 Cost: 2  Cardinality: 3                 
                             14 TABLE ACCESS BY INDEX ROWID SIPR.SRS_SCJ Cost: 1  Bytes: 24  Cardinality: 1                           
                                  13 INDEX UNIQUE SCAN SIPR.SRS_SCJP1 Cardinality: 1                      
                        16 INDEX RANGE SCAN SIPR.CAM_SMOP1 Cost: 2  Bytes: 19  Cardinality: 1                                
                   18 INDEX UNIQUE SCAN SIPR.INS_SPRP1 Bytes: 12  Cardinality: 1                                     *** RESULT ***
    COUNT(*)
    83299I am still struggling to understand why this would have worked as to my knowledge the LOWER & UPPER functions are similar enough in function and regardless of that why would one version cause the optimiser to effectively ignore a join condition.
    If anyone can shed any light on this for me it would be very much appreciated.
    Regards,
    Kieron
    Edited by: Kieron_Bird on Nov 19, 2008 6:09 AM
    Edited by: Kieron_Bird on Nov 19, 2008 6:41 AM

    My mistake on the predicate information, was in a rush to run off to a meeting when I posted the entry...
    *** UPPER Version of the Explain Plan ***
    | Id  | Operation                     |  Name             | Rows  | Bytes | Cost  |  TQ    |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT              |                   |     1 |   146 |   736 |        |      |            |
    |   1 |  SORT AGGREGATE               |                   |     1 |   146 |       |        |      |            |
    |   2 |   SORT AGGREGATE              |                   |     1 |   146 |       | 86,10  | P->S | QC (RAND)  |
    |*  3 |    HASH JOIN                  |                   |   241 | 35186 |   736 | 86,10  | PCWP |            |
    |*  4 |     HASH JOIN                 |                   |   774 |   105K|   733 | 86,09  | P->P | HASH       |
    |*  5 |      HASH JOIN                |                   | 12608 |  1489K|   642 | 86,08  | P->P | BROADCAST  |
    |   6 |       NESTED LOOPS            |                   | 14657 |  1531K|   491 | 86,07  | P->P | HASH       |
    |*  7 |        HASH JOIN              |                   | 14657 |  1359K|   490 | 86,07  | PCWP |            |
    |*  8 |         HASH JOIN             |                   | 14371 |   996K|   418 | 86,06  | P->P | HASH       |
    |*  9 |          TABLE ACCESS FULL    | SRS_SCE           |  3211 |   106K|   317 | 86,00  | S->P | BROADCAST  |
    |* 10 |          HASH JOIN            |                   | 52025 |  1879K|   101 | 86,06  | PCWP |            |
    |* 11 |           TABLE ACCESS FULL   | MEN_MRE           | 51622 |  1310K|    71 | 86,01  | S->P | HASH       |
    |  12 |           INDEX FAST FULL SCAN| SRS_MSTP1         |   383K|  4119K|    30 | 86,05  | P->P | HASH       |
    |  13 |         TABLE ACCESS FULL     | SRS_SCJ           |   114K|  2672K|    72 | 86,02  | S->P | HASH       |
    |* 14 |        INDEX UNIQUE SCAN      | INS_SPRP1         |     1 |    12 |       | 86,07  | PCWP |            |
    |  15 |       TABLE ACCESS FULL       | MEN_MUA           |   312K|  4268K|   151 | 86,03  | S->P | HASH       |
    |  16 |      INDEX FAST FULL SCAN     | CAM_SMOP1         |   527K|  9796K|    91 | 86,09  | PCWP |            |
    |  17 |     TABLE ACCESS FULL         | TEMP_WEBCT_USERS  | 33276 |   194K|     3 | 86,04  | S->P | HASH       |
    Predicate Information (identified by operation id):
       3 - access(UPPER("MUA"."MUA_EXTU")=UPPER("U"."LOGIN"))
       4 - access("CAM"."AYR_CODE"="SCE"."SCE_AYRC" AND "CAM"."SPR_CODE"="SCJ"."SCJ_SPRC")
       5 - access("MST"."MST_CODE"="MUA"."MUA_MSTC")
       7 - access("SCE"."SCE_SCJC"="SCJ"."SCJ_CODE")
       8 - access("SCE"."SCE_STUC"="MRE"."MRE_CODE")
       9 - filter(SUBSTR("SCE"."SCE_AYRC",1,4)='2008' AND ("SCE"."SCE_STAC"='RCA' OR "SCE"."SCE_STAC"='RCE' OR
                  "SCE"."SCE_STAC"='RCI' OR "SCE"."SCE_STAC"='RCO' OR "SCE"."SCE_STAC"='RHL_R' OR "SCE"."SCE_STAC"='RIN' OR
                  "SCE"."SCE_STAC"='RLL' OR "SCE"."SCE_STAC"='RPD' OR "SCE"."SCE_STAC"='RSAS'))
      10 - access("MST"."MST_CODE"="MRE"."MRE_MSTC")
      11 - filter("MRE"."MRE_MRCC"='STU')
      14 - access("SPR"."SPR_CODE"="SCJ"."SCJ_SPRC")
    Note: cpu costing is off
    40 rows selected.*** LOWER Version of the Explain Plan ***
    | Id  | Operation                     |  Name             | Rows  | Bytes | Cost  |  TQ    |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT              |                   |     1 |   146 |   736 |        |      |            |
    |   1 |  SORT AGGREGATE               |                   |     1 |   146 |       |        |      |            |
    |   2 |   SORT AGGREGATE              |                   |     1 |   146 |       | 88,10  | P->S | QC (RAND)  |
    |*  3 |    HASH JOIN                  |                   |   257K|    35M|   736 | 88,10  | PCWP |            |
    |*  4 |     HASH JOIN                 |                   |   774 |   105K|   733 | 88,09  | P->P | HASH       |
    |*  5 |      HASH JOIN                |                   | 12608 |  1489K|   642 | 88,08  | P->P | BROADCAST  |
    |   6 |       NESTED LOOPS            |                   | 14657 |  1531K|   491 | 88,07  | P->P | HASH       |
    |*  7 |        HASH JOIN              |                   | 14657 |  1359K|   490 | 88,07  | PCWP |            |
    |*  8 |         HASH JOIN             |                   | 14371 |   996K|   418 | 88,06  | P->P | HASH       |
    |*  9 |          TABLE ACCESS FULL    | SRS_SCE           |  3211 |   106K|   317 | 88,00  | S->P | BROADCAST  |
    |* 10 |          HASH JOIN            |                   | 52025 |  1879K|   101 | 88,06  | PCWP |            |
    |* 11 |           TABLE ACCESS FULL   | MEN_MRE           | 51622 |  1310K|    71 | 88,01  | S->P | HASH       |
    |  12 |           INDEX FAST FULL SCAN| SRS_MSTP1         |   383K|  4119K|    30 | 88,05  | P->P | HASH       |
    |  13 |         TABLE ACCESS FULL     | SRS_SCJ           |   114K|  2672K|    72 | 88,02  | S->P | HASH       |
    |* 14 |        INDEX UNIQUE SCAN      | INS_SPRP1         |     1 |    12 |       | 88,07  | PCWP |            |
    |  15 |       TABLE ACCESS FULL       | MEN_MUA           |   312K|  4268K|   151 | 88,03  | S->P | HASH       |
    |  16 |      INDEX FAST FULL SCAN     | CAM_SMOP1         |   527K|  9796K|    91 | 88,09  | PCWP |            |
    |  17 |     TABLE ACCESS FULL         | TEMP_WEBCT_USERS  | 33276 |   194K|     3 | 88,04  | S->P | HASH       |
    Predicate Information (identified by operation id):
       3 - access(LOWER("MUA"."MUA_EXTU")=LOWER("U"."LOGIN"))
       4 - access("CAM"."AYR_CODE"="SCE"."SCE_AYRC" AND "CAM"."SPR_CODE"="SCJ"."SCJ_SPRC")
       5 - access("MST"."MST_CODE"="MUA"."MUA_MSTC")
       7 - access("SCE"."SCE_SCJC"="SCJ"."SCJ_CODE")
       8 - access("SCE"."SCE_STUC"="MRE"."MRE_CODE")
       9 - filter(SUBSTR("SCE"."SCE_AYRC",1,4)='2008' AND ("SCE"."SCE_STAC"='RCA' OR "SCE"."SCE_STAC"='RCE' OR
                  "SCE"."SCE_STAC"='RCI' OR "SCE"."SCE_STAC"='RCO' OR "SCE"."SCE_STAC"='RHL_R' OR "SCE"."SCE_STAC"='RIN' OR
                  "SCE"."SCE_STAC"='RLL' OR "SCE"."SCE_STAC"='RPD' OR "SCE"."SCE_STAC"='RSAS'))
      10 - access("MST"."MST_CODE"="MRE"."MRE_MSTC")
      11 - filter("MRE"."MRE_MRCC"='STU')
      14 - access("SPR"."SPR_CODE"="SCJ"."SCJ_SPRC")
    Note: cpu costing is off
    40 rows selected.As you state something has obviously changed, but nothing obvious has been changed.
    We gather statistics via...
    exec dbms_stats.gather_schema_stats(ownname => 'USERNAME', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE , degree => 4, granularity => ''ALL'', cascade => TRUE);
    We run a script nightly which works out which indexes require a rebuild and rebuild those only it doesn;t just rebuild all indexes.
    It would be nice to be able to use the 10g statistics history, but on this instance we aren't yet at that version, hopefully we will be there soon though.
    Hope this helps,
    Kieron

Maybe you are looking for

  • ORA- 600 internal error code : [17070],[],[],[],[]

    Hi All, We have observed this error in a production database. ORA-00600: internal error code, arguments: [17070],[],[],[],[],[],[],[] Can any of you kindly through some light on this issue. When does this error with this argument arise? What is the r

  • Down payment request against PO

    Hi SAP Guru, When user entering down payment request in F-47 against  a purchase oder the system is allowing to post the amount more than PO value which is logically incorrect. How can I prevent this ? Kindly reply with details. Regards, Sajib

  • Connecting A imac w/ a WRT54G Wireless Router

    OK I have an imac but i want to have internet on it. I have a wrt54g wireless router. how can i get my imac to have the internet on it as well. BTW i lost the cd that came with it.

  • LR3 error messages

    I have been successfully using LR3 until a few hours ago. Suddenly Error messages now start to appear saying an error occurred sending this file : access is denied I have uploaded files on LR3 30 times today! without any issues I have uninstalled and

  • Can product costing be used in service industry?

    where a material master is being maintained (type DIEN) for services provided, can product costing be used for services?  what pre-requisites are essential to implement product costing?