Which sorting algorithm Oracle use?

Hi ,
May i know which sorting algorithm oracle use ?
Because when i am using order by with an sorted or unsorted data it is taking same time.
Thanks in advance

Pradeep Dewani wrote:
Hi ,
But i want to know that whether oracle consider sorted and unsorted data in same way or not ?
Please help if any body know because i cant decrease number of rows but i can sorted them in a temp table .Pradeep,
a SORT is usually an additional operation that can be quite costly depending on the amount of data to sort and the available memory for sorting. It would show up in the execution plan as SORT operation.
Note that the optimizer can take various shortcuts to minimize the impact of a sort operation. If you e.g. use a "top-N" query properly, it can take advantage of a "SORT ORDER BY STOPKEY" operation that only keeps the top N rows sorted in memory.
If you have suitable indexes, the optimizer might also come to the conclusion that a SORT operation can be eliminated by traversing an index in the requested order, so you could have a query that uses an ORDER BY but the execution plan doesn't show any explicit SORT operations.
So to answer your question: Oracle doesn't consider sorted and unsorted data in the same way. Sorting is an additional operation that needs to be handled somehow.
If you have a query that takes the same time whether sorted or not the execution time is probably driven by other factors and the SORT operation is negligible in terms of performance.
But there are other scenarios possible where a SORT operation takes significant time and influences the execution time. SORTs can also lead to overall changes in the execution plan that are not directly related to the SORT operation.
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/

