These SQL clauses are equivalent?

Hi, previously I was working in a SQL statement that returns potentially 1 million rows. The 'order by' clause contributes significantly the cost when I checked its plan to explain.
select ...
from ...
order by field1, field2, field3;
Then I found another way to make the order of who has much lower costs to explain the plan.
select ...
, dense_rank() over (order by field1, field2, field3) overall_order 
from ...
order by overall_order;
Both queries took a long time to run if I didn't not wait until this one is over. The question I have is the above two methods will return the same result in the same order? I know dense_rank() returns the same number of ranking if two values are the same, but do not know what 'order by' will do in the same situation.

I found that when the result set is small (say, a few hundred lines), the analytic function actually result in a higher cost to explain plan. Please let know us if it is OK to use the second method to achieve the effect of "order by" for the large result set.

If you have better alternatives, please suggest as well. Thank you.

Hello

Two of these methods do the same thing.

Both are for an indefinite period as to what happens when two or more rows have the same values for the three variables.
Say the lines A, B and C all have exactly the same values for field1, field2, and field3.
Say, you are running the version with ' ORDER BY Field1, Field2, formees3 ' and the output, in order, is A, B, C.
If you run one version, then there is no guarantee that you will again get the same order (A, B, C). You can get the same order, or you might not.

I'd be surprised if "ORDER BY overall_order" was faster than ' ORDER BY Field1, firld2, field3.

Tags: Database

