How can we specify the order of the predicates execution?

I am going to write the following query
select answer, answer_id from surveys s join answers a on s.survey_id = a.survey_seq_id
where question_uid = 206400374 and insertdate = to_date('31/12/2012') and answer > 0;However, when I look at the execution plan, I see that the last predicate (to_number(answer) > 0) has been executed the first. Henceforth, it checks many rows first. Normally, 75 rows belong to 31/12/2012 as you see from the following. Can I specify the execution order?
select count(*) from surveys s join answers a on s.survey_id = a.survey_seq_id
where question_uid = 206400374 and insertdate = to_date('31/12/2012');
COUNT(*)
75If so, how? Because, the type of answer is varchar2 and some of answers contain text characters such as 'Yes' or 'No'. Therefore, before 31/12/2012 some answers contain 'Yes' or 'No'. However in 31/12/2012 all answers are numeric.
Plan hash value: 3217836037
| Id  | Operation          | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT   |         |     2 |    68 |  9401   (1)| 00:01:53 |
|*  1 |  HASH JOIN         |         |     2 |    68 |  9401   (1)| 00:01:53 |
|*  2 |   TABLE ACCESS FULL| SURVEYS |     2 |    26 |   239   (1)| 00:00:03 |
|*  3 |   TABLE ACCESS FULL| ANSWERS |   337 |  7077 |  9162   (1)| 00:01:50 |
Predicate Information (identified by operation id):
   1 - access("S"."SURVEY_ID"="A"."SURVEY_SEQ_ID")
   2 - filter("S"."INSERTDATE"=TO_DATE(' 2012-12-31 00:00:00',
              'syyyy-mm-dd hh24:mi:ss'))
   3 - filter("A"."QUESTION_UID"=206400374 AND
              TO_NUMBER("A"."ANSWER")>0)
select distinct answer from surveys s join answers a on s.survey_id = a.survey_seq_id
where question_uid = 206400374 and insertdate = to_date('31/12/2012');
ANSWER
1
3
0
2And, also I can execute the following query without any error
select to_number(answer) from surveys s join answers a on s.survey_id = a.survey_seq_id
where question_uid = 206400374 and insertdate = to_date('31/12/2012');

In answer to your original question:
970992 wrote:
However, when I look at the execution plan, I see that the last predicate (to_number(answer) > 0) has been executed the first. Henceforth, it checks many rows first. Normally, 75 rows belong to 31/12/2012 as you see from the following. Can I specify the execution order?According to the execution plan, it will do a full scan of surveys using the predicate on insertdate to build the (presumably in-memory) hash table (hash based on survey_id) to do the joins (Step 2). Then, it does a full scan of the answers table using the question_uid and answer predicates (Step 3). For each row it finds that matches those predicate, it will prpobe the hash table created in step 2 using the hashed value of survey_seq_id. So, it is doing the insertdate predicate first.
In answer to your last post
970992 wrote:
>
First of all i would get rid of the implizit type conversion:
TO_NUMBER("A"."ANSWER")>0)it is not implicit conversion, I reckon it is explicit type conversion, isnt it?
No, it is an implicit type conversion. Your code says answer > 0, since the answer column is a varchar2 column, Oracle implicitly converts the answer column to a number to compare against the number on the right side of the comparison. Note that if something like 'A' ever becomes a valid answer, then this query will fail with ORA-01722: invalid number.
>
>
Obviously "A"."ANSWER" is not a number colmun, problably varchar, so use something like
A.ANSWER != "0"
or
A.ANSWER > "0"Yes answer column is varchar2 but can you type A.ANSWER > "0" as a predicate? I mean, you can not varchar > varchar, can you?
Of course you can use inequality predicates on a varcahr column. Is the string A greater than the string B?
Based on the explain plan, your statistics might be a little off, not hugely so. The esitmates are at least in the right order of magnitude based on what you have posted so far.
What indexes, if any, are available on the two tables?
John