Similar Messages

  • Which network is Oracle using for RAC traffic ? where you will get info ? ?

    Hi,
    I am using two node RAC on Oracle 10g R2 (10.2.0.3.0) version on SUN Solaris 10 . I want to know "Which network is Oracle using for RAC traffic ? where you will get info "
    --Kumar                                                                                                                                                                                                                                                                                                                                                                                           

    Hi Kumar,
    In 10g, you can query x$ksxpia. If the cluster_interconnect information is stored in OCR (default), you will get
    SQL> select INST_ID,PUB_KSXPIA,PICKED_KSXPIA, NAME_KSXPIA,IP_KSXPIA from x$ksxpia;
    If you specified the cluster_interconnects parameter in your init.ora:
    Columns to look in : INST_ID P PICK NAME_KSXPIA IP_KSXPIA
    And also you can use 'oradebug ipc' to see which interconnects the database is using:
    SQL> oradebug setmypid
    SQL> oradebug ipc
    Hope it helps...
    Thanks
    LaserSoft

  • What algorithm is used to Sort Photos?

    I've read a LOT of posts asking about the sorting order for photos within an album.
    No one has yet to provide an accurate answer about the sorting algorithm/method used. Some people say to use iPhoto (I have a PC so I can't) which isn't an answer. Other people refer to editing some metadata. No one seems to be answering the main question:
    What data is used to sort photos?
    File Name (alphabetical) ?
    File creation date?
    File modified date?
    Size?
    Type?
    Some (hidden) tag like an mp3 has?
    It's gotta be something!
    What is it?

    Well, I figured it out.
    It uses the Created Date to sort files.
    On my PC, I use a freeware program called AttributeMagicFree
    to change the created date and now sorting works as I expect.
    http://www.elwinsoft.com/atm.html

  • Sorting algorithm ?

    what is the sorting algorithm used in Collection.sort ?
    Its not clear what sorting algorithm is used in Collection.sort
    http://download.oracle.com/javase/1.4.2/docs/api/java/util/Collections.html
    Can anybody throw some light on this ?

    roy wrote:
    It works on binary search algorithm.No.
    Binary search requires that the list already be sorted. You don't use binary search to do the sorting.
    This algorithm has two forms. The first takes a List and an element to search for (the "search key"). This form assumes that the List is sorted in ascending order according to the natural ordering of its elements. The second form takes a Comparator in addition to the List and the search key.The second form also assumes the list is sorted--according to the rules of the comparator.

  • In which trigger can i use go_item() in oracle forms 6i?

    Hi,
        I have a problem with go_item.
    I tried executing go_item() in triggers like key_next_item, pre_text_item, post_text_item & when_validate_item.
    But none of them seemed to be working.
    I searched for other possibilities in the site, where i found a solution of using trigger ' when_timer_expired ' with ' when_validate_item ' ,
    but when i tried to create trigger, i did not find that trigger (when_timer_expired)  in the list at all.
    I'm using oracle form builder 6i.
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production.
    A trigger with go_item() must be created when tab is pressed.
    In which trigger can i use go_item() ??
    Thank You.

    from help:
    Restricted Built-in Subprograms
    Restricted Built-ins affect navigation in your form, either external screen navigation, or internal navigation. You can call these Built-ins only from triggers while no internal navigation is occurring.
    Restricted Built-ins cannot be called from the Pre and Post triggers, which fire when Oracle Forms is navigating from object to another.
    Restricted Built-ins can be called from the When triggers that are specific to interface items, such as When-Button-Pressed or When-Checkbox-Changed. Restricted Built-ins can also be called from any of the When-New-"object"-Instance triggers and from key triggers.
    Unrestricted Built-ins do not affect logical or physical navigation and can be called from any trigger.
    The Built-in descriptions include a heading, Built-In Type, that indicates if the Built-in is restricted or unrestricted.

  • Which driver should I use for Oracle RAC .....

    We are using Weblogic 8.1 sp2 and Oracle RAC (9.x). Which driver , I should
    use : i.e.
    type 2 Orcle thin driver
    or
    type 2 Oracle OCI driver
    or
    type 4 oracle thin driver
    or
    Jdrivers
    or other which is best for this configuration .
    Sanjeev

    Thanks. I was unaware of that forum.
    Joe
    Galen Boyer wrote:
    On Tue, 06 Jul 2004, [email protected] wrote:
    Galen Boyer wrote:
    Joe, I have always suggested that people use the OCI driver
    unless it won't suffice based on distribution requirements.
    How come you choose the thin driver? Oracle will generally
    fix the OCI driver before the thin and the OCI driver will
    give far superior performance when dealing with LOBs.We have actually had faster response getting thin driver fixes
    than OCI-based fixes. Thats interesting. I'll take note of it.
    The 10g driver works with RAC, is much faster than previous
    drivers, and is easier to install etc. OCI users are often
    hopeful about TAF, which is broken and less-than-useless for
    active complicated JDBC applications. OCI problems can bring
    down the whole JVM and are harder to debug.
    These are from reading the results and recommendations of
    Oracle Corporation, Tom Kyte and other Oracle professionals.
    Have you research to say different? I'd like to see it,
    because up until now, I've always suggested OCI first unless
    the client doesn't have an oracle client installation
    available.Tom does an excellent job from the DBMS perspective, but I
    don't see him often in the jdbc arena.His Q&A site is littered with jdbc examples. He also will call
    on people in specific expertise to help him answer questions.
    Here an example of that where he show the OCI driver to be much
    more performant.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:9561536906412728184::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:1004630777647,

  • Which structure is Oracle NoSQL used default? BTree or Hash ?

    Hello,
    Which structure is Oracle NoSQL used default? BTree or Hash ?
    Thank you for your answers.

    Oracle NoSQL Database uses Berkeley DB Java Edition as the storage engine. BDB JE only has a b-tree access method.
    Charles Lamb

  • Hi how to find runtime for sorting algorithms

    I am new to java.......please help me out by taking a sorting algorithm and find the run time of it ......
    Thanks in Advance

    If by "runtime" you just mean the amount of time it takes to execute across some set of input...then you can use java.lang.System.currentTimeMillis() to get the current time in milliseconds since Jan 1 1970. Do that both before and after you run the code that implements the algorithm, and subtract to get the difference as running time in milliseconds. Or, if this weren't part of a homework assignment, you could just use a profiler.
    If by "runtime" you mean the execution environment, then you want to use java.lang.Runtime.getRuntime(). This has nothing to do with algorithms.
    If you mean that you want to analyze the efficiency of the algorithm (eg it's "big-O" notation), then read a textbook on algorithms. This has nothing to do with Java, apart from that Java is just one computer language out of many in which algorithms can be implemented.

  • Sorting a vector using the selection sort method

    I have to write a program that sorts a Vector using the selection sort algorithm. Unfortunately the textbook only has about 2 pages on vectors so needless to say I'm pretty clueless on how to manipulate vectors. However I think I'm on the right path, however I'm stuck on one part as shown in the code below.     
    private static void  selectionSort(Vector parts)
          int index;
            int smallestIndex;
            int minIndex;
            int temp = 0;
            for (index = 0; index < parts.size() - 1; index++)
              smallestIndex = index;
              for (minIndex = index + 1; minIndex < parts.size(); minIndex++)
               if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex))  // this is where I'm having trouble
                  smallestIndex = minIndex;
                parts.setElementAt(temp, smallestIndex);
                parts.setElementAt(smallestIndex, index);
                parts.setElementAt(index, temp); if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex))
    is returning "ProcessParts3.java:51: operator < cannot be applied to java.lang.Object,java.lang.Object"
    Here is the full program:
    import java.util.*;
    import java.io.*;
    public class ProcessParts3
         static Vector parts;
         public static void main(String[] args)
              loadVector();
         private static void loadVector()
         try
              Scanner fileIn = new Scanner(new File("productionParts.txt"));
              parts = new Vector();
              String partIn;
              while (fileIn.hasNext())
                   partIn = fileIn.nextLine();
                        parts.addElement(partIn.trim());
              selectionSort(parts);
                   for (int i = 0; i < parts.size(); i ++)
                   System.out.println(parts.elementAt(i));
         catch(Exception e)
              e.printStackTrace();
         private static void  selectionSort(Vector parts) //from this part down I'm responsible for the coding, everything
                                                               // everything above this was written by the teacher
                 int index;
            int smallestIndex;
            int minIndex;
            int temp = 0;
            for (index = 0; index < parts.size() - 1; index++)
                smallestIndex = index;
                for (minIndex = index + 1; minIndex < parts.size(); minIndex++)
                    if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex))
                        smallestIndex = minIndex;
                parts.setElementAt(temp, smallestIndex);
                parts.setElementAt(smallestIndex, index);
                parts.setElementAt(index, temp);
    }Edited by: SammyP on Nov 27, 2009 11:43 AM

    SammyP wrote:
    I have to write a program that sorts a Vector using the selection sort algorithm...Hmmm.... Your teacher is, in my humble opinion, a bit of a tard.
    1. Vector is basically deprecated in favor of newer implementations of the List interface which where introduced in [the collections framework|http://java.sun.com/docs/books/tutorial/collections/index.html] with Java 1.5 (which became generally available back in May 2004, and went end-of-support Oct 2009). ArrayList is very nearly a "drop in" replacement for Vector, and it is much better designed, and is marginally more efficient, mainly because it is not syncronised, which imposes a small but fundamentally pointless overhead when the collection is not being accessed across multiple threads (as is the case in your program).
    2. Use generics. That "raw" Vector (a list of Objects) should be a genericised List<String> (a list of Strings)... because it's compile-time-type-safe... mind you that definately complicates the definition of your static sort method, but there's an example in the link... Tip: temp should be of type T (not int).
    Note that String implements [Comparable<String>|http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html], so two String's can safely be compared using the compareTo method... In Java the mathematical operators (<, >, &#43;, -, /, &#42;, etc) are only applicable to the primitive types (byte char, int, float, etc)... The Java Gods just chose to muddy the waters (especially for noobs) by "overloading" the &#43; operator for String (and String only) to enable succinct, convenient string-concatenation... which I personally now see as "a little bit of a mistake" on there part.
         private static void  selectionSort(Vector parts)  {
    int index, smallestIndex, minIndex, temp = 0;
    for (index = 0; index < parts.size() - 1; index++) {
    smallestIndex = index;
    for (minIndex = index + 1; minIndex < parts.size(); minIndex++) {
    if (parts.elementAt(minIndex) < parts.elementAt(smallestIndex)) {
    smallestIndex = minIndex;
    parts.setElementAt(temp, smallestIndex);
    parts.setElementAt(smallestIndex, index);
    parts.setElementAt(index, temp);
    }3. ALLWAYS use {curly braces}, even when not strictly necessary for correctness, because (a) they help make your code more readable to humans, and also (b) if you leave them out, you will eventually stuff it up when you insert a line in the expectation that it will be part of the if statement (for example) but you forgot to also add the now mandatory curly-braces... This is far-too-common source of bugs in noob-code. Almost all professionals, nearly allways allways use curly braces, most of the time ;-)
    4. Variable names should be meaningful, except (IMHO) for loop counters... Ergo: I'd rename index plain old i, and minIndex to plain old j
        for ( int i=0; i<list.size()-1; ++i) {
          int wee = i; // wee is the index of the smallest-known-item in list.
          for ( int j=i+1; j<list.size(); ++j ) {Cheers. Keith.
    Edited by: corlettk on 28/11/2009 09:49 ~~ This here fraggin forum markup friggin sucks!

  • Quick Searches sort algorithm

    Hello,
    I'm defining some Quick Search queries to be used in Agent Inbox (through SAP Menu>Interaction Center>Administration>Agent Inbox>Define Quick Searches (CRMC_IC_AUI_QUICKS)
    There is field for defining 'Special Sort' for search results which can be used to define sort algorithm in addition to default options.
    My question is, how can I define sort algorithm? I think it is some xml algorithm but I have no idea how? Does anyone have any examples?
    Thanks,

    Hi John,
    Thanks for your response. I saw page 48 in the Inbox FAQ doc. It does talk about method for Custom sort by doesn't say anything about how?
    I need more details. Someone mentioned that we can write xml sort queries in Custom sort field but I'm looking for more information on how it can be done.
    Thanks,

  • Would this sorting algorithm work?

    I'm writing a sorting algorithm for a class that implements the Comparable interface. The class (called Memo) has a field, 'entryDate' of type 'Date', which itself has int fields for day, month, and year. I want to have the class sorted by date, earliest to latest, and then (for entries on the same day) by 'priority' (a field of type int; can be 1, 2 or 3).
    The one I've written seems to work based on a few tests, but I just want to make sure it will work all the time:
    (btw, i have to use the 'getEntryDate()' method because entryDate is a private field in the Memo class' superclass.
    public int compareTo(Memo memo)
    int comparison = getEntryDate().getYear() - memo.getEntryDate().getYear();
    if(comparison != 0) {
    return comparison;
    comparison = getEntryDate().getMonth() - memo.getEntryDate().getMonth();
    if(comparison != 0) {
    return comparison;
    comparison = getEntryDate().getDay() - memo.getEntryDate().getDay();
    if(comparison != 0) {
    return comparison;
    return priority - memo.priority;
    }

    Generally when you simply subtract one int value from another in the compareTo() method, you'll have to take care that you don't run into an overflow situation (because comparing Integer.MIN_VALUE and (Integer.MIN_VALUE-1) would result in unpleasant surprises otherwise). But in your case you can probably safely assume that all your values are well within the safe range for int.
    Also: If you have the chance to modify the Date chance I'd simply make the Date implement Comparable<Date> and delegate that comparison to the Date class.
    Also: are two Memos at the same date with the same priority considered equal? Don't they have any other fields? It's important that objects that are not equals (i.e. a.equals(b) returns false) don't compare to be the same (i.e. a.compareTo(b) should only return 0 iff a.equals(b) returns true). Otherwise you might run into situations where objects are silently dropped because some Collection classes consider them to be equal (SortedSet implementations are tricky here).

  • New sorting algorithm�

    It�s still under development, but it�s gonna be big!
    http://www.ninjasort.com/

    Is there a lower bound for sorting? A sorting
    algorithm based on comparing elements with each other
    has a theoretical lower bound of O(n log(n)). That is
    not too hard to prove (typical homework in an
    algorithms course)...
    So to beat O(n log(n)) you have to do something other
    than comparing the elements with each other!Simple (using pseudo code)....
        Array sortArray(Array a)
            return a;
        }Sorting is only problem and limited when the data is not sorted in the first place.
    It is all in the assumptions.
    There are other problems that not knowing the assumptions can cause. For instance when someone tries to implement a binary sort on data which only lives on the hard drive.

  • Best sorting algorithm

    What would be the best sorting to algorithm for a list that is probably 90% sorted? I assume that quick sort wouldn't be the most efficient in this case.
    EDIT: the list is made of strings. So i don't think any of the linear sorts will work.
    Also, what sorting algorithm does Collections.sort() use?

    Quote from the javadocs:
    The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n log(n) performance.
    http://java.sun.com/javase/6/docs/api/java/util/Collections.html#sort(java.util.List)

  • Help needed with variable - trying to get data from Oracle using linked svr

    Sorry if I posted this in the wrong forum - I just didn't know where to post it.
    I'm trying to write a simple stored procedure to get data from an oracle database via a linked server in SQL Enterprise manager. I have no idea how to pass a variable to oracle.
    Here's how I would get the variable in SQL:
    declare @maxkey INTEGER
    select @maxkey= MAX(keyfield) from [server].Data_Warehouse.dbo.mytable
    select * from [server].Data_Warehouse.dbo.mydetailtable where keyfield=@maxkey
    the select statement I need to do in oracle would use that variable like this:
    select * from OPENQUERY(OracleLinkedServer,'select
    * from ORACLEDB.TABLE where keyfield > @maxkey')
    and I get this message: OLE DB provider "OraOLEDB.Oracle" for linked server "OracleLinkedServer" returned message "ORA-00936: missing expression".
    I realize that I can't pass the @maxkey variable to oracle - so how do I accomplish this?

    Please refer the example in this link which deals with Oracle date format.
    You can finnd a command DECODE which is used for date formats. If you have a look at whole theory then you will get an idea.
    Link:[Bulk insert SQL command to transfer data from SAP to Oracle|http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bulk-insert-sql-command-to-transfer-data-from-sap-to-oracle-cl_sql_connection-3780804]

  • How can I tell which clips are currently used in a sequence

    In the Project window there is a list of clips I have loaded, but often I lose track of which clips are currently used in the sequence.  In Premiere Elements there was a green check next to clips you have used in the timeline, but I don't see any indication of which clips are currently used in the sequence/timeline I am editing.
    Is there some way to sort the loaded clips so that the ones in use all appear first followed by those clips not currently being used in the timeline/sequence.  Is there some indication I am missing showing me whether or not a clip I have loaded is currently being used or not?
    -Roger Uzun

    This isn't really a sorting mechanism, but you can see how many times a clip is used, where it's used, and then navigate to it using the following non-descript button:
    You need to have a clip selected in the Project Panel to see this information, of course. Once you click the disclosure triangle, you'll see the list of sequences and the times where the clip is used; if you select one of those references, the sequence will come to the front in the Timeline panel, and the CTI will park at its in point.
    Again, not a sorting means, but it might be helpful in some instances.

Maybe you are looking for