Similar Questions

  • any case when and the sql clause

    Hello:
    What follows is my sql clause:
    SELECT T.*, b.name
    OF dbtest1 t
    LEFT OUTER JOIN dbtest b ON t.NO = b.empno
    WHERE t.ChineseName like '% "| : ChineseName | ' %' AND b.name like "%" | : name | » %'
    ORDER BY t.ChineseName

    The main problem is that I want to check the b.name if it is null, it can be passed as function NVL, so I try using case when, but it does not work.
    When there are the b.name in where clause, the columns of result will not include data without b.name (or implies the b.name is NULL); And that
    the result data are not entirely accurate.
    is it possible to use the case when it is implemented in the following code snippet:

    -case when b.name is not NULL then b.name like "%" | : name | » %'
    Else b.name = NULL (b.name = b.name does not seem to work on the analysis of data zero)
    end

    Thank you very much.

    962769 wrote:
    The main problem is the table is the form of the cross, and the like clause will filter the
    data without a name. Basically, it should show the empty columns, however, it won't.
    so, when I test the sql code, I fhound Like "%" | b.Name | ' %' will not get the data when the original dbtest1 table data
    has no id corresponding to the BD test. It seems pointless to go the LEFT OUTER JOIN.

    Thank you

    WHERE t.ChineseName like '%'||:ChineseName||'%'
    AND  (
            b.name like '%'||:name||'%'
           or b.empno is null
        )
    
  • The USE of dynamic SQL clause

    Hi all
    I'm moving a table as a variable in dynamic SQl but with no result. Suppose that I it running on HR diagram example:
    declare
    sql_state varchar(100);
    hire_date date;
    temp_table varchar(9):='employees';
    
    begin
    sql_state:= 'select hire_date from :1 where employee_id=206';
    
    execute immediate sql_state into hire_date using temp_table;
    dbms_output.put_line('hire_date is '||hire_date);
    end; 
    
    declare
    *
    ERROR at line 1:
    ORA-00903: invalid table name
    ORA-06512: at line 9
    I get this error of invalid table name without knowing what was read for the variable. Any advice?

    Best regards
    Val

    Hi Valerie,

    To add to what Peter, said

    "Binding" values in a query is done for a specific purpose, and this purpose is so that the optimizer can use the same query as the previous execution plan runs the query, which prevent it from having to analyze the hard the query each time. A query execution plan is based on the tables and columns are presented in the query, but with respect to the actual "values" of these columns, they are unlikely to change the execution plan. So, to keep the same execution plan, the query must seem identical (in terms of a query string) like the previous series, so if you want the same query, but just with different values, they can be replaced with bind variables (these things have a ': ' character) and then the values passed in the query, when it is run.

    Now, if Oracle were to allow you to link in the names of objects, such as tables, this means that it could not use the previous execution plans, because he doesn't know until run time what tables will be consulted. Therefore, it would be useless link in the values of the query and it would be just as quick to implement your query string by concatenating all the values inside rather than link them. Considering that a query is parsed first and then the values in it, then it cannot be analyzed if the tables are not known everything first. (Take a look at how queries are formed and variables when you use the DBMS_SQL package).

    So the key thing to remember is that, when it comes to bind variables, you can bind only the 'values', not 'objects '.

  • These graphics cards are compatible with the computer

    Hi I wonder if these graphics cards will be able to adapt and work in my machine

    http://support.HP.com/us-en/document/c02628380

    It's my computer

    I wonder if these graphics cards are compatible have not decided what to buy yet

    AMD Radeon R7 250 4 GB graphics card Sapphire Radeon R7 240 1 GB GDDR5, PCI-Express 3.0 (x 16) EVGA NVIDIA GeForce GT 730 1 GB GDDR5 graphics card

    and also what power would be good for those or if I still have to improve diet

    austin211,

    If your return?     Your other confectioners, Q, and r.   Always try to find a card with a value of World of Warcraft?   The recommended card is HD5870 or better. The cards that you offer are very low-end.

  • These startup programs are causing windows to start slowly

    Original title: interruption of the performance issue
    I installed the emulator DOSBox BACK on my computer slowed last January.It my computer. So I uninstalled. My computer became a little fast. But I always find a little problem. In the performance tools advanced it shows

    Start up programs are causing Windows start slowly. See the details
    When I click on it, I see that
    ______________________________________________________________________________<>
    These startup programs are causing windows start slowly.
    Name: BACK DOSBox emulator
    File name: DOSBox.exe
    Editor: DOSBox team
    Day: Thu Jan 24,2013 14:55
    Time of shooting: 109,7 seconds
    ______________________________________________________________________________>

    This is the exact report I get. This report is boring. Help, please. I hope that my community.

    Hello

    Thanks for posting the request in the Microsoft community forums!
    It seems that the computer is slow after installing the emulator DOSBox BACK. Don't worry, try the suggestions and check if it has speed up the computer.

    What virus protection software is installed on the computer?

    To solve the "'these startup programs are causing windows to start slowly ' error, try the methods"

    Method 1:
    Unplug external devices attached to the computer and then restart the computer and check the performance of the computer

    Method 2:
    Step 1: Check if the problem occurs in safe mode:
    http://Windows.Microsoft.com/en-us/Windows7/start-your-computer-in-safe-mode
    Step 2: If the problem does not occur in safe mode then you can perform a clean boot and check.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135
    Note: After the adventures of shooting set the computer to start as usual by performing step 7 above of the Knowledge Base article.

    Method 3:

    You can run a Microsoft security scanner to make sure that the computer is free from virus infection:
    http://www.Microsoft.com/security/scanner/en-us/default.aspx
    WARNING:
    If you run the antivirus program that is infected by the virus scan will get deleted. Therefore, reinstall the program. Also if the files and folders are affected by the virus, while they might even get deleted

    See the link in order to improve the performance of the computer:

    Optimize Windows 7 for better performance
    http://Windows.Microsoft.com/en-us/Windows7/optimize-Windows-7-for-better-performance


    Ways to improve your computer's performance
    http://Windows.Microsoft.com/en-us/Windows7/ways-to-improve-your-computers-performance

    If you need help with Windows, just tell me and we will be happy to help you.

  • Downloaded PSE13, these two files are located in the downloads folder, but I can't activate the program, he repeated to me that the part of the file is missing

    Downloaded PSE13, these two files are located in the downloads folder, but I can't activate the program, he repeated to me that the part of the file is missing

    Please check: https://forums.adobe.com/message/8163721

  • r beeb used before on pc. The problem is that these two PCs are thrown NAWL avay chrased long, I hava a few photos on the program and its impossible to buy a new number for one that oldc product. What should do?

    r beeb used before on pc. The problem is that these two PCs are thrown NAWL avay chrased long, I hava a few photos on the program and its impossible to buy a new number for one that oldc product. What should do?

    If you have the serial number, you can contact the Adobe Support via chat (when they are available - not weekend) and ask them to reset your activations.  Which will allow you to reinstall and activate again using the serial number, which you have now.

    To the link below, click on the still need help? the option in the blue box below and choose the option to chat...
    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If it fails to connect, try to use another browser.

    Serial number and activation support (non - CC) chat
    https://helpx.Adobe.com/contact.html?step=PHSP-PHXS_downloading-installing-setting-up_lice nsing-activation_stillNeedHelp

  • I LR4 on my Mac with a few 8 000 images on it. If I buy the creative cloud, do I download LR5 on my desktop and how can I access these images or are they automatically imported?

    I LR4 on my Mac with a few 8 000 images on it. If I buy the creative cloud, do I download LR5 on my desktop and how can I access these images or are they automatically imported?

    There is no forced use of the LR5 and your LR4 will remain in place and active. If you decide to use LR5 will try, import your catalogs.

    Mylenium

  • The following types are equivalent?

    Hey guys, I want to know if an object type is equivalent to a record type. So ignore the problems of demarcation, the following types are equivalent?
    create or replace type xml_row as object (xmlfragment varchar2(2000));
    /
    create or replace type xml_tab is table of xml_row;
    /
    What I want to accomplish is the following equivalent
    create or replace package pac_a as
      type xml_row is record(xmlfragment varchar2(2000));
      type xml_tab is table of xml_row;
    end pac_a;
    / 

    From a point of view of 'data', the models are equivalent.
    A type of object has a set of features that a classic record type has no, first the possibility to create a column in a table using this type...

    Max

  • What are these SQL statements?

    Hello!

    We are our applications running on Windows Server 2003 where it works fine, using Oracle via OCI 12.1.

    Now, we have the application installed on Windows Server 2012 and it works very slowly.

    When comparing these two environments trace files came a surprise: Oracle generates a lot of SQL statements when run on Windows Server 2012!  By operating on Windows2003 it only executes the SQL from the applicaton instructions.  These additional SQL statements must be the reason for the slowness, but why Oracle it generates them and how could we get arrested?

    An example:

    PARSING IN CURSOR #46985062096816 len = 210 dep = 2 uid = 0 oct = cover 3 = 0 tim = hv 1439277877325893 = ad 864012087 = "4db599f28" sqlid = "96g93hntrzjtr."

    Select / * + rule * / bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp #, sample_size, minimum, maximum, distcnt, lowval, hival, density, col #, spare1, spare2, hist_head avgcln $ where obj #=: 1 and intcol #=: 2

    END OF STMT

    ANALYSIS #46985062096816:c = 1000, e = 456, p = 0, cr = 0, cu = 0, put = 1, r = 0, dep = 2, og = 3, plh = 0, tim = 1439277877325890

    EXEC #46985062096816:c = 0, e = 498, p = 0, cr = 0, cu = 0, put = 1, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326455

    FETCH #46985062096816:c = 0, e = 56, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326533

    STAT #46985062096816 id = 1 cnt = 1 pid = 0 obj = op 411 = pos = 1 "TABLE ACCESS BY INDEX ROWID HIST_HEAD$ (cr = 3 pr = 0 pw = time 0 = 55 US)"

    "STAT #46985062096816 id = 2 cnt = 1 pid = 1 pos = 1 obj = op 413 ='INDEX RANGE SCAN I_HH_OBJ #_INTCOL # (cr = 2 pr = 0 pw = time 0 = 32 US)"

    OUTCOME #46985062096816:c = 0, e = 37, dep = 2, type = 3, tim = 1439277877326601

    EXEC #46985062096816:c = 0, e = 23, p = 0, cr = 0, cu = 0, set = 0, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326702

    FETCH #46985062096816:c = 0, e = 18, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326738

    OUTCOME #46985062096816:c = 0, e = 8, dep = 2, type = 3, tim = 1439277877326765

    EXEC #46985062096816:c = 0, e = 19, p = 0, cr = 0, cu = 0, set = 0, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326837

    FETCH #46985062096816:c = 0, e = 21, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326923

    OUTCOME #46985062096816:c = 0, e = 10, dep = 2, type = 3, tim = 1439277877326954

    Thank you very much in advance!

    Best regards

    Jaakko Terhonen

    Thank you all for the reply!  This time, the reason was a problem in network traffic (TCP protocol): a lot of retransmissions for a still unknown reason.  If it had nothing to do with Oracle after all.

    I cried for help here because as a common application programmer, I wasn't familiar with the Interior details of SQL analysis and after seeing it in the trace, I assumed that these strange SQL statements - which, for some reason, is appeared only in W2012-trace - were the reason for the slowness.

    Thank you, I'm a little wiser now - and I hope that many others find this thread before asking the same question!

    Best regards

    Jaakko Terhonen

  • SQL clause 'or '.

    Hello

    I am creating a search function vi, which allows the user to search for some columns in my database with the input control 1. Is it possible to do if some of the columns have different data as string types & digital?

    I have this here vi which I use to interrogate some of the column of the same type of data in the database. It seems that there is something wrong with my 'or' clause. When the input is b / l, the part of the data displayed is correct since the firstname column won't work & the clause "and" name also will not work, resulting in all data displayed. However, if I remove the or clause for my lastname, firstname column column will work but my data for the device will not work. When the input is 1, all occupants in my database will be displayed & they will all have the same unit even if they live in a different unit. However, if I delete my request first name, leaving only the unit, it works perfectly.

    I believe that the problem happens if I use the or clause of these terms before the last clause "or" & after the last 'or' clause in my query will not work. The Address.AddID AND = PersonDetails.AddID AND PersonDetails.Status = 'active' is ignored if it is not the last clause 'or '.

    IM using data select vi to recover my data, because it is something strange happens if I use the sql execute query vi. below is my sql query & attached is my base data & vi.

    WHERE Address.Unit = 'b' or PersonDetails.FirstName LIKE '% b %' or PersonDetails.LastName LIKE '% b %' AND Address.AddID = PersonDetails.AddID AND PersonDetails.Status = 'active '.

    Thanks for reading & hope someone knows why this happens.

    Kind regards

    Wayne

    I can't open your files (got an earlier version), but I suppose you use an .mdb you have access? Do the work in question here? I have several times to build an access issue and switched to the sql mode to copy in LabView.

    Maybe a couple of brackets to fix the problem. It should not be necessary, but it might help to use WHERE ([or CLAUSES]) AND ([CLAUSES AND])

    /Y

  • I have an ipod, the content that will not appear on my itunes since I inadvertently updated (I think) to the latest version of itunes.  I also lost all my playlists, when I upgraded.  I can't find these, but they are on my ipod

    I have an ipod touch.  its contents will appear not on itunes because I upgraded the version of itunes.  When I upgraded I also lost all my playlists.  These lists are still on my ipod, but I can't put them back on itunes.  my ipod doesn't seem to be appear on senuti.  I even bought a (non-working so far) xilisoft ipod rip so I post playlists.  so, how to do content of my ipod appears on my itunes and senuti?  Thank you.

    What operating system and version you have on the computer?

    What version of iTunes you have?

    Which version of iOS?

  • How can I avoid my message box to send these messages which are invadeing?

    All these messages are poping up upward in the message box, now I can't send my message, because now I'm over my limit of message, but none of the messages are not from me.

    If you use Hotmail, your probably got account compromised.  Ask here and they can rectify things: http://answers.microsoft.com/en-us/windowslive

    Steve

  • my photo folders have been deleted and I can't get back them and they are not in the Recycle Bin, how can I recover these photos they are very important

    Remember - this is a public forum so never post private information such as numbers of mail or telephone!

    Ideas:

    • You have problems with programs
    • Error messages
    • Recent changes to your computer
    • What you have already tried to solve the problem
    On Monday, December 6, 2010 09:09:06 + 0000, krazychild18 wrote:
     
     
    > Remember - this is a public forum so never post private information such as numbers of mail or telephone!
    >
    > Ideas: programs you have problems with error messages recent changes you do on your computer that you have already tried to solve the problem
     
     
    Please do * not * leave the text above in a question to ask you. Delete it.
    It has nothing to do with your question. And please ask your question
    in the body of the message, not in the title.
     
    How to get deleted? If you remove them normally, they must be
    in the trash. If they are not, read point 1 below (but also pay
    Special notice to the point 2):
     
    1. "deleting" a file does not actually delete it just marks the
    available space be used. There are third-party programs that can
    sometimes recover deleted files. The problem is that the space used by
    the file is likely to be replaced very quickly, and it makes
    the unrecoverable file.
     
    So your chances of successfully recovering these files are decent if
    you try to recover immediately after their deletion and quickly
    down from there. If you use the computer since
    (for example to read this answer and write that question), your
    chances may be very weak now.
     
    But if the file is large enough, it's still worth a try. Stop
    using the computer in question immediately, if you have not done
    already. Download an undelete program (and here's one:)
    others to choose from; Do a search) on a friend's computer and bring
    it to you on a floppy disk, CD or USB to try.
     
    If that fails, your only recourse is to bring or send the disc
    a company of professional file recovery. This kind of service is very
    expensive and may or may not work in your case.
     
    2. If you have files that are important to you, and you do not
    back them up regularly, you are playing with fire. It is not a question
    to know if you lose them, it's a question of * when *. You could
    you want to read this article on the backup that I wrote:
     
     
     

    Ken Blake, Microsoft MVP

  • I installed lr6 &amp; photoshop cc &amp; these two apps are not in features &amp; pannel - control program. both work well, but I want to uninstall cc photoshop, how do I do

    I installed photoshop cc & lr6 in win 7 64 bit.
    These two applications work well & are not in features & pannel - control program.
    How to uninstall photoshop cc if it is not in the pfogram list & features?

    Try tool Adobe Cleaner running:

    Locate the Photoshop option and remove it.

    Do not select clean all the option, it will remove all Adobe applications

    https://helpx.Adobe.com/content/help/en/creative-cloud/KB/CC-cleaner-tool-installation-Pro d/_jcr_content/hand-Sea/support_section_0/section-Sea/section_content/section-content t-main/filter_content/section-content-main/procedure/proc_par/step_5/step_par/download/wire e.res/AdobeCreativeCloudCleanerTool.zip

Maybe you are looking for

  • Device and the user does not add security to the family account

    First post. Win8 running on a laptop. He was previously a partner in a family safety account, that I had put in place. I removed the unit and the user to try to resolve a problem with a web page. However, the account will now add the user or the devi

  • I have disk defragment now show that I have no free space left

    I try to Defrag. and cleaning disc once a week. I normally like 30% free space. After that I have the defragmentation. last week, he went to zero, all free space (white bar) became red. I have not downloaded anything. I tried to remove programs, whic

  • How to open pps files of ideas... my current program will not be read

    Sevealla months ago I received a fileand despirte pps download a program that was supposed to open I couldn't do so... any idea?

  • Search function works only in Windows 7

    I was wondering what happened to the Windows search function?  When he changed to the version of Windows 7, I can't find it anywhere.  I'm not talking about a search engine like Google or Bing - I am not search when you type in a word or several word

  • Dagen na 21 trial precisi

    Op 17 juli 2016 heb ik Adobe first Pro CC test geinstalleerd via Creative Cloud. Said is voor mij niet nieuw, due very clean. IK kan echter me herinneren dat deze test 30 dagen available starket, "momenteel" het is niet wat is. Sinds vandaag (21 dage