Decide upon which query to choose.

I've a couple of SQL queries both performing the same task.(ie.the result set of the two queries being the same).
Now,How would I decide which of the two to go with?
Would it be ok if I decide with the costs of the two queries.ie choose the one with min. cost?
Regards,
Bhagat

According to Tom Kyte, one cannot do this. The CBO costs from one execution plan can never be related to another execution plan - even for the same SQL.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:313416745628
Quote. "Don't compare them, you cannot -- they might as well be random numbers." Unquote.
I think Jonathan Lewis may have a slightly different take on this. (hint, hint Jonathan - you're here? ;-) ).
Must admit that I have often used the cost between to plans for the same SQL as a deciding factor - which from reading Tom's response is not a very bright idea.

Similar Messages

  • Which query is best

    Hi,
    Which query is best interms of performance.
    SELECT NAME
    COUNT(ID) AS CNT,
         RANK() OVER (ORDER BY COUNT(ID) DESC) AS RANK
    FROM TABLE_1
    GROUP BY NAME
    SELECT NAME
    --- COUNT(ID) AS CNT,
         RANK() OVER (ORDER BY COUNT(ID) DESC) AS RANK
    FROM TABLE_1
    GROUP BY NAME

    Which query is best interms of performance. They dont look similar, i.e., in the second query, you have commented out --COUNT.  This will avoid sorting, by the way.
    Do you think both queries gives you the same output?
    you have said in your last reply that you hate full table scans.
    Let me tell you, FTS are always not evils and INDEX scan is not always FASTER.
    it all depends on many factors why optimizer chooses FTS over INDEX scan.
    Jaffar

  • ADF: How to find out which query has taken what time?

    Hi,
    I have an ADF application which has many SQL queried running on each button click/page load, so how to find out which query is taking what amount of time? So that i can identify the long running queries and modify them to improve the application performance.
    Thanks in advance.

    Hi,
    As suggested by Timo,you need to start tracing on oracle.jbo package for getting the SQL queries.But I think the second option suggested by him would be better.You will have to override executeQueryForCollection method in VO Impl class .Pseudo code would be
    @Override
    Take start time
    super.executeQueryForCollection
    Take end time

  • I am trying to decide on which Mac laptop I should get

    I am trying to decide on which Mac laptop I should get

    nobody can tell you without knowing your parameters of usage
    If mostly photo and video editing (or a lot of same), then get a higher end pro.
    If casual typical use, the Air is a powerhouse of which many are fooled by its slim size thinking it cannot do much, when in fact its a full powered notebook that amazes most people first time in use.
    recommend 8GB min. RAM on either model.

  • Eversince I updated my iphone 4 to IOS 5.0.1, sometimes I get a 'No Service' or 'Searching'  signal where my network signal should be upon which I have  to 'Reset all Settings' to get the phone normal again.Is  there a solution to this?

    Eversince I updated my iphone 4 to IOS 5.0.1, sometimes I get a 'No Service' or 'Searching'  signal where my network signal should be upon which I have switch the phone off then on then 'Reset all Settings' to get the phone normal again.Is  there a solution to this?

    I couldn't find the edit button on my original post so I am posting an update here.
    I have gone through more apps and have had good luck on all but one more.  And it's not that the app doesn't work, I am talking about the Yahoo Weather app, It works fine, but when you swipe between cities the screen lags a bit and it sometimes doesn't move between pages the way it should.  On iOS 7.1.2 it was smooth as butter but on iOS 8.0, not so much.  I will post a note in the app store to let them know.  I really like the Yahoo app better than the new stock app.
    I have been going through my games and they all work fine. Angry Birds (Original and Stella), Canabalt, Minecraft, Bejeweled 2, Silly Walks, PopWords, Doodle Jump, Deep Green all seem to work just fine. 
    Starbucks app works as it should. 
    I will stop back again next week after I have had the weekend to play with it in detail and post my thoughts again.

  • How to identify what customer exit variables are used in which query?

    Hi all,
    When i happened to check the CMOD transaction code i can find a list of customer exits are used. But i want to know what are those customer exist are used in which query? can anyone let me know the procedure of identifying it.
    Thanks a lot
    Pooja

    hii pooja
    check the foll links
    Very Urgent: Customer Exit Variable
    customer exit variable
    MIssing Authorisation for customer exit variable query
    Authorization variable or customer exit variables
    if it is helpful assign points
    thanks.

  • Which query is running in package

    Hi,
    I created one package and run this package in toad
    like
    select reports_package.func_reports('ABC') from dual;
    I have 10 delete and 10 insert statement on this .
    How I will check which query is running iin database.

    799301 wrote:
    I have 10 delete and 10 insert statement on this .
    How I will check which query is running iin database.V$SESSION_LONGOPS holds information on SQL taking > 6 seconds to run but its not always possible to find expected entries in the V$ views
    If you're trying to figure out what is slow a better bet would be to perform trace or use DBMS_PROFILER to analyze the PL/SQL

  • How to check which query is consuming most resources....

    Hi guys how can i check which query is consuming most resources , run by which user and how to kill that....
    Khurana

    1)     At the first stage, login to the server and at the OS level I run commands like TOP and see the overall performance of the Server. From this one can know the Total CPU Memory, CPU Usage, Memory Available, and Swap Memory Available and how busy the CPU is.
    2)     Once you identify the top processes in the CPU, relate them to ORACLE using V$PROCESS.SPID = OS Process ID to get the V$PROCESS.ADDR and join this with the V$SESSION.PADDR to get the V$SESSION.SID and SERIAL# columns.
    3)     Then enable the Session Trace using DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION.
    4)     look on the Trace File using the TKPROF. During this sort the Trace File using various options like EXEELA/DSK, PRSELA/DSK, FCHELA /DSK.
    5)     Once you identify the expensive SQL statements, inform the user about it and KILL the respective job.

  • Ho do i check bcz of which query's the dead locks happend in 11g

    Hi,
    I am working on 11g database and recently dead locks happend and it's released it's fine. But i need to know becz of which query's the dead locks happend and who fired those query's.
    i hope we can get these info from trace file i opend trace file but am fully confusing how do i know all these details. Can any one help me on this...
    Thanks in advance
    Regards

    Check
    How to find where is deadlock?

  • My macbook pro is already authorized, but a purchased song from iTunes keeps stating that my computer is not authorized to play it. I enter my apple ID and password, upon which a window confirms that my computer is already authorized. Yet the song still w

    My macbook pro is already authorized, but a purchased song from iTunes keeps stating that my computer is not authorized to play it. I enter my apple ID and password, upon which a window confirms that my computer is already authorized. Yet the song still won't play and continues to state that my computer is not authorized.

    If you live in a country in which you are allowed to re-download purchased music delete the track from the library and the HDD and re-download it.

  • I ordered the download of Photoshop 13. It's giving me 2 options. 32-bit or 64- bit operating system download. Which do I choose?

    I ordered the download of Photoshop 13. It's giving me 2 options. 32-bit or 64- bit operating system download. Which do I choose?

    The one that is the same as your operating system.
    See #2:
    32-bit and 64-bit Windows: frequently asked questions - Windows Help

  • How to find which query taking more cpu

    Hi,
    How to find which query taking more CPU
    at a particular point of time .
    Chhers,

    Take a look at Server Standard Reports. It has a few CPU usage oriented reports.
    You can also track CPU usage by server-side tracing:
    http://www.sqlusa.com/bestpractices/createtrace/
    Glenn Berry's CPU usage query:
    SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime],
    qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.execution_count,
    ISNULL(qs.execution_count/DATEDIFF(Second, qs.cached_time, GETDATE()), 0) AS [Calls/Second],
    qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count
    AS [avg_elapsed_time], qs.cached_time
    FROM sys.procedures AS p WITH (NOLOCK)
    INNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK)
    ON p.[object_id] = qs.[object_id]
    WHERE qs.database_id = DB_ID()
    ORDER BY qs.total_worker_time DESC OPTION (RECOMPILE);
    LINK:
    http://dba.stackexchange.com/questions/52216/sql-server-2008-high-cpu-historical-queries
    Query optimization:
    http://www.sqlusa.com/articles/query-optimization/
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Hi ....using iphoto '08, but whenever i export photos to mail, they all come out small size, regardless of which size i choose. please help.

    hi ....using iphoto '08, but whenever i export photos to mail, they all come out small size, regardless of which size i choose. please help.

    After they get into the email go to the small menu at the lower right hand corner of the Mail window and select the size you want:
    Click to view full size

  • Which query is using which Hierarchy?

    Hello All,
    Where can i get the information like which query is using which hierarchy!?
    I tried to make it happen by combining lot of tables like
    RSRREPDIR
    RSZELTPROP
    RSZELTXREF
    RSHIEDIR
    RSZCOMPDIR
    but couldn't arrive at a solution. Did u guys come across such a situation!?
    If so please brief me how?
    Thanks
    Karthik

    Please see this link for a solution:
    Queries that use a hierarchy
    Hope this helps.
    Regards
    PS: assign points is the way to say thanks

  • How to find which query need to tuned

    Hi ,
    How can i find , which query need to tuned . Is there any mechanism behind it?

    The mechanisms behind it are depending on your database version.
    For example:
    Oracle 9i has STATSPACK that helps you to identify possible problem queries.
    Oracle 10g has AWR - Automatic Workload Repository
    Oracle 11g has SPA - Database Replay SQL Performance Analyzer
    but there are many more tools/mechanisms...trace/tkprof for example.
    Go to http://tahiti.oracle.com and do a search on 'performance tuning guide', and pick the one that matches your (sofar unknown) database version, read a bit every now and then and see what tools are at your disposal and fit your requirement and situation.
    Besides the links that Blu already posted, searches on http://asktom.oracle.com also give lots of pointers and explanations regarding the (neverending) tuning process (at least: helped me tremendously in understanding the tuning process, the do's and dont's).
    Make sure you don't get CTD (Compulsive Tuning Disorder) from all this... ;)

