Which statement is efficient?

Which statement is efficient?
1.  SELECT MSG_ID,IP_ADDRESS,DATETIME INTO V_MSG_ID,V_IP_ADDRESS,V_DATETIME
       FROM (SELECT * FROM INCOMING_MSG_IDX ORDER BY LAST_CHECKTIME)
         WHERE STATUS = 4 AND MSG_TYPE >= LOW_MSG_TYPE AND MSG_TYPE <=
            UP_MSG_TYPE AND ROWNUM <=1;
2.   SELECT MSG_ID,IP_ADDRESS,DATETIME INTO V_MSG_ID,V_IP_ADDRESS,V_DATETIME
         FROM INCOMING_MSG_IDX
           WHERE STATUS = 4 AND MSG_TYPE  BETWEEN  LOW_MSG_TYPE AND
             UP_MSG_TYPE AND ROWNUM =1
                  ORDER BY LAST_CHECKTIME

jetq wrote:
Which statement is efficient?If more than one row satisfies your filter predicates in the WHERE clause then your question is irrelevant since the two statements are not equal.
The first one obeys the ORDER and returns the first entry ordered by LAST_CHECKTIME that passes the predicates.
The second one returns an arbitrary row that passes the predicates, because ROWNUM is applied before the ORDER BY, and therefore the two statements are not equal.
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

  • What is dbms_sql, execute_immediate?which one is efficient?

    what is dbms_sql, execute_immediate?which one is efficient?

    Efficient is to use static sql and don't bother with dynamic sql unlss you are FORCED to do that because it cannot be achieved with static sql. Most of the times it can.
    Generally speaking dbms_sql is more efficient if you have to execute your statement over and over again, native dynamic sql aka execute immediate is more efficient if you need to do something only once.
    Of course native dynamic sql is easier to code, although there may be times when you cannot live without dbms_sql for example if you don't know types or number of returning columns.
    Anyway I repeat one more time - use static sql whenever possible.
    Gints Plivna
    http://www.gplivna.eu

  • In SQL Trace how to see which statement getting more time .

    Hi Expart,
    In SQL Trace (T-code ST05) . I am running the standard transaction . how to see which statement
    running more time and less time . suppose one statement running more time so how resolve the
    performance .
    Plz. reply me
    Regards
    Razz

    > The ones in 'RED' color are the statement which are taking a lot of time and you need to
    > optimise the same.
    No, that is incorrect, the red ones show only the ones which need several hundret milliseconds in one execution. This can even be correct for hard tasks. And there are lots of problem, which you will not see
    I have said everything here:
    SQL trace:
    /people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
    Go to 'Tracelist' -> Summarize by SQL statements', this is the view which you want to see!
    I summarizes all executions of the same statement.
    There are even the checks explained, the slow ones are the one which need a lot of time per record!
    See MinTime/Rec > 10.000 microseconds.
    Check all number of records, executions, buffer, identicals.
    The SE30 Tipps and Tricks will not help much.
    Siegfried

  • Implicit Join or Explicit Join...which is more efficient???

    Which is more efficient?
    An IMPLICIT JOIN
    SELECT TableA.ColumnA1,
    TableB.ColumnB2
    FROM TableA,
    TableB
    WHERE TableA.ColumnA1 = TableB.ColumnB1
    Or....An EXPLICIT JOIN
    SELECT TableA.ColumnA1,
    TableB.ColumnB2
    FROM TableA
    INNER JOIN TableB
    ON TableA.ColumnA1 = TableB.ColumnB1
    I have to write a pretty extensive query and there will be many parts and I just want to try and make sure it is efficient as possible. Can I EXPLAIN this in SQL Navigator as well to find out???
    Thanks in advance for your review and hopeful for a reply.
    PSULionRP

    Alex Nuijten wrote:
    The Partition Outer Join is very handy, but it's an Oracle-ism - Not ANSI ...Ooh, "New thing learnt today" - check.
    but then again who cares? ;)Oracle roolz! *{;-D                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • I keep getting an error message when downloading a new app which states " Zinio and 5 other apps cannot be purchased at this time" and then it let's me purchase the app that I was looking at? Can anyone explain that?

    I keep getting an error message when downloading a new app which states " Zinio and 5 other apps cannot be purchased at this time" and then it let's me purchase the app that I was looking at? Can anyone explain that?

    apple_master New Delhi, India
    This solved my questionRe: Unable to Purchase 
    Apr 16, 2012 10:22 PM (in response to eight4seven)
    This worked for someone
    I had this problem for about six weeks. I was following this forum but was too unsure of what might happen to try the fixes that were suggested.
    About two weeks ago I decided to delete the downloads.28.sqlitedb file (usingDiskAid(a free program), on a PC running Windows 7). The original downloads.28.sqlitedb was 936 KB. The new one that the system created is 80 Kb., and has stayed at about that size. After about four days I also deleted all the other contents of the Download folder. Ten days later and still no more problems. Downloads are much quicker, nothing greys-out (as was happening frequently before).
    Everything has worked well since with no more error messages.
    I am using an iPod 4G, iOS 5.1 (originally iOS 5.0). I do not have a manifest file, and as far as I know, have not had one. DiskAid can search the whole "hard drive" on the iPod.
    Deleting downloads.28.sqlitedb and the contents of Downloads worked for me.

  • When I try to open my Yahoo mail in safari, I get a message which states:" In order to use Yahoo mail, please turn Private Browsing off. Please go to Settings Safari Private Browsing, and turn off" The problem is my ipad does not a Private Browsing switch

    When I try to open my Yahoo mail in safari, I get a message which states:" In order to use Yahoo mail, please turn Private Browsing off. Please go to Settings>Safari>Private Browsing, and turn off" The problem is, my ipad does not a Private Browsing switchat this location.

    With iOS 7 on the iPad, you turn Private  Browsing on and off by tapping the URL field.  The screen that  opens up has your bookmarks on it.  In the bottom left corner is a hot button marked 'PRIVATE'.  Tap on the word 'PRIVATE' to turn private browsing on or off.  Yeah, there aren't any instructions anywhere that I can find to do this, and if you follow Yahoo's instructions, they don't work.  This doesn't happen with the previous Apple OS, and you can restore your iPad to the older OS. 

  • Which statement would you use to confirm a transaction?

    Which statement would you use to confirm a transaction?
    a. COMMIT TRANSACTION
    b. ROLLBACK TRANSACTION
    c. CHECK TRANSACTION
    d. VIEW TRANSACTION

    a.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • My friend has an Iphone 5s which states 'Assembled in Korea' at the back? Is it genuine? Plz help ! thanks

    My friend has an Iphone 5s which states 'Assembled in Korea' at the back? Is it genuine? Plz help ! thanks

    Thanks Razmee209 for your reply. He bought it in India. I was wondering does apple make devices which are Assembled or Made in Korea?

  • CC will not allow me to install MUSE 2014 ....take me to Adobe site which states "Muse is downloading now..." however after a hour nothing has downloaded ...very Stange no error message either.

    CC will not allow me to install MUSE 2014 ....take me to Adobe site which states "Muse is downloading now..." however after a hour nothing has downloaded ...very Stange no error message either.

    Braxs please see Install and update apps - https://helpx.adobe.com/creative-cloud/help/install-apps.html for information on how to install Muse CC 2014.

  • I am unable to download the product I purchased.  I have followed the instructions, gone to my command/order which states I have paid for the product and it is ready to download.  I have then, gone to 'my downloads' and it advises me that I have no downlo

    I have followed the instructions, gone to my command/order which states I have paid for the product and it is ready to download.  I have then, gone to 'my downloads' and it advises me that I have no downloads available!  What next?

    The product is online and accessible via the web site.  It was accessed via an email connection. 

  • Which is more efficient for includes/imports?

    Which is more efficient?
    1) <jsp:include
    2) <%@ include file
    3) <c:import
    4) Custom tag version (tomcat 5)
    <me:header/>
    header.tag
    navigation html stuff
    Thanks,
    Karmen

    Depends...
    1) <jsp:include -- this is a runtime include. It will embed the included file at runtime.
    2) <%@ include -- this is a compile-time include. It will copy the file's contents into the JSP page when it compiles it into a servlet. Also, typcially it will not recompile the main page if the include file changes, where as #1 above will.
    3) <c:import -- ...well, I don't honestly know what this does.
    4) Custom tag -- what this does clearly depends on what the tag is written to do. But most of the time, this is just going to write some simple HTML stuff out. You could do it that way, but using 1 or 2 to include some HTML or JSP fragment files would probably be better, since it would be easier to maintain.

  • Which one is efficient???

    I have a text file with huge data. I need to generate Oracle report from this file.
    I have two options...
    1. Creating External table and query the data from external table
    2. Directly accessing data from text file.
    Which one is efficient?
    Thank you,
    Prasad

    hello,
    i guess that depends on
    a) how often your data changes
    b) how often your report is run
    c) how often the format of the data changes
    d) is creating the report the only use for that file
    if you have one single file that does not change and you want to use the data from other applications, i would load it intot he database. also if you generate a lot of reports off that data, going the database route would possibly be the best one.
    on the other hand if creating a report off this data is more of an one-off thing and you might create a new version once in a while but don't need the data for anything else, you might want to access the data directly.
    overall it's a performance vs. work issue. you will have to invest a bit of work to load the data into the database, but will have a much better performance if you use the data heavily, but if you only use it once in a while you might not want to invest in creating loader scripts or setting up a warehousebuilder mapping.
    regards,
    philipp

  • I have a new iPhone 4 which I cannot sync until I upgrade to the latest version of iTunes software (10.2.2).  Upon trying to upgrade, I keep receiving a message which states, "The URL could not be opened."  Anyone have a solution to this problem?

    I have a new iPhone 4 which I cannot sync until I upgrade to the latest version of iTunes software (version 10.2.2).  Upon trying to upgrade, I keep receiving a message which states, "The URL could not be opened."  Anyone else had the same problem & does anyone have a solution?  Would like to try other easier option(s) before uninstalling & installing newest version. 

    You need to buy and install a Mac OS X 10.6 DVD.
    (96040)

  • Which statement is correct?--------QNo.108

    Which statement is correct?--------
    A. One block change tracking file is created for each datafile. By default, the file is created in DB_CREATE_FILE_DEST.
    B. One block change tracking file is created for the database.By default, the file is created in DB_CREATE_FILE_DEST.

    Given the commands to enable and disable block change tracking, which do you think is the correct answer?
    SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
    SQL> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;
    Take a look at the docs for detailed information.
    http://download-east.oracle.com/docs/cd/B19306_01/backup.102/b14192/bkup004.htm

  • When trying to sync I am getting error 13019 which states unable to sync....

    I am trying to sync my iPod in iTunes and I keep getting error 13019 which states unable to sync.  iTunes is updated.

    Same exact thing here, except I have a Nano 5th Gen. Just updated iTunes, and now I am getting the 13019 message, even after restoring to default settings. I've been searching in vain for a fix that WORKS. (Plenty are online, but no luck with several I've tried ...)  Good luck to us both.

