Does sql sql efficiency depend on order of join predicate?

hello experts,
I trying to under stand the explain plan , I read the link
http://savvinov.com/2012/06/11/sql-efficiency/
Example 3: The inefficiency is coming from the wrong join order, where the bigger row source is taken as the driving table.
please explain.
thanks
yahs

Hi Nikolay,
What matters is the order in which a join is executed, not the order in which you specify join conditionsHmmm. Not really in all cases.
As jonathan Lewis pointed it out in the following article
http://jonathanlewis.wordpress.com/2010/12/15/join-surprise/#more-5104
With multi-column joins, the order of the join predicates can make a big difference to the way Oracle operates a merge join
Best regards
Mohamed Houri
www.hourim.wordpress.com

Similar Messages

  • Why does SQL execute inner selected functions again in the outer select?

    Hi,
    Why does SQL execute inner selected functions again in the outer select?
    Given:
    CREATE OR REPLACE FUNCTION K_TEST
    RETURN NUMBER IS
    BEGIN
    RETURN 1;
    END;
    SELECT K_TEST, K_TEST FROM DUAL;Will (logically) execute the function twice.
    SELECT intest, intest
    FROM (SELECT K_TEST intest FROM DUAL);Will execute the function twice too!
    Why can't SQL buffer the inner result?
    Does anyone have an idea on how to achieve executing the function only once? My original called function is quite heavy and returning a user defined type. Adding predicates, the function is executed 3 or 4 times!
    Thanks for any tips,
    K.

    Hello
    Depending on your version of Oracle, Sub query caching could help....
    XXXX> create sequence seq_1
      2  /
    Sequence created.
    Elapsed: 00:00:00.07
    XXXX> CREATE OR REPLACE FUNCTION K_TEST
      2  RETURN NUMBER IS
      3
      4      ln_Ret  NUMBER;
      5
      6  BEGIN
      7      SELECT
      8          seq_1.NEXTVAL
      9      INTO
    10          ln_Ret
    11      FROM
    12          dual;
    13
    14      RETURN ln_Ret;
    15  END;
    16  /
    Function created.
    Elapsed: 00:00:00.60
    XXXX>
    XXXX> SELECT K_TEST, K_TEST FROM DUAL;
        K_TEST     K_TEST
             1          2
    1 row selected.
    Elapsed: 00:00:00.06
    XXXX> SELECT K_TEST, K_TEST FROM DUAL;
        K_TEST     K_TEST
             3          4
    1 row selected.
    Elapsed: 00:00:00.01
    XXXX> SELECT intest, intest
      2  FROM (SELECT K_TEST intest FROM DUAL);
        INTEST     INTEST
             5          6
    1 row selected.
    Elapsed: 00:00:00.10
    XXXX> SELECT
      2      intest,intest
      3  FROM
      4      (
      5          SELECT (SELECT K_TEST FROM dual) intest
      6          FROM
      7          dual
      8
      9      )
    10  /
        INTEST     INTEST
             7          7
    1 row selected.
    Elapsed: 00:00:00.03
    XXXX> /
        INTEST     INTEST
             8          8
    1 row selected.
    Elapsed: 00:00:00.01THis last example takes advantage of a specific optimisation for calling functions in a subquery. Not sure if it would suit your circumstance though...
    Alternatively - again depending on your version - you might be able to look at function result caching...
    HTH
    David
    Edited by: Bravid on Feb 1, 2012 12:32 PM

  • Does SQL Developer Data Modeler fit-in??

    Hi Everyone,
    Wish you happy new year 2011.
    Does SQL Developer Data Modeler support conceptual, logical and physical in our modeling or only logical and physical?
    We all use Erwin for modeling. Erwin works without database repository storing models in desktop folders and provide additional reporting. I find some place SQL Developer Data Modeler talked about repository need.
    Does SQL Developer Data Modeler store the models in local/network folders instead of Database server?
    What are the functions need database based repository to work with SQL Developer Data Modeler?
    We are thinking of using SQL Developer Data Modeler for our conceptual, Logical, and data dictionary need. Will it help in our need?
    Do we need to face any surprises on using SQL Developer Data Modeler for our need?
    Thanks in sharing your experience and helping me out.
    RI

    1) Do we need to have Oracle database at back end to work with SQL Developer Data Modeler?No, Data Modeler use Oracle database only if you create reporting repository.
    Data Modeler is free, you need database license only if you want to log service request
    2) Will SQL Developer Data Modeler create any tables (as backend repository ) in Oracle database to store Model details? no
    3) Do we need to create reporting schema in backend oracle database to generate reports of SQL Developer Data Modeler's items such as Entity/attributes etc?no, reports can be created out of current loaded design. However having reporting repository will give you additional benefits - history (reports can be generated for every snapshot of your designs there) and multi-user usage, you can create your own reports
    4) Do we to use SQL Developer Data Modeler reverse engineer from DB2, SqlServer, Terra data etc?Data Modeler has full support for Oracle, DB2/390, DB2/UDB(LUW) and MS SQL Server. Reverse engineering from other databases (including Terra Data) is at generic JDBC level - you'll get some and some will be missing (no check constraints for example).
    You can read release notes http://www.oracle.com/technetwork/developer-tools/datamodeler/ea2-releasenotes-185793.html
    Philip

  • Help: PL/SQL passing paramter to ORDER BY clause

    I am working on a procedure that using a parameter to pass sorting order. If there parameter, say p_order which is varchar2, can I just use the it directly passing the field name to the order by clause?
    What I really want to know is that do I have to use decode together with p_order to achieve the goal?
    WJH

    Hi,
    The positional notaion in ORDER BY, e.g.
    ORDER BY 2, 1is one of the rare cases in which a numeric literal is required. Using an expression, even a bind variable, won't raise an error, but won't sort, either. (It's equivalent to sorting by a constant, which doesn't sort at all.)
    Like Centinul said, you have to use dynamic SQL to construct the ORDER BY clause, or use some kind of IF-THEN-ELSE logic (such as CASE), like this:
    SELECT    ename, sal
    FROM      scott.emp
    ORDER BY  CASE
                  WHEN  :x = 1  THEN ename
                  ELSE  TO_CHAR (sal, '000000')
              END;

  • Does sql server could export a partition from a partition table ?

    Dear :
       Does sql server could export a partition from a partition table ? 
      For example, I need to export all old partition,which is '2013' and drop them.  It is easy in oracle. but how to do with sql
    server 2012 ?

    where do you want it to be exported to? Another server instance? if yes you can do piecemeal restore if partition is in a separate filegroup and you're on full recovery model
    http://msdn.microsoft.com/en-IN/library/ms177425.aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • What does SQL write to that allow changes to be undone or rolled back in case of a system failure?

    What does SQL write to that allow changes to be undone or rolled back in case of a system failure?

    What does SQL write to that allow changes to be undone or rolled back in case of a system failure?
    Hello,
    If i read your question correctly you are asking about how uncommited transaction are rolled back.For this, concept of transaction log came into picture.where first changes were first made to transaction log and then into memory .Before any change is made
    to real data file change is made to trn log files so that if rollback comes it can see in log and rollback it.
    I would suggest you to read Famous article by log which will explain you
    http://technet.microsoft.com/en-us/magazine/2009.02.logging.aspx
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Does SQL developer plan to support TFS?

    our developing team uses MS Team Foundation Server as our primary source control / version control software. Does SQL developer planning to give a plug-in to support this? The PL/SQL developer could let us us MSSCCI provider to connect to TFS, I would like to know if Oarcle's SQL developer support the same.
    Thanks!

    Although unlikely, you can always request this at the SQL Developer Exchange, so other users can vote and add weight for possible future implementation.
    Regards,
    K.

  • Does Sql Server compartible with Citrix version 6.5 .?

    Does Sql Server compartible with Citrix version 6.5 .? provid link

    Hi Piya Sahu,
    You post the same question 3 times. Please avoid this practice on Forum, I 
    have merged the same thread. Thanks for your understanding.
    As other post, Citrix supplies to ensure compatibility with upcoming database releases. The following databases are supported for the XenApp data store, for example, Microsoft SQL Server 2005 SP4, Microsoft SQL Server 2008, and Microsoft SQL Server 2008R2
    and so on.
    For more information, you can review the following article about System Requirements for Citrix XenApp 6.5.
    http://support.citrix.com/proddocs/topic/xenapp65-w2k8/ps-system-requirements-w2k8-xa65.html
    There is an detail about hardware and software requirements for installing SQL Server. You can review it.
    http://msdn.microsoft.com/en-us/library/ms143506(v=sql.90).aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Does SQL Developer support OS Authentication?  Will it?

    Does SQL Developer support OS Authentication connections? If not will it in the future?

    Given this has the SQL Developer been changed to remove the requirement of adding a password for an OS authenticated account? These users also have the ability to access the DB via applications and the fact that they don't have to enter a password right now is ideal. I really don't want to have to add a password for them. Will this be changed within SQL Developer?

  • Does SQL 2008 r2 DB backup file will run in SQL 2008

    Shifting my Data base need to confirm does SQL 2008 r2 DB backup file will run in SQL 2008

    It's not possible as they have different version numbers and there is not backword compatibility.
    Please refer similar thread:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/4daae3e5-15ab-4929-a122-e1bab420310e/backup-sql-server-2008-r2-restore-on-sql-2008
    Blog:
    http://www.mssqltips.com/sqlservertip/2810/how-to-migrate-a-sql-server-database-to-a-lower-version/
    Cheers,
    Vaibhav Chaudhari
    [MCTS],
    [MCP]

  • How to delete a row from a SQL Server CE Table with multiple JOINs?

    I want to delete a record from a SQL Server CE table.
    There are 3 tables scripts, options and results. I would like to remove a record from the results table. The where clause contains dynamic information which retrieved via other queries to different tables in the same database. These queries work fine and deliver
    the desired data.
    The Compact server is a clone of a remote table created using the sync framework. The same query to the remote table works fine.
    The error I get is:
    There was an error parsing the query. [ Token line number = 1,Token line offset = 10,Token in error = from ]
    The code that throws the exception is as follows:
    Dim connLoc As SqlCeConnection = New SqlCeConnection(My.Settings.ConnectionString)connLoc.Open()     Dim strDel As String = "Delete r from ResultsTable r inner join OptionsTable o ON o.TestName=r.TestName inner join ScriptTable c ON r.TestName=c.TestName WHERE r.TestName = '" & ds1Loc.Tables(0).Rows(0)(1) & "' AND [Index] = '" & lstIndex & "'"Dim cmdDel As SqlCeCommand = New SqlCeCommandcmdDel.CommandText = strDelcmdDel.Connection = connLoccmdDel.ExecuteNonQuery()
    The values held in ds1Loc.Tables(0).Rows(0)(1) and lstIndex are
    correct so should not be the problem.
    I also tried using parameterised queries
    Dim strDel As String = "Delete r from [ResultsTable] r inner join [OptionsTable] o ON o.TestName=r.TestName inner join [ScriptTable] c ON r.TestName=c.TestName WHERE r.TestName = @TestName AND [Index] = @lstIndex"
    Dim cmdDel As SqlCeCommand = New SqlCeCommand        cmdDel.CommandText = strDel       
    With cmdDel.Parameters           
    .Add(New SqlCeParameter("@TestName", ds1Loc.Tables(0).Rows(0)(1)))           
    .Add(New SqlCeParameter("@lstIndex", lstIndex))       
    End With 
    cmdDel.Connection = connLoc        cmdDel.ExecuteNonQuery()
    I have tried replacing the "=" with "IN" in the the WHERE clause but this has not worked.
    Is it the join that is causing the problem? I can do a select with the same search criteria and joins from the same database.
    Also this query works with SQL Server. Is it perhaps that SQL CE does not support the Delete function the same as SQL Server 2008? I have been looking at this for a while now and cannot find the source of the error. Any help would be greatly appreciated.

    Hello,
    In SQL Server Compact, we can use join in FROM clause. The DELETE statement fail may be caused by the FOREIGN KEY constraint.
    Please refer to:
    DELETE (SQL Server Compact)
    FROM Clause (SQL Server Compact)
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Can I pre-order Iphone 5 from apple website and does it cost extra to pre-order?

    Can I pre-order Iphone 5 from apple website and does it cost extra to pre-order?

    your bound to get a long line up where ever you are near an official apple store, but if youtr planning on getting by one of your carreirs it depends where you live as i was able to get iphone on the day it was released at my carriers store, though im exploring other options atm, whether it worth buying it out on apple store, work out my average data usage and just buy data packs for like $5 - $20, but no idea what atm.

  • The list of extensions for InDesign now have a yellow triangle warning symbol in front of a good many of the extensions and when moused over i get one of two messages:  "Extensions may not function properly because it does not meet the dependency conditio

    The list of extensions for InDesign now have a yellow triangle warning symbol in front of a good many of the extensions and when moused over i get one of two messages:
    "Extensions may not function properly because it does not meet the dependency condition."
    OR
    Extension Status is not consistent with extension set configuration."
    The reason I opened the Extension Manager in the first place was to check to see if I had installed a third party extension.  And I was presented with these warning symbols.  I haven't added anything, I haven't done anything that would cause this.
    Does anyone know how to fix this???
    I am running OSX 10.9.5; Indesign CS6 version 8.0.2 And Adobe Extension Manager version  6.0.8.28.
    Thanks in advance!
    Nina

    Many InDesign pre-installed extensions (Those extensions you have immediately after InDesign installation) define dependency rules in their mxi files. Dependency means that one extension works well only if one or more other extensions are installed and enabled. If this condition is not met, the yellow triangle warning will be shown.
    You can select an extension with warning, click "Advanced" tag page in the lower right panel. You will see "This extension has dependency on: <extension name> ...". Check whether every extensions listed here are available and enabled. If not, enable them. Repeat these steps for all the extensions which have warning.

  • Have just down loaded Yosemite over Mountain Lion, Indesign CS5 does not work ( Am dependant on it) although Bridge , Light Room and Elements operate OK How do I solve this rapidly. Can any one help on this issue. Thanks

    Have just down loaded Yosemite over Mountain Lion, Indesign CS5 does not work ( Am dependant on it) although Bridge , Light Room and Elements operate OK How do I solve this rapidly. Can any one help on this issue. Thanks

    Sorry to say it, but I think you can see from Bob's response that there's no way to solve this rapidly.
    Did you take an image of your Mountain Lion install before upgrading to Yosemite? Roll back to that. If you're not in the habit of taking a snapshot of your system before performing operating system upgrades - get in that habit. If you are dependent on anything at all on hour computer, having a reliable backup method in place is essential. If you don't have a Time Capsule, or some other way to run Time Machine onto a disk that's not in your computer, go set that up yesterday.
    If you can't just remove Yosemite and roll back to Mountain Lion for whatever reason, you can partition your drive so that you can install both Yosemite and Mountain Lion on the same drive, and then boot into Mountain Lion when you need to work in CS5. Or you can take your Mountain Lion disc (I assume you have one, no?) and then use it to create a virtual machine in something like VirtualBox to run Mountain Lion from inside Yosemite.

  • User Exit for MSC2n( Batch) while doing a Good receipt for an order

    Is ther any exit to update the Date1 field(MCHA-FVDT1) in MSC2n( Batch) while doing a Good receipt for an order
    Thanks in advance

    Hi Varsha,
    Try these User Exit.
    BATCHCHK  Function Module Exits for Check in Case of Batch Change
    MBCFC010  Propose batch number on Inventory Management item scree
    SAPLCHVW  Batch where-used list
    SAPLMHD1  Shelf life expiration date
    SAPLV01D  Determining the initial status of a batch
    SAPLV01P  Function Module Exits at Time Batches Are Updated
    SAPLV01Z  CFCs for internal batch number assignment
    SAPLV1ZE  CFCs for external batch number assignment
    SAPLV1ZN  CFCs for batch valuation in VB_CREATE_BATCH
    Regards,
    Vijay