Similar Messages

  • How can I print an order from the PCUI

    Hallo,
    have anybody an idea how I can print an order from the PC UI. The Print Button does'nt work.
    best regards
    Stephan Holzschuh

    I think SAP have changed the hardcoded PRINT event to BTX_PRINT event. Try to change this event in your blueprint table. (See 850647 oss note)

  • Entity Finder mothod takes run time String. How can I specify in CDATA of the weblogic-cmp-ejb-jar.xml

    Hi everyone,
    I have an CMP bean which has findByName(String). During deployment of the ejb
    I tell the bean use the WLQL such as
    (like string%), but I would like to pass the name when the user enter in the text
    box of the .html page then the user click on search, the servlet is called and
    process using ejb technique. If I specified (like Fre%) in the ejb despcriptor
    for one particular case( such as looking for all Fred's), it will not work for
    the user enters smith.
    for example: user enter: Fre in the text box.
    I would like to have the bean do the query for me like:
    --> select * from user where lastName like Fre%
    If I cannot tell in the CDATA field, does that mean I have to use BMP to write
    query that takes the name.
    Please help,
    Thanks in advance.

    Thanks Jim,
    I did exactly like in the example (like Name $0) Name is my cmp field, but this
    time it always returns one entity (same entity )regardless what I entered to search
    by name. So that means it did not take the parameter that defined in <find-param>
    of the weblogic-cmp-rdbm-jar.xml. Do you have any suggestion or idea to overcome
    this problem.
    Thanks Jim,
    Tom
    Jim Weaver <[email protected]> wrote:
    >
    Tom
    You can use like with a String parameter in WLQL. There is an example
    in our
    documentation at
    http://www.weblogic.com/docs51/classdocs/API_ejb/EJB_environment.html#1022700
    Thanks
    Jim
    Tom wrote:
    Hi everyone,
    I have an CMP bean which has findByName(String). During deploymentof the ejb
    I tell the bean use the WLQL such as
    (like string%), but I would like to pass the name when the user enterin the text
    box of the .html page then the user click on search, the servlet iscalled and
    process using ejb technique. If I specified (like Fre%) in the ejbdespcriptor
    for one particular case( such as looking for all Fred's), it will notwork for
    the user enters smith.
    for example: user enter: Fre in the text box.
    I would like to have the bean do the query for me like:
    --> select * from user where lastName like Fre%
    If I cannot tell in the CDATA field, does that mean I have to use BMPto write
    query that takes the name.
    Please help,
    Thanks in advance.Content-Description: Card for Jim Weaver
    begin:vcard
    n:Weaver;Jim
    x-mozilla-html:FALSE
    org:BEA Systems Inc.
    adr:;;.;;;;
    version:2.1
    email;internet:[email protected]
    title:Developer Relations Engineer
    fn:Jim Weaver
    end:vcard

  • How can FRT be backordered but not the phone ???

    So I ordered my iPhone through direct fullfillment on 7/19. This morning (7/28) I checked the status of my order, and it showed that the phone is no longer back-ordered but the FRT is. From what I understand, the FRT is the shipping. How can that be back-ordered if the phone isn't any longer.
    Do you think this means my phone will ship soon ?

    Well yes I guess an AT&T forum would probably be the best for this question.
    I have seen many other board members though QUESTION, GRIPE, & COMPLAIN about their woes of trying to actually get their iPhone. I figured this is like one big family, your allowed to complain about things slightly off topic to get some answers.

  • How can I specify an SFTP directory path that has spaces in it?

    The directory (path) on my SFTP server has spaces in some of the folder names: e.g. /data/Cisco Products/UC Applications/
    How can I specify this path in the directory field of a remote server definition if I want to upload files from my SFTP server to the CUCM?
    I've tried surrounding the whole path in quotes, %, *, backslash space, point, hash...running out of things to try. Must be possible...surely?!#
    Thank-you
    -Rob.

    I haven't tried this but when i hit tab to auto complete on a linux machine i notice a space and backslash between two words. I can see you tried backslash space. Try space backspace - <word><space><backslash><word>

  • How can I get iTunes to display the tracks from a CD in their original (album) order?

    To be absolutely honest, I don't really understand what this box is for, so I shall just use it to repeat and expand on my question. (I have already sent a "Feedback" comment on the same topic).
    How can I get iTunes to display the tracks from a CD in their original (album) order?
    It seems to me that there is something very basic wrong with the way iTunes handles CD Tracks.
    Professionally produced CD tracks are seldom if ever in a randomised order. Why then does iTunes seem unable to display the tracks in the order they appear on the original CD source - whether from a personally owned CD or from a download from the iTunes Store?
    Some music demands a specific, non-alphabetic sequence in order to make sense. Why does it seem that iTunes only offers Alphabetic, or reverse alphabetic order - both of which make a nonsense of the original, often intended order of tracks?
    Why not replace the so-called "cover-art" in the bottom left hand corner if the iTunes window - which, while it may look attractive to some, gives the barest of information concerning the original disc, with a list of the original CD tracks in their original order, so that the user can easily reestablish the order in which they should be played.
    As I would expect legibility might be a problem with doing this, why could not the original contents, (in their original order), at least, be displayed when the "cover art" is double clicked-on - the result of which at present gives me an enlarged version of the "Cover Art". While on the subject of the contents of the source disc, what about all the album notes which someone takes trouble to write in order to increase the appreciation of the music on the CD and the listener's general background knowledge of the artists involved. Such notes, it seems to me, have considerable intrinsic value in their own account. I would, I think, normally be prepared to buy such "Sleeve notes" - so long as a "taster" was supplied (as it is for the music) - for something like the cost of a single 'Tune" on iTunes.
    These two aspects let Apple iTunes down enormously, in my opinion. I think that by chopping even quite protracted sequences of music up into bits does no one any favours - except perhaps Apple's already quite substantial bank balance. People have to be aware that two and a half, to three and a half minutes is a very short time to develop a piece of worthwhile music, and that there are many, many composers, not all of whom are alive today who have written music that huge masses of mankind value for the enrichment of their lives and the human condition in general.
    Please make the viewing of iTunes tracks in their correct order by default possible. By all means have the alphabetical variations available as offering a different approach to the music, but not the sole approach to it - PLEASE.
    Frustratedly yours
    Alan Whitaker
    PS I work at my old 24" iMac Intel Core 2 machine which runs OS "Tiger" - because it is more beautiful to look at, the screen is more pleasant to work on, and because, in some ways it is more capable (it will run FreeHand MX without needing a "patch"), than my more recent 21.5" which runs "Snow Leopard". (I don't find it that much slower, either).

    Dear Mike
    Thanks for the support. I am utterly amazed that after all the hype about how good iTunes is that it cannot play a downloaded CD in the correct order, and that what that order should be is not available directly from within one's own iTunes installation. (I know that one can go back to the iTunes Store to check what the order should be, but having downloaded the tracks surely iTunes is clever enough to retrieve this important information.
    My iTunes to differ from yours in that I have also noticed that it seems unable to download copies of my "talking books" in the correct order either. But in my case it downloads them - from a CD - in order, but with the first track downloaded first - so that it appears at the bottom of the column of tracks so that it would get played last! (At least this is, while being inexplicable, a relatively "logical" bit of blundering and because of this is relatively easy to put right!).
    I like many genres of music, some of which are not really programmed except perhaps by the artist performing them. I know that Frank Sinatra was very careful to programme his album songs to obtain a particular effect and in relation to the keys of the music. iTunes presumes to know better.
    Film scores may be totally randomly put together, in some cases, but in others the order is vital to one's appreciation of the music as a whole and how it relates to the plot of the film.
    In symphonic music most works are divided into sections and are conceived by the composer that way. Some individual sections may gain a life of their own if played separately, but they are never complete in the sense that the composer envisaged them without being placed in their proper context.
    Opera and probably most choral music too, is similar except that the words may well become meaningless if the order is changed at the whim of a piece of ill-written computer code, while ballet music has to be heard totally within its sequential context or it becomes meaningless.
    Finally, I would venture that iTunes, by jumbling up the order of the tracks as recorded on a CD, does an immense disservice, not only to the music on a particular CD, but to music in general, by expressing everything in terms of "Songs" - which it seems to interpret as stand-alone items of between 2 and 4 minutes whatever the genre. Even the way the iTunes publicity speaks of how many "songs" it can store instead of how many minutes or hours of recorded sound. This has to be another brick in the wall of "dumming-down" of people's expectations, and the shortening of their attention spans.
    I don't know about anyone else, but I feel betrayed by Apple over this. Perhaps the look, feel and general presentation of an item are not the most desirable features of a consumer product. Maybe it should be judged more on it fitness for the purpose for which it was sold. There is one other possibility - that Apple are trying to redefine "Music" - and that everything that lasts longer than about 3.5 minutes or is in the form of what could for want of a better term be called symphonic in the broadest sense is something else - not "Music" within Apple's new definition, at all!
    Well that's off my chest! now I can get down to creating some sort of order in my iTunes Libraries, knowing that I have to reconsult all the sources in order to confirm the source playing order.
    Anyway thanks again. At least I know that it is not just me
    alanfromthatcham

  • You changed the order of the menu for "Open in a new window" or "Open in new Tab", How can I change it back? Or how can I omit any reference to tabs? I do not use them at all.

    You changed the order of the menu for "Open in a new window" or "Open in new Tab", How can I change it back? Or how can I omit any reference to tabs? I do not use them at all.

    You can use the Menu Editor add-on to rearrange or remove menu items - https://addons.mozilla.org/firefox/addon/menu-editor

  • How can we specify the Mailbox for Notes?

    In Mail.app, how can we specify the Mailbox for Notes (where the new notes will be resided)? It is now 'On My Mac'. I wish to change to my IMAP Mailbox so it sync with my iPhone by just checking email (not by syncing on iTunes).
    Thanks in advance.
    Message was edited by: Ekapon

    You could use the DecimalFormat or NumberFormat to do the job.
    double number 1234.567;
    DecimalForamt df = new DecimalFormat("###.##");
    String s = df.format(number);or
    double number 1234.567;
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMaximumFractionDigits(2);
    /* if needed.
       nf.setMaximumIntegerDigits(value);
       nf.setMinimumFractionDigits(value);
       nf.setMinimumIntegerDigits(value); */
    String s = nf.format(number);I didn't test the codes but they should work. For more information, please consult the documentations.

  • TS4020 I live in a house with multiple iCloud users.  When they try to turn on "Find my computer"  they get the message that they will have to disable my "find my computer" setting in order to enable theirs.  How can they all be enabled at the same time?

    I live in a house with multiple iCloud users.  When they try to turn on "Find my computer"  they get the message that they will have to disable my "find my computer" setting in order to enable theirs.  How can they all be enabled at the same time?

    Try this support document for information on how to contact Apple and account security. Apple ID: Contacting Apple for help with Apple ID account security

  • How can I gift a playlist, with the songs in the order I choose?

    How can I gift a playlist, with the songs in the order I choose, to a bunch of other people? Since iTunes won't allow me to burn a song more than a few times to disc, and I have to share playlists with my cover band (so we can learn songs), I need the capability to do this.

    Drag them from where? I've tried to drag them from windows explorer and it won't allow me. It seems the only place I can drag files from is from the iTunes library list. The problem is there is no way that I can find to just see the songs from a specific folder on my drive in the iTunes library list. It sorts them by artist, album, genre, etc....but not by folder.

  • How can I send multiple pictures to the Kodak link (under file & then order prints)? if the photos are not sequential can it be done?

    how can I send multiple pictures to the Kodak link (under file & then order prints)?  if the photos are not sequential can it be done?

    Does the order matter here?Because the photos will be sent for printing. If there is any other reason, can you please cite example.

  • How can I specify the default tab in a CHM Output?

    My company uses CHM-based help for some of its products. We build the CHM files from RoboHelp 9, and while these CHM files don't really have a full Index attached to them, the Index tab shows up in the output anyway. Unfortunately, we are suddenly seeing that when the CHM file is launched from our program, the Index tab is displayed by default. We'd rather have the Contents tab be the default look, especially considering that the Index does not exist.
    I have poked around into how you can specify a default tab for a CHM file, and the only information I have found suggests that using a CHM file creates a file (HH.dat) that specifies which tab should be displayed on a user-by-user basis, and that the last tab displayed when you close the CHM should be the first one displayed when you re-open it. While this is true if you open the CHM independent from the product, when you launch it from our program, it's all Index, all the time.
    So, my question is: How can I specify the default tab for a CHM file? Or, failing that, how can I excise the Index tab from my CHM output.

    Hi there
    This will be something up to your application developer to resolve. When s/he issues the call to open the CHM, there are parameters that may be used to always open with the desired tab "in front".
    Point your developer to the link below and advise that s/he is most likely interested in the section titled: Programming Tips.
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • How can I hide or make visible the fields at the order and at the delivery?

    How can I hide or make visible the fields at the order and at the delivery?
    Thanks in advance.

    Hi,
    For sales order, use user exit :
    MV45AFZZ and FORM userexit_field_modification.
    For deliveries, use BADI :
    LE_SHP_DELIVERY_PROC (see with Tcode SE18) and method CHANGE_FIELD_ATTRIBUTES.
    Create implementation in ref to this badi with Tcode SE19.
    Regards,
    Lionel

  • I ordered Illustrator for another user.  I received an invitation that was accepted, logged in and tried to change the account to the name and email of the person it was ordered for.  How can I get this changed and the invitation sent to the right person?

    I ordered Illustrator via creative cloud for another user.  I received an invitation that was accepted  and tried to change the account to the name and email of the person it was ordered for.  How can I get this changed and the invitation sent to the right person? 

    Cloud as a Gift https://forums.adobe.com/thread/1665610

  • How can I change the order of the photos in a slide show I have created on my iPad mini?

    How can I change the order of the photos I have selected in a slide show on my iPad Mini?

    Currently, the order in which the phone numbers appear (in a contact) is dependent on the sequence to which you enter them. There is no way to change that order other than re-entering them in the desired order.

  • How can I change the order of the songs listed in a playlist?

    How can I change the order of the songs listed in a playlist?

    Hello Pokerplayer62,
    In order to update the order of items in your playlists on the iPod Nano, you have to update them on the computer, and then sync the updated playlists to your device.
    From the iPod Nano User guide here: http://manuals.info.apple.com/en_us/ipod_nano_features_guide.pdf
    To set iTunes to update iPod nano automatically with selected playlists:
    Open iTunes and select iPod nano in the Source list. Click the Options button and click Music.
    Select “Automatically update selected playlists only.” Select the playlists you want.
    All the best,
    Sterling

Maybe you are looking for