Maybe you are looking for

  • Web link to a template

    How i can add web link to a template successfully .I've read the following to do it ,but I still have some ambiguity: It says : 1-In the Object Navigator ,open the template property inspector 2- under the report Escapes node, set the type for the pro

  • Connection error in J dev 11g when deploying weblogic.

    We developer an ADF JSF 11g application. Deploy weblogic is OK for application module We use JDBC URL type connection. Our DB name is TESTDB. And url is jdbc:oracle:thin:@10.0.X.XXX:1521:TESTDB. We have configured web logic with the same connection i

  • Help on running asynchronous RMI over a cluster

    I'm working in an asynchronous RMI interface over the Sun's RMI for cluster computing and I'm having some problems on the distribution and running of the applications slaves. Well, I'd like to know if somebody knows any efficient way of deploying the

  • Re: end of song icon when editing in GB-track markings

    Strange thing--I followed the Bullets & Bones'Converting LPs to iTunes article through to making the split on the track, created a New Basic Track, selected its Solo button, and dragged the track to the new track. But the end of song marker (EoS) did

  • Validation for Exchange Rate

    Hi Experts, I am trying to create a validation with an user exit. I have enhanced RGGBR000 to compare for translation date in BKPF to that of TCURR. Problem I am facing is, I dont know how to put U100 user exit as check and rule in GGB0. How can I do