In which order does the query's where clause condition is checked

Hi All,
can anyone tell me in which order does oracle evaluate the where clause condition?
for ex: select * from users where user_type='Admin' and stauts='Enabled'

user9981103 wrote:
The conditions in the WHERE clause are checked in the reverse order of the given order.
i.e; first it will check stauts='Enabled'* and then user_type='Admin'* for your given queryWhy do you believe that?
If there is a sufficiently selective b-tree index on USER_TYPE, the optimizer would undoubtedly use that index to process the USER_TYPE = 'Admin' condition and then check the STATUS column.
If there is a sufficiently selective b-tree index on STATUS, the optimizer would undoubtedly use that index to process the STATUS='Enabled' condition and then check the USER_TYPE column.
If there is a composite b-tree index on (STATUS, USER_TYPE), the optimizer would use that index to process the two conditions nearly simultaneously, though technically the leading column of the index is evaluated first. Of course, if you reverse the order of columns in the index, you get a different evaluation order
If there are bitmap indexes on STATUS and USER_TYPE, Oracle can combine the two indexes and evaluate the two conditions simultaneously.
And that is leaving out tons of query plan options and other optimizer wrinkles.
Justin

Similar Messages

  • Does the Order of the tablesjoins in Where clause matter in ORDERED hint?

    The ORDERED hint requests that the tables listed in the FROM clause of a SQL statement be joined in the order specified. But does the order of the join in "where" clause matters?
    Will be there any performance difference between below query? The order of the table in the FROM clause remains the same, but there is a difference in the order of conditions in the WHERE clause
    SELECT /*+ ORDERED */ a.fp_i f
    FROn iw_owner.revenue_fpct b,
    dw_owner.fp_dinn c,
    dw_owner.nanaged_at_dinn a,
    dw_owner.at_dinn_curr d,
    iw_owner.na_progran e,
    dw_owner.fp_dinn_curr f,
    dw_owner.fpn_of_at_dinn g
    WHERE a.nacc_dinn_i = b.nacc_dinn_i
    AND b.fp_dinn_i = c.fp_dinn_i
    AND a.acc_i = d.acc_i
    AND a.acc_nacc_c = e.npn_pro_c
    AND a.fp_i = f.fp_i
    AND b.org_fpn_dinn_i = g.org_fpn_dinn_i(+)
    AND c.fp_i IN ('JG 04')
    AND b.dte_dinn_i BETWEEN '1-Apr-2011' and '30-Apr-2011'
    SELECT /*+ ORDERED */ a.fp_i f
    FROn iw_owner.revenue_fpct b,
    dw_owner.fp_dinn c,
    dw_owner.nanaged_at_dinn a,
    dw_owner.at_dinn_curr d,
    iw_owner.na_progran e,
    dw_owner.fp_dinn_curr f,
    dw_owner.fpn_of_at_dinn g
    WHERE c.fp_i IN ('JG 04')
    AND b.dte_dinn_i BETWEEN '1-Apr-2011' and '30-Apr-2011'
    AND b.fp_dinn_i = c.fp_dinn_i
    AND a.nacc_dinn_i = b.nacc_dinn_i
    AND a.acc_i = d.acc_i
    AND a.acc_nacc_c = e.npn_pro_c
    AND a.fp_i = f.fp_i
    AND b.org_fpn_dinn_i = g.org_fpn_dinn_i(+)
    Thanks

    Gangadhar Reddy wrote:
    Does it matter the order of first 2 tables?This question makes me really wonder. It's fairly easy to see how explain changes when using hints.
    Your question indicates that you do not look at explain plans?
    Then why are you asking about hints in the first place?
    Using hints is something you do when you want to force a specific execution plan as part of some investigation, because you know something that the optimizer does no, or you have found a bug in the optimizert.
    In all cases you know exactly what you are doing.
    The /*+ ORDERED */ is all about you telling the optimizer to join the tables in the order you specified them in the from clause.
    As to your original question, there exists a similar ORDERED_PREDICATES hint.
    Regards
    Peter

  • Which method does the actual bulk fetch from database in ADF?

    Hi,
    I'm looking to instrument my ADF code to see where bottlenecks are. Does anyone know which method does the bulk fetch from the database so that I can override it?
    Thanks
    Kevin

    Hi,
    I think you need to be more specific. ADF is a meta
    data binding layer that delegates data queries to the
    business service
    FrankSorry - to be specific I probably mean BC4J - when a query runs in a view object.

  • Does The Query get Fired Again

    Does the query get fired again when i query a existing view
    1. create view abc as select name from Table
    2. select name from abc
    Table is a really large table wid many columns and many rows
    Lookin for a better performance coz i need names in one procedure and again need the same names for deletion in another procedure
    I dont want to fire the same query twice dats y.

    > there are like 20000 rows out of wch i need 2 retrieve 9000 or 10000 rows dependin on
    the constraints
    Go slow on the I'M SPEAK please... much better to deal with technical issues when using proper English.
    A 20,000 rows table is tiny and running a SQL that returns 10,000 or so rows, should be execute in seconds.. the slowest part of the operation should be shipping that 10,000 rows to the client (across the network) in case of a remote client.
    Maybe if you can describe the physical structure of the table (heap, index, partitioned?) and pinpoint just where the performance problem is (execution plan or an SQL*Plus autotrace), we could comment on why the performance seems (or maybe truly is) slow.

  • How does the system decide where to put a file on the desktop?

    So you've just created some sort of file, and you choose to save it to the desktop.   A second later--presto!--the file icon appears on the screen.
    How does the computer decide where on the desktop to put that icon?

    I'm not 100% on this, but I think the system will save files to the last destination you nominated unless you designate another destination at the point of saving. I guess you previously saved something to the Desktop.
    Just tested it on my two Macs and that's how it behaves here.

  • Which Table Store the Query in the Query Manager?

    Hello, I have looking for the table which store all the query inside the Query Manager.
    From this i can retrieve the query without open the program.
    Please help. Thanks.

    Hi William,
    Try this Queries in MSSQL Server Management Studio and dont use Query Generater.
    1. Run this Query, Result: Query Manager Details
    SELECT * from OQCN
    2. Run this Query, Result: Query Details on Query Manager
    SELECT * from OUQR
    Regards,
    Madhan.

  • In which language does the jvm program is written?

    In which language does the jvm program is written?
    Please give the reason for that
    Thanks,
    Vidyadhar

    Dear Nisha,
    you can use table GRACREVREJUSER with the correpsonding reasons from table GRACREJREASON and GRACREJREASONT.
    Regards,
    Alessandro

  • Which tables does the IDOC QALITY02 update?

    Hi Guys,
    I have a serious question at hand. I have to find out which tables the IDOC QALITY02 updates. How do I find this out?
    The problem arises because the functional designer wants an IDOC that updates the same tables as transaction code QE51N. Is QALITY02 the right IDOC for doing this? If not which IDOC does the job and how do I find it?
    I would really appreciate your help. Please mark this question as URGENT.
    Thanks in advance.
    - Priyanka Shukla

    Hi Priyanka,
    Please take a look at these..
    http://help.sap.com/saphelp_erp2005/helpdata/en/04/964e38533e3860e10000009b38f889/frameset.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/5a/5b5738ed5a1d36e10000009b38f889/frameset.htm
    cheers,
    Prashanth
    P.S Please mark helpful answers

  • It does not cover my question about in what order does the sync work?

    It does not cover my question about in what order does the sync work?
    Does the first signed on computer copy its information to the cloud?
    Does the second computer/pad/cell then download the information from the cloud overwriting the information on the second device even if some of the information is different?
    What happens to the information on the second device that is not in the cloud?
    If you delete a record (eg a bookmark) from the second device how does it then delete it on the first device?
    What are the keys to the different types of information?

    Hi I have answered you questions inline below:
    Does the first signed on computer copy its information to the cloud?
    Yes when you first set up the account or when you first add a device to the cloud, if it is not the first time, it will merge with the other data
    Does the second computer/pad/cell then download the information from the cloud overwriting the information on the second device even if some of the information is different?
    By default it merges. There is no option to change this.
    What happens to the information on the second device that is not in the cloud?
    It will sync at the next sync interval if that data is selected to sync.
    If you delete a record (eg a bookmark) from the second device how does it then delete it on the first device? What are the keys to the different types of information?
    It resolved the entry the next time the first and second device syncs. Can you elaborate on the second part of this question?

  • Which resolution does the new macmini support?

    Which resolution does the 2012 mac mini support? Would it be able to power the old 30"Cinema HD display, which has 2560 x 1600 pixels as an optimum resolution?

    Apple seem to have had a brain seizure regarding making this information available. If you look at the KB article for the mid 2011 Mac mini model as here
    http://support.apple.com/kb/SP632
    it does show the required information. If you look at the equivalent article for the late 2012 Mac mini model as shown here
    http://support.apple.com/kb/SP659
    it does not show the resultions. I would say that the answer is the same, that is the new model supports the same resolutions. What has changed is how many displays it can simultaneously drive (now only 2).
    So the answer to your question would be
    Thunderbolt port with support for up to 2560-by-1600 resolution
    HDMI port with support for up to 1920-by-1200 resolution
    Note: If you are using a DVI display with a higher than 1920x1200 resolution, you need to use a Mini Displayport to DVI adaptor, furthermore as before the higher resolution monitors like the 30" Cinema Display need a dual-link DVI adaptor.

  • HT4623 How do we save a attachment which comes with the mail and where?

    IHow do we save a attachment which comes with the mail and where?

    What type of file is the attachment ? You first need an app on your iPad then supports the type of file that you want to save on the iPad - unlike a 'normal' computer the iPad doesn't have a file system, and everything on it has to be associated with an app. If you have an app that supports the type of file that you want to save, then pressing and holding the attachment might (if the app supports it) give a popup with options to save ('open in') the attachment in your app.

  • Dynamic Order by with user defined Where clause...

    Hello!
    I have a block based on a table, with no order by set and no where clause.
    The block is queryable so users can filter the data to be retrieved.
    Each of the columns on the form have a button above which requeries the block, applying the order by (SET_BLOCK_PROPERTY ( 'B12', ORDER_BY, :bc1.h_b12_custom_orderby ); )
    The problem is that each time the block is requeried the user definied filter criteria is lost. Is there any way I can get a handle on this and maintain the filtering?
    GET_BLOCK_PROPERTY(item, DEFAULT_WHERE); only retrieves the query entered while in design mode so this won't work.
    I'm using Oracle Forms 6i, web based. Any suggestions are very much appreciated.
    Thanks in advance,
    Jay

    Many thanks for your response Hedy,
    Below is the procedure I used to achieve this.
    I found GET_BLOCK_PROPERTY ( p_block, LAST_QUERY ) worked better than :SYSTEM.last_query. As the first time it is called within a block :SYSTEM.last_query returned the query made in another block - which I'm sure has it's applications.
    Thanks again,
    Jay
    PROCEDURE set_last_query_where ( p_block IN VARCHAR2
    , p_where IN VARCHAR2 DEFAULT NULL )IS
    l_last_query VARCHAR2(10000);
    l_last_where VARCHAR2(10000);
    BEGIN
    IF p_where IS NULL THEN
    l_last_query := UPPER(GET_BLOCK_PROPERTY ( p_block, LAST_QUERY ));
    l_last_where := SUBSTR ( UPPER ( l_last_query),
    INSTR ( l_last_query, 'WHERE')+6, INSTR(SUBSTR(UPPER(l_last_query), INSTR(l_last_query, 'WHERE')+8), 'ORDER BY'));
    ELSE
    l_last_where := p_where;
    END IF;
    SET_BLOCK_PROPERTY ( p_block, DEFAULT_WHERE, l_last_where );
    EXCEPTION
         WHEN FORM_TRIGGER_FAILURE THEN
         ref_raise_ftf;
         WHEN OTHERS THEN
         ref_others( 'P-SLQW' );
    END;

  • Query Bean Where clause

    In Query Bean (Auto Customization Criteria) , OA FWK generate
    where clause automatically .
    I want to disable this criteria in some cases. Is there any way exists?
    (Disable means remove some condition )
    I want to see runtime query with where clause(In case of Query Bean) . Is there is any way to find out it?
    Thanks, Avaneesh

    You have couple of options to do this,
    1. You can use getCriteria API on the queryBean which will stop the query execution by framework and it's the responsibility of the developer to use the dictionary returned by getCriteria and bind the complete where clause yourself.
    2. You can use getNonViewAttrCriteria API on queryBean. This provides a dictionary of criteria on the column which are not mapped to a viewAttribute, for example if you want a poplist in the search region which has values like "Last one week", "Last 2 weeks", "Last 15 days" and so on and want to bind the criteria your self by interpreting the value selected.
    In this case, framework still binds the where clause for the other criteria's which are mapped to a vo based column in the table and expects the developer to bind the criteria for these non viewattribute mappings in the controller.
    I think your requirement fits in the second approach.

  • Query using where clause

    I am not able to run a SQL query using where clause.
    the query is as follows:
    I extract the text input by the user in a text field say 'a' and
    store it in string 'y'.
    String y= a.getText();
    //running the query
    Select A from B where B.x=y;
    how do we run a where clause when y is a string variable instead of value?

    Use the following :
    String y = a.getText();
    String query ="select A.CODE from Port A where A.NAME=" + "'" + y + "'" ;
    ResultSet rs= stmt.executeQuery(query);

  • Hierarchical query with where clause

    Hi,
    How can I query hierarchically a query with WHERE clause? I have a table with three fields session_id,id and root_id.
    When I try with the following query,
    select id, level from relation
    where session_id = 79977
    connect by prior id = root_id start with id = 5042;
    It gets duplicate values.
    I want the query to show in the hierarchical manner with a filter condition using WHERE clause. Please help me how can I achieve this. If you know any link that describes more about this, please send it.
    Thanks in Advance.
    Regards,
    -Parmy

    Hi Sridhar Murthy an others,
    Thanks a lot for your/the answer. It's working for me. It saved a lot of other work around without the proper knowledge of hierarchical query. Please send me any link that describes these issues in detail and also I hope as I have mentioned in the other message, same cannot be achieved on views or ( on two different tables ???)
    Any way thanks for your reply,
    It's working for me.
    With happiness,
    -Parmy

Maybe you are looking for

  • I'm on W7. How do I install Arch on a usb stick via Virtualbox?

    I want to make a bootable USB arch install I use on computers i don't trust and other such case scenarios. I get internet from my phone via wlan so i need to use Virtualbox to take andantage of it.

  • Based on a SQLException how to know if the database is down?

    Hi How can I know based on a SQLException that the database is down?. I know I can check the errorCode but which error codes indicate that the database is DOWN or not available? Regards, Néstor Boscán

  • Mandrake 8.0 Installer dosn't run

    I am try to installer under the new Mandrake release and have setup unix groups, env. when I try "./runInstaller", i tget some output in thw window but then nothing happens, ie the installer does not launch. Ideas anyone ?

  • I Lost Parallels After Archive and Install

    I posted this on the Parallels Forum, and although it was viewed 59 times, there were no replies. So I'm posting it here hoping that someone can/will answer my question. Here's what I posted: My OS X (10.4.11) became a little quirky after three years

  • Desk stand for the 11" Air

    I own the mid 2011 MacBook Air 4,1. It's the 11" model. When working at my desk, I have it hooked up to an external monitor, keyboard and mouse. I'm looking for a desk stand that would suit elevating the system to a comfortable eye height. Could anyo