Order by disk sort porblem

hi friends i have a querry which return 40.000 rows and 2 mb data. this querry works in 1-2 seconds. if i add simple order by to querry it work in 20 seconds.
i think because of disk sort. but i have another querry which have 270.000 row and 8 mb data its dont do disk sort. i write my querry, and in my opinion something force it disk sort instead of ram and row. but i dont find the problem.
thanks
SELECT p.nkisi_uygulama_id, p.nvardiya_id,
          p.dbaslangic_tarih AS dper_vardiya_bas_tarih,
          p.dbitis_tarih AS dper_vardiya_bit_tarih, p.nper_vardiya_id,
          v.nvad AS nvvardiya_ad, v.nvaciklama, v.nvbaslama_saat,
          v.ntoplam_saat, TO_CHAR (d.tarih, 'DAY') AS nvgun,
          TO_DATE (d.tarih || ' ' || v.nvbaslama_saat,
                   'DD.MM.YYYY HH24:MI'
                  ) AS dbaslangic_zaman,
            TO_DATE (d.tarih || ' ' || v.nvbitis_saat,
                     'DD.MM.YYYY HH24:MI'
          + CASE
               WHEN TO_DATE (d.tarih || ' ' || v.nvbitis_saat,
                             'DD.MM.YYYY HH24:MI'
                            ) <
                      TO_DATE (d.tarih || ' ' || v.nvbaslama_saat,
                               'DD.MM.YYYY HH24:MI'
                  THEN 1
               ELSE 0
            END AS dbitis_zaman,
          (SELECT bvardiya_izin
             FROM iky_tnm_vardiya_gun vi
            WHERE vi.nvardiya_id = v.nvardiya_id
              AND TO_CHAR (d.tarih, 'D') =
                     CASE
                        WHEN vi.ntip_gun_id = 781
                           THEN 1
                        WHEN vi.ntip_gun_id = 782
                           THEN 2
                        WHEN vi.ntip_gun_id = 783
                           THEN 3
                        WHEN vi.ntip_gun_id = 784
                           THEN 4
                        WHEN vi.ntip_gun_id = 785
                           THEN 5
                        WHEN vi.ntip_gun_id = 786
                           THEN 6
                        WHEN vi.ntip_gun_id = 787
                           THEN 7
                     END) AS bvardiya_izin
     FROM iky_tnm_vardiya v,
          iky_hrk_per_vardiya p,
          TABLE (pck_iky_func.f_tbl_per_vardiya_zaman ()) d
    WHERE p.nvardiya_id = v.nvardiya_id
      AND d.ID = p.nper_vardiya_id
      AND p.nvardiya_id IS NOT NULL
      AND TO_CHAR (d.tarih, 'D') IN (
             SELECT CASE
                       WHEN g1.ntip_gun_id = 781
                          THEN 1
                       WHEN g1.ntip_gun_id = 782
                          THEN 2
                       WHEN g1.ntip_gun_id = 783
                          THEN 3
                       WHEN g1.ntip_gun_id = 784
                          THEN 4
                       WHEN g1.ntip_gun_id = 785
                          THEN 5
                       WHEN g1.ntip_gun_id = 786
                          THEN 6
                       WHEN g1.ntip_gun_id = 787
                          THEN 7
                    END
               FROM iky_tnm_vardiya_gun g1
             WHERE
                    v.nvardiya_id = g1.nvardiya_id)
ORDER BY nkisi_uygulama_id;

Listen to Billy & Centinul. You'll need to figure out why the query is really slow, and the notes on tuning should help.
Looking at your query: the sorting won't help performance. Make sure it is not sorting to disk (you can use AUTOTRACE in SQL*PLUS or SQL*DEVELOPER for this).
Select list inline views are notorious for a couple of reasons. First, they can decrease performance by executing for every row. Second, under just the wrong conditions their actvity will not show up in execution plans - I just rewrote one as a insert/select from in 10gR2 to PL/SQL and the original execution plan only showed the insert with a cost of 2 (!); this is standard behavior on 9i (in my case I was able to consolidate multiple queries with a possible 50% per-line run time according to dbms_profiler).
Table functions are also problematic for a couple of reasons - they provide needed functionality, but due to the converstion there are no statistics available to effectively plan out the execution by the CBO. The cardinality hint might help this somewhat but you have to hard-code the numbers. Sometimes the despised rule-based optimizer can help with conversions where there are no statistics available but this needs to be examined very carefully
SQL looks so much more impressive when used with foreign languages :)

Similar Messages

  • Need to order recovery disks for g7-1320dx

    I created a usb recovery for my g7-1320dx. It seems this computer, however, can't boot from a usb. Where can I order recovery disks?
    --TIA

    Hi,
    You can order a replacement set of Recovery Discs using the link below.
    Order HP Recovery Discs.
    However your notebook should be able to boot from usb flash drive - unless you've already done so, try the following
    Shut down the notebook. 
    Tap away at the esc key as you start the notebook to enter the Start-up Menu.
    Insert the Recovery USB into a USB 2.0 port. 
    Select Boot options ( f9 ) and see if the usb drive is now detected - if it is, use the arrow keys to select it and hit enter.
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • Loading order of disks

    Just purchased Photoshop Elements 10 and installed 3rd disk first (after installing 1st disk 1st seeing no obvious warning.advice to the contrary) on my Mac. Question is: the 3rd disk appeared to have the entire program, the 2nd disk has a trial version of 64 bit and the first disk has a bunch of stuff I have no idea what it is...does disk 3 contain the entire PSE10 program or do I also need to install disks 1 & 2?

    all I see is "Re: Loading order of disks" and no actual reply to my posting???

  • Multi Disk sorting Screwed up in 11.1.4

    iTunes 11.1.4 OSX 10.9.1
    I have the first 3 audio books of A Game Of Thrones totaling over 90 CD's and over 1000 files!
    When I importen them, iTunes dunped them in the Music Liberary with seperate Disk folder's. I have moved them over the Audio book folder but it has just mashed them all together in one folder!
    How do I get itunes to leave them this kind of sort?
    Book1>Disk 1>Files
    Book2>Disk 1>Files
    Book3>Disk 1>Files
    instead of
    AGOT>everything
    or is this the old itunes multi disk sort bug still not fixed?

    Hi All,
    My issue got resolved by modifying the save button logic..
    In the existing code we are commiting the data in the backing bean using
    getAm().getDBTransaction().commit();
    I just replaced the code with the below commit action from page definition and it started working...
    BindingContainer bc = getBindings();
    oracle.binding.OperationBinding opb = bc.getOperationBinding("Commit");
    opb.execute();
    System.out.println("opb.getErrors() :"+opb.getErrors());
    if(opb.getErrors().isEmpty()){
    But still no clue why it is working...........
    Thanks,
    Rajesh

  • I'm actually trying to find the date i visited a site. adding columns allow the order to be sorted but not show a date. Please tell me it there's a way to see t

    I'm actually trying to find the date i visited a site. adding columns allow the order to be sorted but not show a date. Please tell me it there's a way to see the date. the sidebar no longer has the option for date. the most recent only shows the time.

    If you only see the time then that would mean that you see an entry of the current day (today).
    History items from past days should have the date as well in the Most Recent Visit column.
    You should be able to see this changing if you open the last 7 days folder and scroll down.

  • Difference between ordered by and sorted by?

    hi,
    Can any1 tell me wats the actual difference between ordered by and sorted by???

    Generally speaking, when talking math, one talks about an "ordering" in some set of values. Usually one doesn't actually place them in order; the order is already there, implicit in the values. When talking computer science, one talks about "sorting" because the values may be in a sequence which violates the desired order, and you have to sort the sequence to match the order. "Sorting" isn't as relevant in math because there is no sense of the items being out of sequence when the order is established.
    So "order" describes the ideal (which mathematicians care about).
    "Sort" describes the practical, the activity needed to make the real match the ideal (which computer sciences care about).
    That's my intuitive feeling on it, anyway.

  • Can't order recovery disk for my Pavilion 17-e019dx

    I have accidentally deleted my factory given windows while installing UBUNTU... Now I have again installed Windows 8.1 64bit but it doesn't have the previous softwares and drivers given by HP... But I really need them :/
    I have also deleted my recovery partition  
    I tried to order recovery disks but they are not taking the orders and telling me to order after sometime, but nothing worked... 
    Can anyone tell me how to get my recovery disks? from HP or other websites? :/ 
    This question was solved.
    View Solution.

    Download a copy of Hiren's Boot at Hirensbootcd.org, there is some really good programs in there, use the disk recovery stuffs like government issue or something. I was just messin around with it on a disk I had formatted previously and it brought up all the files that were on it. It may or may not help with all the problems your having but you will love the software belive me. Good luck.

  • I submitted my podcast and I got an email saying error, I checked with the feed validator and got this message: This feed does not validate. line 40, column 6: Undefined item element: itunes:order, how do sort this out, someone help me please.

    I submitted my podcast and I got an email saying error, I checked with the feed validator and got this message: This feed does not validate. line 40, column 6: Undefined item element: itunes:order, how do sort this out, someone help me please.

    Ignore it. 'itunes:order' is a recent addition which FeedValidator doesn't know about. If your podcast is rejected that is unlikely to be the reason. Of course as you haven't posted the feed URL nor the text of the error message I can't make any further comment.

  • Need to order recovery disks, how can I tell if I need 32 or 64 bit without an OS?

    I'm trying to repair someones laptop.  It's a g60 and they dont have recovery disks.  The hard drive has crashed so I can't use windows to find out if i need a 32 or 64 bit version.  HP's website can't determine this by model number, serial or anything and is asking me what version i need when i try to order recovery disks.  It tells me I should use windows to figure this out.  (why would I need to order recovery disks, if windows was still working?????)  Anyway. Any help would be appreciated. Thanks.
    This question was solved.
    View Solution.

    Awesome, thanks.

  • Sort order in iTunes (sort by album)

    Hi!
    What could be the cause that iTunes in this case: http://homepage.mac.com/bhager/sortierung.png doesn't sort the tracks in correct order when sorting by album? In the other cases apparently it works fine.
    Thanks,
    Bensch

    I had this problem when I was viewing the tracks in "Group by Artwork" mode. It would "duplicate" the album and the artwork for every change in Artist.
    Here's a solution if you don't want to rename all the tracks with s single artist (if there is more than one):
    - Select all the tracks in the album
    - Click command + I
    - In the field "Album Artist" enter a single space (" ")
    That's it. All the tracks will be grouped together.
    Enjoy!
    17" PowerBook   Mac OS X (10.4.6)   1.67 Ghz G4, 2 GB RAM

  • How do I get my Music library songs in alphabetical order and not sorted by artist?

    Curious how you can sort your songs by alphabetical order without them being grouped by artist? Having this problem on ipad and iPhone

    Well as far as I can recall, I did nothing special at all when I synced my music to the iPad. I have very few downloaded/purchased songs on the device, but even the very few purchased songs that I have in the Music App are in alphabetical order. The only settings that can be changed on the iPad are in Settings>Music and I don't see anything in there that has any bearing in this. I have Group by Album Artist selected, but that doesn't change the alphabetical order if I toggle it off and on.

  • My Album Order Doesn't Sort Correctly in iTunes

    Hi, I don't know whether anyone can help me with this, but I'd like my albums to sort such that the songs are in the same order in my iTunes as they are on the album. For example, right now I have 3 John Mayer albums in my iTunes and iTunes mixed all the albums up from the CDs such that the right songs don't follow in iTunes. I'm guessing this is not hard to figure out, but I'm a bit of a techno idiot. Thanks for any help someone might be able to provide.
    Thanks,
    Keri
    [email protected]

    Hi, Keri.
    ... I'd like my albums to sort such that the songs are in the same order in my iTunes as they are on the album.
    Generally speaking, that will be the case if you click on the Album column heading in your main iTunes Library display.
    Can you confirm whether or not such is the case?

  • Play Order on Album Sort by Year Funk

    I was super pleased to find that iTunes 9.01 fixed the bug regarding sorting multi-disc albums while sorting album by year.
    However, now I'm noticing that when I'm playing an artist's discography, while sorted by year, instead of playing the albums in chronological order (like they've been visually sorted), it plays the albums in alphabetical order (default sort). So I could be playing an artists' first of five albums, but if the album name starts with a 'Z' then it will just stop the playlist all together, as if the end of said playlist has been reached.
    Also, does anyone else who sorts by year find it annoying that iTunes finds it prudent to always switch back to sorting by album alphabetically whenever I'm not looking? I find that quite annoying.
    Any ideas? Thoughts? Thanks!

    Oh poop. I just updated the two extensions "I Love Stars" and "Cover Stream."
    I'm no longer having problems with my music stopping after 'all' of an artists' music plays 'all' through. But still, anyone else having similar issues?
    Message was edited by: tyPod18
    Message was edited by: tyPod18

  • Performance - using JDBC call with 'order by' vs sorting data on app server

    Hello! I need some valid thoughts on the performance of using a JDBC call versus processing information on the application server.
    Here is the somewhat simplified scenario:
    I need to retrieve customer information (name, e-mail, telephone), display it in HTML format and then be able to redisplay it in a different order. For example, initially the list would be displayed sorted by last name, but then a user might choose to sort it by e-mail address. Initial call to DB uses 'order by' in the SQL stmt to get me the initial ordering by last name. Results are stored in 2D array. However, when a user selects a different sort I have two options:
    1) just make another call to the DB with a different order by clause. This means I need to create a DB connection, connect to DB, retrieve the results and read them from result set into a 2 dimensional array
    2) re-sort data in the 2D array populated during the initial call. This means I need to use java.util.Arrays.sort(my_2D_resultsArray, my_custom_comparator)
    Question is : which is more efficient? Number of entries retrieved can be anywhere from 0 to a few thousands (depending on other filters such as customer's country). My feeling is that option umber 2 is better, but I would like to get your opinion.
    Thank you!

    Good points! Thanks! I ran a test (see code below) and it takes less than a second to sort 2000 Strings and 2000 nulls. The only thing I ran the test at a UNIX prompt as oppose to from within app server (Weblogic). I expect the speed to be compatible though. Do you think that test was valid and tells us that sorting on the app server is probably faster than doing another SQL query?
    import java.io.*;
    import java.math.*;
    import java.util.*;
    import java.util.Arrays.*;
    public class Test {
      public static void main(String[] args) throws Exception {
        Test test = new Test();
        test.testSortingPerformance();
      public void testSortingPerformance() {
        Object[] objArray2 = new Object[]{};
        Vector v = new Vector();
        Date start, end;
        java.util.Random rd = new java.util.Random(2000);
        for (int i = 0; i < 2000; i++){
          v.add(new Object[]{new String("" + rd.nextInt())});
          v.add(new Object[]{null});
        objArray2 = v.toArray();
        Object[] innerObjArray2 = new Object[]{};
        MyComparator2 myComp = new MyComparator2();
        start = new Date();
        java.util.Arrays.sort(objArray2, myComp);
        end = new Date();
        for (int i = 0; i < objArray2.length; i++) {
          System.out.println();
          innerObjArray2 = (Object[])objArray2;
    for (int j = 0; j < innerObjArray2.length; j++) {
    System.out.print(innerObjArray2[j] + " ");
    System.out.println(v.size());
    System.out.println("Start " + start + " End " + end);
    import java.util.*;
    public class MyComparator2
    implements Comparator {
    //position in the inner array to use for comparison
    private int position = 0;
    //default empty constructor
    public MyComparator2() {
    //implement compare method
    public int compare(Object o1, Object o2) {
    Object[] strAr1 = (Object[]) o1;
    Object[] strAr2 = (Object[]) o2;
    if (strAr1[0] == null){
    if (strAr2[0] == null){
    return 0;
    else{
    return -1;
    else if (strAr2[0] == null){
    return 1;
    return ( (String) strAr1[0]).compareTo( (String) strAr2[0]);

  • Order by -- complex sorting?

    Hello:
    How can one accomplish the following:
    Let's say I have the following scenario:
    Select value2 from table2 IF this value exists. Else, select value 1 from table1. --
    Then: I would like to ORDER BY all of the above results (sometimes the value may be value1, other times vaule2, etc). How can one do such an ORDER BY? Is this even possible via a query?

    Hi,
    In most cases, you can use functions and CASE expressions (or more specialized if-then-else expressions, like COALESCE) to sort things the way you want.
    For example, if you want to pass a parameter, :p_sort_key, a VARCHAR2 that tells if you want to sort by value1, value2or value3, then you can do this:
    ORDER BY  CASE  :p_sort_key
              WHEN  'V1'  THEN value1
              WHEN  'V2'  THEN value2
              WHEN  'V3'  THEN value3
                 ENDThis assumes value1, value2 and value3 all hafve the same datatype. If not, use TO_CHAR or some other conversion function on one or more of them.
    Now say we want to sort by table2.value4 if it is present, and otherwise by the expression above.
    Depending on your exact requirements, you could say
    ORDER BY  table2.value4               NULLS LAST
    ,            CASE  :p_sort_key
              WHEN  'V1'  THEN value1
              WHEN  'V2'  THEN value2
              WHEN  'V3'  THEN value3
                 ENDThis will sort by table2.value4, and then, as a tie-breaker, by the other value. (NULLS LAST is the default, so you don't have to say explicitly say it, but you can for clarity's sake.)
    if you really want the second expression only to have effect when table2.value2 is NULL, then you could use a NVL statement, or incorporate value4 into the CASE:
    ORDER BY  CASE 
              WHEN  table2.value4  IS     NOT NULL
                                          THEN table2.value4
              WHEN  :p_sort_key = 'V1'  THEN value1
              WHEN  :p_sort_key = 'V2'  THEN value2
              WHEN  :p_sort_key = 'V3'  THEN value3
                 ENDIf all else fails, there's always dynamic SQL.
    In SQL*Plus, for example, you could run a preliminary query that produces a sting like
    SUBSTR (value1, 1, 2),
    value3,
    TRUNC (entry_date, 'YYYY') and sets the substitution variable &order_txt to that value.
    Then, in your main query, you say:
    ORDER BY  &order_txt

Maybe you are looking for

  • Can I transfer songs from my admin account to a new user account?

    I want to start using a user account as my main account instead of the admin account. I bought a bunch of songs from iTunes and downloaded them to my admin account. Can I transfer these songs from my admin account to a new user account and then de-au

  • LG Monitor and New Mac Pro -- Colours out of Whack

    I have an LG L226WT and a 20" Apple Cinema Display connected to a brand new Mac Pro. Both monitors (in the same configuration) were running on my old PowerMac G5 before. The Cinema Display works fine, colours are good, so is light etc. The LG first h

  • Problem with SE78 recordimg

    Hi All, I hav recorded SE78 Tcode for uploading BMP file. report ZSR_REC_SE78_1        no standard page heading line-size 255. include bdcrecx1. start-of-selection. perform open_group. perform bdc_dynpro      using 'SAPMSSCH' '2000'. perform bdc_fiel

  • Aiff or .AC3 on DVD disc?

    Hi, I am finishing my band's DVD and I have the final mix in 2 formats. 1 is stereo aiff and the other is a 5.1 .ac3. My question is, is there any advantage to me converting my stereo file to a 2.0 channel .ac3? Will it play back better in more playe

  • Help in Planning Network: G5/iBook G4/Airport Extreme & Express?

    Hi  Folks, I could use some help setting up a WiFI network to accomplish three goals (see below). Hardware and Software: Computers -Dual Core 2.3 GHz PowerPC G5 Desktop Computer (note: NO internal airport WiFi card), OS 10.4.11 -iBook G4 with interna