Maybe you are looking for

  • Brand New Ipod Touch 4th Generation

    Just opened my new ipod touch 4th generation today. For some reason it will not appear on my devices in itunes! My other devices are fine. I tried all the troubleshooting and nothing is working! I tried uninstalling and reinstalling itunes and nothin

  • Is it possible to export a video at under 500mb???

    I have a 3 minute video that I am trying to export and upload to Vimeo who caps your upload at 500mb. Yet, I can not export a .mov file under 655mb. There is no approx. file size shown for .mov for some reason like there are for other formats, and if

  • How to pass xml data as objects into Database using store procedures

    Hi All,      I don't have much knowledge on store procedure,can anybody help how to pass the xml as objects in Database using store procedure. My Requirement is I have a table with three fields EMPLOYEE is table name and the fields are EMP_ID,EMP_TYP

  • I purchased Adobe Photoshop Elements 13, comes with disks, can I download it instead?

    My new laptop doesn't have a CD rom drive.  I guess I didn't realize this would be a package with disks in it when I ordered online.

  • After Even Process Chain

    I have a process chain ‘B’ scheduled in mode ‘After Event: Z_CHAIN’ How can I see what is ‘Z_CHAIN’? I try to see this with SE37 and SE38 but with out any happy result. Thank you in advance.