A Simpler, More Direct Question About Merge Joins

This thread is related to Merge Joins Should Be Faster and Merge Join but asks a simpler, more direct question:
Why does merge sort join choose to sort data that is already sorted? Here are some Explain query plans to illustrate my point.
SQL> EXPLAIN PLAN FOR
  2  SELECT * FROM spoTriples ORDER BY s;
PLAN_TABLE_OUTPUT
|   0 | SELECT STATEMENT |              |   998K|    35M|  5311   (1)| 00:01:04|
|   1 |  INDEX FULL SCAN | PKSPOTRIPLES |   998K|    35M|  5311   (1)| 00:01:04|
---------------------------------------------------------------------------------Notice that the plan does not involve a SORT operation. This is because spoTriples is an Index-Organized Table on the primary key index of (s,p,o), which contains all of the columns in the table. This means the table is already sorted on s, which is the column in the ORDER BY clause. The optimizer is taking advantage of the fact that the table is already sorted, which it should.
Now look at this plan:
SQL> EXPLAIN PLAN FOR
  2  SELECT /*+ USE_MERGE(t1 t2) */ t1.s, t2.s
  3  FROM spoTriples t1, spoTriples t2
  4  WHERE t1.s = t2.s;
Explained.
PLAN_TABLE_OUTPUT
|   0 | SELECT STATEMENT       |              |    11M|   297M|       | 13019 (6)| 00:02:37 |
|   1 |  MERGE JOIN            |              |    11M|   297M|       | 13019 (6)| 00:02:37 |
|   2 |   SORT JOIN            |              |   998K|    12M|    38M|  6389 (4)| 00:01:17 |
|   3 |    INDEX FAST FULL SCAN| PKSPOTRIPLES |   998K|    12M|       |  1460 (3)| 00:00:18 |
|*  4 |   SORT JOIN            |              |   998K|    12M|    38M|  6389 (4)| 00:01:17 |
|   5 |    INDEX FAST FULL SCAN| PKSPOTRIPLES |   998K|    12M|       |  1460 (3)| 00:00:18 |
Predicate Information (identified by operation id):
   4 - access("T1"."S"="T2"."S")
       filter("T1"."S"="T2"."S")I'm doing a self join on the column by which the table is sorted. I'm using a hint to force a merge join, but despite the data already being sorted, the optimizer insists on sorting each instance of spoTriples before doing the merge join. The sort should be unnecessary for the same reason that it is unnecessary in the case with the ORDER BY above.
Is there anyway to make Oracle be aware of and take advantage of the fact that it doesn't have to sort this data before merge joining it?

Licensing questions are best addressed by visiting the Oracle store, or contacting a salesrep in your area
But I doubt you can redistribute the product if you aren't licensed yourself.
Question 3 and 4 have obvious answers
3: Even if you could this is illegal
4: if tnsping is not included in the client, tnsping is not included in the client, and there will be no replacement.
Tnsping only establishes whether a listener is running and shouldn't be called from an application
Sybrand Bakker
Senior Oracle DBA