Maybe you are looking for

  • My Screen Broke, And Ive Got A Mini-DVI To Video Adapter (Help Please)

    and all i see is my background and my mouse on my tv, no icons or anything. any one got any helps.

  • IF CONDITION IN SMARTFORM.

    Hello all, Just facing a small problem in smart form. The code goes as follows :: PLANT: &GRLABEL-WERKS& /* Codes works fine. Displayed correctly. /: IF &GRLABEL-WERKS& = '01' Inside IF /: ELSE Outside IF /: Endif The problem is in if condition. Its

  • Goods Issues done with Purchase Price and not MAP

    I would like to know on the inventory valuation from moving average price (MAP)/ average the inventory value to First In First Out (FIFO) basis. FIFO basis is where assumption made that inventory being sold is based on first come first serve basis i.

  • Cell Text Doesnt display comments in FR

    Hi, We're having some DR(Data Request) forms and through which we are submitting the amounts & comments against any particular HFM Account through Smartview fuctions like- HsSetValue and HsSetText, want to display the same in FR in the Grid. Need to

  • BI Export Library vs. ADS (Adobe Document Services)

    Does anybody know why SAP added the Export Library as an alternative to ADS for BI?  I mean, are there pros and cons to using one over the other?  Right now we're using the Export Library and it seems to work fine for broadcasting and Print View in B