Similar Messages

  • [Theory] A simple but hard question about OO programming

    I was in my first class of OO programming (4th year of computer engineering in Valencia) and the professor gave us homework.
    The homework was a simple question about OO programming (it is not about a specific language, though we are going to use Java in the practice sessions), we shall find an answer to it and discuss it in class the next day.
    The question was:
    "May classes also be objects?"
    which can be said as:
    "May classes be instances of an(other) classes?"
    I hope that you, archers, can enlighten me in this question

    tvale wrote:I believe an object is an instance of a class.
    Yup, that's true. Let's see... An object is an instance of a class, so we can have a lot of objects coming from one class.
    We can say an object is not a class because it has a state (think about a light, it has a state: on or off, but a class light is not on/off, because in a class we just describe the behavior that class should have.
    But what we're asking here is if a class can have a state. I think it may refer to static properties about the objects.

  • Round trip workflow with proxies between Premiere and AE / a more general question about how these programs work?

    Hi all,
    I'm new to editing with proxies in Premiere and have some questions about how to handle the relationship with After Effects. Say I have a rough cut (with proxies) and I want to send it to AE to do some effects. The simplest thing to do seems to be to replace the proxies with the originals in Premiere, send the project to AE and do my thing. But if I then want to send the project back to Premiere, it will involve the original files, which are too machine-intensive for me to edit. In theory, it seems like there should be a way to send the project with original footage to AE, do effects, send it back to Premiere, and then replace it with proxies to do further editing while retaining the effects.
    This leads to a confusion about how AE works. When I do an effect, am I correct in assuming that it does nothing to the original file? If that's the case, it seems like it shouldn't matter (in the editing stage) what file AE "applies" an effect to (proxy or original). But I feel like there's a hitch in this workflow. The same question could also be asked about going back and forth in Speed Grade.
    Perhaps there is no real answer to this and the best option is to save effects and grading for after I have picture lock, but sometimes that's not entirely possible or convenient, etc.
    Hopefully this makes some sense—It's a little hard to explain.
    Thanks.

    Hi Mark,
    Here are the specific sections of the manual that should give you the best explanation regarding the Check out/in workflow for FCP projects in Final Cut Server:
    Check out:
    http://documentation.apple.com/en/finalcutserver/usermanual/#chapter=7%26section =5
    Editing:
    http://documentation.apple.com/en/finalcutserver/usermanual/#chapter=7%26section =6
    Check in:
    http://documentation.apple.com/en/finalcutserver/usermanual/#chapter=7%26section =7
    -Daniel

  • Question about Merge Statement

    Is it possible to use a CASE statement inside the update clause of a merge statement? Also what about a function?
    I have a string (In Source) that needs to be split into multiple columns (In Target) depending on values in other columns (In Source).
    I am on 11iR1

    Hi Chris,
    You can take a look at the below examples :
    SQL>create table t_test
    col1,col2,col3
    ) as
    select 1,2,3 from dual union all
    select 2,3,4 from dual union all
    select 3,4,2 from dual union all
    select 9,10,12 from dual union all
    select 11,23,43 from dual
    create table succeeded.
    SQL>select * from t_test;
    COL1                   COL2                   COL3                  
    1                      2                      3                     
    2                      3                      4                     
    3                      4                      2                     
    9                      10                     12                    
    11                     23                     43    
    SQL>merge INTO t_test t_t USING
      SELECT
        1 AS col1
      FROM
        dual
    ) d_d
    ON
    (d_d.col1 = t_t.col1)
    WHEN matched THEN
      UPDATE set
        col2 = (
          CASE
            WHEN d_d.col1 = 1
            THEN 123
            ELSE -1
          END );
    1 rows merged
    SQL>select * from t_test;
    COL1                   COL2                   COL3                  
    1                      123                    3                     
    2                      3                      4                     
    3                      4                      2                     
    9                      10                     12                    
    11                     23                     43                    

  • Question about merging 2 Companies in SAP

    Hi,
    our client wants to merge 2 Companies, the company that is going to disapiar is not in SAP.
    Our approach is to post the account balances and movements into SAP posting them in the SAP Co.COde, ant that is fine, the problem is that they want to get all the legal reporting (P&L, Balance Sheet...) separately for both companies in SAP.
    We think that we could cover that requirement doing:
    1. posting the merged company documents with and specific Doc. type. But we think that a lot of legal reports cannot be filtered/selected using Doc.type. It seems no to work.
    2. the other thing that we have thought is to use "business area", but BA was out of our blue print and we are not sure what can happen creating BA when a CoCode (in fact several CoCodes) are already in production (went live some time ago).
    I will really appreciate if someone can give me any approach about how to meet client's requirements.
    Cheers

    For a legal entity, you need to have separate company codes.
    If it is just the ownership of the company that is being taken over and for all other practical purpose the taken over entity shall be a separate legal entity you can create a company code for the. This is recommended, as the P&L and Balance sheet report is readily available.
    You can do a consolidation later for merging both the companies results. either through ECCS within SAP or SEM-BCS.

  • Very simple and quick question about Arrays

    Hi,
    I have the following code to produce a student grades provessing system. I have got it to store data in the array, i just cant figure out how to add the integers from the row to produce a total. Thats all I want to do create a total from the 6 marks and add a percentage.
    Any help would be greatly appreciated.
    -------------CODE BELOW----------------------
    import java.util.*;
    public class newstudent1_2
    public static void main (String[]args)
    System.out.println ("-----------------------------------------------"); //Decorative border to make the welcome message stand out
    System.out.println (" Welcome to Student Exam Mark Software 1.2"); //Simple welcome message
    System.out.println ("-----------------------------------------------");
    int [][] mark;
    int total_mark;
    int num_students;
    int num_questions = 9;
    Scanner kybd = new Scanner(System.in);
    System.out.println("How many students?");
    num_students =kybd.nextInt();
    mark = new int[num_students][num_questions] ;
    for (int i=0; i<num_students; i++)
    System.out.println("Enter the Students ID");
    String student_id;
    student_id =kybd.next();
    System.out.println("Student "+i);
    for( int j=1; j<num_questions; j++)
    System.out.println("Please enter a mark for question "+j);
    mark[i][j]=kybd.nextInt();
    System.out.print("id mark1 mark2 mark3 mark4 mark5 mark6 mark7 mark8");
    //This section prints the array data into a table
    System.out.println();
    for (int i=0; i<num_students; i++)
    for( int j=0; j<num_questions; j++)
    System.out.print(mark[i][j]+"\t"); //the \t is used to add spaces inbetween the output table
    System.out.println();
    --------------END OF CODE---------------
    Thanks.

    I had to do this same sort of thing for a school assignment but i didnt use an array.
    import java.text.DecimalFormat;
    import TurtleGraphics.KeyboardReader;
    public class grade_avg
         public static void main(String[] args)
              int grade, total = 0, count = 0;
              double avg = 0.0;
              KeyboardReader reader = new KeyboardReader();
              DecimalFormat df = new DecimalFormat("0.00");
         for (;;)
                   grade = reader.readInt("Please enter a grade: ");
              if (grade > 0)
                        total = total + grade;
                        count ++;
              if (grade == 0)
                        avg = total / count;
                        System.out.println("The average is: " + df.format(avg));
                        System.exit(0);
    }output looks like:
    Please enter a grade: 100
    Please enter a grade: 50
    Please enter a grade: 0
    The average is: 75.00

  • More syntax questions about nested symbols

    I have a symbol timeline that does everything I need it to do except to access a function within the stage symbol. I would have thought that calling the function in the stage symbol from a nested symbol (which is loaded dynamically, if that makes any difference) would be something along the lines of:
    sym.getComposition().getStage().gotoNextSlide("slide5");
    but no luck. I can alert the stage itself as [Object Object], which brings up another question. Is there an always-available property of objects that one can alert or trace to make sure the correct object is being targeted? I've had no luck with the symbol's id, name, or symbolName.

    Sure. You've seen one form of the project I'm working on, though I'm at the next speedbump. Here's an excerpt of the involved parts.
    I have the stage symbol and within that symbol, I have a function:
    function gotoSlide(slideName){
              fadeTo(slideName);
    function fadeTo(slideName){
         /// this all works fine, when called from the main timeline
    In the composition, I'm loading slides from the library and on the timeline of one of those slides is the following.
    navHidden = true;
    var trueButton = sym.getSymbol("answers").$("true");
    trueButton.bind('click',goNext);
    function goNext(){
              sym.getComposition().getStage().gotoSlide("slide_05");
    I know there are other syntaxes I could use but refactoring is in the future. The console log I get is:
    Object [object Object] has no method 'gotoSlide'
    It's slide 5 in these:

  • The question about "Merge"

    I created a Sequences (24fps),Captured video and imported audio files.After set inport,I used the command "merge".But that merged clip's inport presented offset--video's inport and audio's inport are not superposed. that's Why?
    waiting your answer.
    ps: video have been conformed.

    Is there a way to merge the 12 movies into one?)
    Import them into iMovie HD and build a sequence with chapter markers.
    What determines the order in which the movies are being played?
    Sequence of you adding them to the main menu.
    tried to view it on a Windows computer
    Seen many problems on Windoze computers. Does it work on your Mac?

  • More specific question about my topic

    public class Item implements Comparable
    private int myId;
    private int myInv;
    public Item(int id, int inv)
    myId = id;
    myInv = inv;
    public int getId(){ )
    public int getInv(){ }
    public int compareTo(Object otherObject){ }
    public boolean equals(Object otherObject){ }
    public String toString(){ }
    public class Store
    private Item[] myStore;
    public Store(String fileName) { }
    public void displayStore()
    public String toString(){ }
    public void doSort() { }
    private void quickSort(Item[] list, int first, int last)
    private void loadFile(String inFileName)
    The first line of file50.txt contains the number of id/inventory integer pairs listed on subsequent lines. The idea behind the data type item is the simulation of an item in a store, nearly all of which use a bar code for identification purposes. For every item in a store we keep track of an id value and an inventory amount. So file50.txt looks like this:
    50
    3679 87
    196 60
    17914 12
    18618 64
    2370 65
    etc. (for 45 more lines)
    Each id value in file50.txt will be unique.
    Assignment:
    Write a program that solves the following sequential events:
    loads the data file, file50.txt, as a collection of Item types maintained in a Store object
    sorts the data using quickSort
    prints the data , now in increasing order based on the id field of an Item object
    The printing should add a blank line after every 10 items in the output. Include a line number in the output. For example:
    Id Inv
    1 184 14
    2 196 60
    3 206 31
    4 584 85
    5 768 85
    6 2370 65
    7 3433 5
    8 3679 87
    9 4329 64
    10 5529 11
    11 6265 58
    12 6835 94
    13 6992 76
    14 7282 73
    15 8303 90
    16 9267 68
    I really have no Idea what to put for getId(), getInv(), and
    the constructor Store
    public Store(String fileName) { }
    please.. please help me..

    Please just stick to the original thread.
    http://forum.java.sun.com/thread.jspa?threadID=699397

  • HT204053 Question about merging two iCloud accounts?

    Before I understood how to use iCloud properly I set up two completely different iCloud accounts (one for work and one for personal) but now I want to merge the two into one. How do I do that and keep all app purchases and all information?

    Unfortunately, you can not merge two accounts. See also: Apple IDs and iCloud FAQ: http://support.apple.com/kb/HT4895?viewlocale=en_US&locale=en_US

  • SOS!! Simple yes/no question about JPA...

    Hello,
    I have the following environment and requirements:
    -Tomcat 5.5 (no ejb container)
    -Latest version of Hibernate
    -JSF 1.1
    -A requirement to use JPA
    -I must use the query cache and the second-level cache
    My question is as follows:
    What is the best solution?
    Solution 1.
    ONE EntityManagerFactory stored in the ServletContext for use by all of my web app users generating MULTIPLE INSTANCES of EntityManagers. (would this allow me to use the query cache?)
    Solution 2.
    ONE EntityManagerFactory and ONE EntityManager stored in the ServletContext for use by all of my web app users.
    Thanks in advance,
    Julien.

    Regarding caching, what exactly are you referring to
    by "query cache"? Are you saying you
    plan to execute the same query multiple times but
    you'd like the underlying persistence manager
    to avoid trips to the actual database? Whether the
    query is executed by an actual database
    access or is fulfilled through some JVM-local cache
    is not controlled by the spec. Most implementations
    do allow for such caching but the behavior is
    persistence-provider specific.Yes. I am actually using hibernate behind the scenes as my persistence framework.
    I'd suggest looking at the presentation from last
    year's JavaOne called "Persistence In the
    Web Tier"
    http://developers.sun.com/learning/javaoneonline/2006/
    webtier/TS-1887.pdfI am going to have a look at that.
    Thanks again.
    Julien.

  • Another question about merging photos

    I am trying to take a person from one photo and p
    lace her in another, The hair selection is what is getting me. She has blond hair and is on a solid background, Is there a way I can remove the background and nmake her hair selection look better. I am new to this so, if anyone knows how to do this, could tou please post instructions. I have Photoshop elements 9.

    Try using the magic selector to select the solid background rather than the subject.
    Then on the top menu click Select >>Inverse
    That will automatically select the subject. Then press Ctrl+J to put the subject on it’s own transparent layer.
    You can then drag in the photo you want to use and place it below the transparent layer.
    Use the move tool to position it.
     

  • Question about self join

    I have a table with the following coloums:
    ANR (NUMBER)
    ART (VARCHAR2)
    NAME
    in ART I have two types 'FA' and 'RG'
    So for example two line out of the DB:
    1; RG; Region Wien
    1; FA; Wien 1
    I want to have a query which gives me the following:
    FA; Wien 1; Region Wien
    Thanks for help,
    Walter

    Untested and not 100% sure what you mean, but....
    select t1.art, t1.name,t2.name
    from your_table t1, your_table t2
    where t1.anr=t2.anr
    and t1='FA;'
    and t2='RG;'

  • Simple (probably dumb) question about Mail --

    After I read a message, how do I go the next message without closing the current message box and going back to Inbox? That is, is it possible to read a message then go to the next one, then the next one, etc. without going back to the Inbox?
    Thanks for any help.
    Sunil

    you can read a message from the message list, by reading in the preview pane. if you do not have the preview pane set on your main window, go to the bottom of the window, you will notice a line with a dot at the middle, drag that dot to the middle of the window or a little higher and drop it. you should now have your main window divided in two, with the upper part showing the message list, and the lower part showing the text of the email you have selected in the message list.
    hope this helps

  • Really simple Mac Mail question about the Delete button

    When at a message, the Edit menu shows Command+Delete as being the proper keystroke for deleting a message.
    Just pressing Delete also removes it from the Inbox.
    What is different between that and Command+Delete?
    Thanks,
    doug

    Hi,
    I don't have a very good answer to you other than the fact that the Macbook does not have a proper DELETE-button.  You delete by pressing cmd/backspace.
    If you want to delete something through Finder you have to press cmd/backspace.  In orher programs, like Mail, you can delete by pressing only backspace.  In iPhoto you can delete pictures by presing backspace and conform with return.
    The reason for these different solutins are not known to me...  
    Nils

Maybe you are looking for

  • Payment document reversal issue

    Hi All, While posting a document I wrongly selected the vendor account.  PO itself the vendor account wrongly entered. And one more thing is the payment is completed. As per SAP members suggestion I have planned to reverse the payment document. Rever

  • Passing dynamic values in WebElements

    Hi I have created a report with webelement using WESelect. For drop down values we are creating a sting of values with allelements.Is there a way i can get the values from a database column or dynamic values. For example a Week WESelect is created wi

  • Restricting select-options

    Hi, I came across this piece of code in ABAP FAQ. It is supposed to restrict the select-options so that the user can enter only specific options like only intervals or single values or patterns etc. But for some reason its not working for me. I am us

  • Problems syncing blackberry storm to new macbook

    Help.  I have downloaded the information that I think is correct for the blackberry to my macbook.  When I sync, what is on my bb is not being transferred to entourage.  What do I need to do to correct this.  Thanks

  • Possible LR CC Instability Fix - This worked for me...

    For those who have upgraded to LR CC and are finding the software to be unstable, are getting gray boxes instead of pictures when filtering images or are finding LR CC is slowing down your computer to a crawl this worked for me.... 1) Go to Pictures/