Why does last fetch take so much longer than first three?

I have this trace file:
EXEC #3:c=0,e=4803,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=2726503091,tim=2779072194357
WAIT #3: nam='SQL*Net message to client' ela= 1 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=2845769927079
FETCH #3:c=0,e=2969,p=0,cr=56,cu=0,mis=0,r=1,dep=0,og=1,plh=2726503091,tim=2779072197438
WAIT #3: nam='SQL*Net message from client' ela= 1006 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=2845769931224
WAIT #3: nam='SQL*Net message to client' ela= 1 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=2845769931269
FETCH #3:c=0,e=322,p=0,cr=2,cu=0,mis=0,r=15,dep=0,og=1,plh=2726503091,tim=2779072198806
WAIT #3: nam='SQL*Net message from client' ela= 3733 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=2845769935348
WAIT #3: nam='SQL*Net message to client' ela= 0 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=2845769935423
FETCH #3:c=0,e=178,p=0,cr=2,cu=0,mis=0,r=15,dep=0,og=1,plh=2726503091,tim=2779072202692
WAIT #3: nam='SQL*Net message from client' ela= 3136 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=2845769938725
WAIT #3: nam='SQL*Net message to client' ela= 1 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=2845769938763
FETCH #3:c=410000,e=403256,p=0,cr=7354,cu=0,mis=0,r=13,dep=0,og=1,plh=2726503091,tim=2779072609065
STAT #3 id=1 cnt=44 pid=0 pos=1 obj=0 op='PARTITION RANGE SINGLE PARTITION: KEY KEY (cr=7414 pr=0 pw=0 time=0 us cost=7 size=9823 card=47)'
STAT #3 id=2 cnt=44 pid=1 pos=1 obj=0 op='PARTITION RANGE SINGLE PARTITION:   (cr=7414 pr=0 pw=0 time=0 us cost=7 size=9823 card=47)'
STAT #3 id=3 cnt=44 pid=2 pos=1 obj=590979 op='TABLE ACCESS BY LOCAL INDEX ROWID BA_PGM_SLS_DTL PARTITION: KEY KEY (cr=7414 pr=0 pw=0 time=0 us cost=7 size=9823 card=47)'
STAT #3 id=4 cnt=44 pid=3 pos=1 obj=590982 op='INDEX RANGE SCAN BA_PGM_SLS_DTL_PK PARTITION: KEY KEY (cr=7408 pr=0 pw=0 time=10 us cost=6 size=0 card=1)'
WAIT #3: nam='SQL*Net message from client' ela= 3104 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=2845770355048It looks to me like the first three fetches return 31 rows in very little time, but the last fetch takes about .4 seconds and does about 7354 buffer gets to get the remaining 13 rows. Does anyone have an idea what might cause this?
- Bobby

I goofed. The types of two of the bind variables got reversed:
Wrong type
VARIABLE V_PRIM_CUST_CNTL_LOCN VARCHAR2(10)
VARIABLE V_PRIM_CUST_NBR NUMBER
Right type
VARIABLE V_PRIM_CUST_CNTL_LOCN NUMBER
VARIABLE V_PRIM_CUST_NBR VARCHAR2(10)
Once I fixed this the query reads hardly any blocks at all just as I would expect. I guess the first three fetches got lucky and hit some blocks with matching data. The last fetch must have read through a bunch of index blocks needlessly because it wasn't using all the values in the where clause.
Here are the predicates with the right plan and wrong:
good
   4 - access("BPSD"."PGM_MSTR_NBR"=:V_PGM_MSTR_NBR AND "BPSD"."PGM_SEQ"=:V_PGM_SEQ AND
              "BPSD"."PMT_STS"=:V_PMT_STS AND "BPSD"."PRIM_CUST_CNTL_LOCN"=:V_PRIM_CUST_CNTL_LOCN AND
              "BPSD"."PRIM_CUST_NBR"=:V_PRIM_CUST_NBR AND "BPSD"."DIV_NBR"=:V_DIV_NBR AND
              "BPSD"."CUST_CNTL_LOCN"=:V_CUST_CNTL_LOCN AND "BPSD"."CUST_NBR"=:V_CUST_NBR AND
              "BPSD"."PRCS_DT"=TO_DATE(:V_PRCS_DT,'DD-MON-YYYY') AND "BPSD"."CR_MEMO_NBR"=:V_CR_MEMO_NBR AND
              "BPSD"."INV_NBR"=:V_INV_NBR)
bad
   4 - access("BPSD"."PGM_MSTR_NBR"=:V_PGM_MSTR_NBR AND "BPSD"."PGM_SEQ"=:V_PGM_SEQ AND
              "BPSD"."PMT_STS"=:V_PMT_STS AND "BPSD"."PRIM_CUST_CNTL_LOCN"=TO_NUMBER(:V_PRIM_CUST_CNTL_LOCN) AND
              "BPSD"."DIV_NBR"=:V_DIV_NBR AND "BPSD"."CUST_CNTL_LOCN"=:V_CUST_CNTL_LOCN AND "BPSD"."CUST_NBR"=:V_CUST_NBR AND
              "BPSD"."PRCS_DT"=TO_DATE(:V_PRCS_DT,'DD-MON-YYYY') AND "BPSD"."CR_MEMO_NBR"=:V_CR_MEMO_NBR AND
              "BPSD"."INV_NBR"=:V_INV_NBR)
       filter(("BPSD"."INV_NBR"=:V_INV_NBR AND "BPSD"."CUST_NBR"=:V_CUST_NBR AND
              TO_NUMBER("BPSD"."PRIM_CUST_NBR")=:V_PRIM_CUST_NBR AND "BPSD"."DIV_NBR"=:V_DIV_NBR AND
              "BPSD"."CR_MEMO_NBR"=:V_CR_MEMO_NBR AND "BPSD"."PRCS_DT"=TO_DATE(:V_PRCS_DT,'DD-MON-YYYY') AND
              "BPSD"."CUST_CNTL_LOCN"=:V_CUST_CNTL_LOCN))Having reviewed this I believe this is what Jonathan Lewis meant by a hidden coercion of the data type of one of the columns. The column PRIM_CUST_NBR had to be converted to a number to compare it with the mistyped bind variable and so none of the columns after that one in the index could be used in the range scan.
- Bobby
Edited by: Bobby Durrett on Jul 9, 2012 3:17 PM
Edited by: Bobby Durrett on Jul 10, 2012 8:23 PM

Similar Messages

  • Why does exporting take so much longer than in FCP7?

    With the same computer configuration I am getting three times the rendering time with I go to either the projectings settings defualt or h.264. Nothing had been background rendered but it was never in FCP7 either. It seems like any text or other overlayed graphics are really slowing this process down. Thoughts?

    That is not normal, but what is going on is hard to say without some testing.  It could be cache-related, if you've gotten some corruption in some important caches.  Try getting a copy of OnyX and clearing caches.  (Note that cache clearing should be considered a troubleshooting step only...  don't use such utilities for routine maintenance.)
    You could also have a dying hard drive.  That would not necessarily show up on hardware tests.  Sometimes drive failures show up in advance in hardware tests or SMART status checks, and sometimes they don't.  That could explain the excessive hard drive thrashing.  If this is the problem, there may not be any reasonable solution until the drive finally goes kaput, or decides to change to a detectable imminent failure.
    There could also be any number of other problems, such as low RAM, hard drive directory corruption, incompatible third-party software, etc.  Try some of the techniques in the Mac OS X Speed FAQ.

  • Why does my iMac take a lot longer to start than my Macair?

    I have both an iMac 24 inch circa 2008 & a Macair circa 2010, both running OS X 10.9.2. Wnen  starting up the Macair only takes moments whereas the iMac can take three or four minutes. Is there a reason for this?  It is really not much of a problem but has me wondering.

    I've done another scan of the disk and permissions repair. I had done it before but it didn't change anything.
    My dropbox is full, but it was long before I had this startup problem. I became slow after an OSX update (?).
    I get that kind of message on the console:
    com.apple.launchd (com.apple.systemStarter) failed to count the number of files in "system/library/Startup items": no such file or directory (14 times)
    and this:
    com.apple.WindowServer 14:18:57 iMac de Philippe.local WindowServer... <error>: KCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint5° to catch errors as they are logged.
    The next message is at 14:27:11

  • Why does my search take 60x-70x longer with X or XI than with v9?

    When I install Adobe Reader X (v10) or v11, I notice a huge degradation in search speed.  I first noticed this last year, and I just re-verified my results with the latest version (v11.0).  I don't know if this is unique to my system, or if you might have similar issues.
    I am using a wee Acer Aspire One netbook.  It has an Intel Atom processor and runs Windows XP SP3 at 1.6GHz with 1GB RAM.  I have a set of PDF files in which I search for articles.  There are 16 files, totalling 600MB, with about 800 pages in each PDF file.
    My test was to use Edit->Search to look for a single word across the entire set of files, with no other options specified.  Search returned 14 files with 54 instances.  I have a few saved timings:
    Adobe Reader v9.1.0     24 seconds.
    Adobe Reader v9.2.0     15 seconds.
    Adobe Reader v9.4.6     12 seconds.
    Adobe Reader v9.5.0     14 seconds.
    Adobe Reader v9.5.1     15 seconds.
    Adobe Reader v9.5.2     14 seconds.
    Adobe Reader v10.1.3   841 seconds.  (14m 01s)
    Adobe Reader v11.0.0   991 seconds.  (16m 31s)
    Un-installing v10 or v11 and re-installing v9.5 immediately restores the faster performance.
    Any suggestions on what might be causing this difference?  I would welcome upgrading to X or XI if this could be solved.

    RESOLVED! 
    The prior poster inspired an experiment.  Under Edit->Preferences (Search), I clicked the "Purge Cache Contents" button, and "Poof!", the fast speeds for v9 disappeared and v9 behaved the same I had seen with v10/v11 -- 17 minutes for a full search.  After running about 8 full searches, the v9 times dropped back down to 20 seconds!  Reader was building indexes to speed the searches.
    I reinstalled v11 and clicked "Purge Cache Contents" once more.  After about 8 full searches (17 min each), the time for v11 dropped to 20 seconds!  When I reinstalled v9, it was immediately quick.  When I then reinstalled v11 again, it was immediately quick.
    I looked at more forums and read that indexes created by v9 could not be used by v10 and v11, but that indexes created by v10 or v11 would work correctly with v9.  Purging the cache contents made sure my v9 cache entries were eliminated, and then Reader could become as quick it was designed to be.
    Thanks for your comments.

  • Why does the library image look much better than develop image?

    I'm noticing a huge difference in IQ even after post processing between the library image and the develop image within Lightroom 2.1 itself. Any reason why? Thanks.

    In what way? The Library image is just a rendering of the Develop image. In Develop, the sharpening and noise reduction are only applied at the 1:1 view to speed it up and to not lie to you (which it would if shown at lower magnification).

  • Grey screen takes way much longer than before.

    It just happened out of the blue. One minute I'm surfing the net finder freezes and restarts my computer then a folder with a question mark appears and doesn't boot up. I turn it off and on again, this time the apple appears but it takes at least 10 minutes to start up. Help please.

    I would pay attention to a failing hard drive. Do a backup asap. DiskWarrior or similar utility should be a next step.
    Bob
    Message was edited by: Bob Bujic

  • Why does my ipad recharge to much less than 100%

    When I recharge my iPad II it recharges to from 65 to 85 % instead of 100%. I wondering why.

    Try resetting...
    Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
    http://support.apple.com/kb/ht1430
    iPad Charging
    "The fastest way to charge your iPad is with the included 10W USB Power Adapter.
    iPad will also charge, although more slowly, when attached to a computer with a high-power USB port (many recent Mac computers) or with an iPhone Power Adapter.
    When attached to a computer via a standard USB port (most PCs or older Mac computers) iPad will charge, but only when it's in sleep mode.
    Make sure your computer is on while charging iPad via USB. If iPad is connected to a computer that’s turned off or is in sleep or standby mode, the iPad battery will continue to drain."
    See...  http://support.apple.com/kb/HT4060
    Ipad Battery About Best Practice
    http://www.apple.com/batteries/ipad.html

  • Why does Time Machine take forever?

    Just using Time Machine for the first time today. It's been running for nearly four and half hours, only displaying "Indexing backup..." with no progress indication at all. Does it really take this monumentally long the first time you use it?
    Sorry if this question is redundant... I find the new Apple discussions board absolutely horrible to use... use to be super easy to search thru previous posts but it seems like the new search function can't find anything. (Another case of a company fixing something that wasn't broken and ruining it in the process.)

    peteratomic wrote:
    Just using Time Machine for the first time today. It's been running for nearly four and half hours, only displaying "Indexing backup..." with no progress indication at all. Does it really take this monumentally long the first time you use it?
    Yes. It must copy the entire contents of your hard drive to the backup. Are you backing up to a networked drive like a Time Capsule? If so, it will take even longer. Don't bother trying it without connecting via ethernet cable first. Event then it will take overnight. Subsequent backups are very small and will work fine over WiFi, even faster with a directly connected disk.
    Sorry if this question is redundant... I find the new Apple discussions board absolutely horrible to use... use to be super easy to search thru previous posts but it seems like the new search function can't find anything. (Another case of a company fixing something that wasn't broken and ruining it in the process.)
    Apple doesn't bother trying to be everything to everyone. They make the best products they can in what they think is the best way. If you think that is horrible and broken, you are free to go elsewhere. Searching for this topic is definitely something I would consider super easty. I was quite familiar with the old system and the old search engine. It was profoundly broken and useless.

  • Why is my wi-fi greyed out?  Why does battery not hold charge for more than a few hours?  All since IOS7.

    Why is my Wi-Fi greyed out?   Why does battery not hold a charge longer than a few hours?  All since upgrade to IOS 7.

    To validate the operating system and radio software complete the following steps:
    Tap Settings > About.
    In the Category drop-down menu, select  OS.
    Ensure the Radio Version is only 1 number higher than the  OS Version.
    If not then follow this
    http://www.blackberry.com/btsc/KB34666
    Click here to Backup the data on your BlackBerry Device! It's important, and FREE!
    Click "Accept as Solution" if your problem is solved. To give thanks, click thumbs up
    Click to search the Knowledge Base at BTSC and click to Read The Fabulous Manuals
    BESAdmin's, please make a signature with your BES environment info.
    SIM Free BlackBerry Unlocking FAQ
    Follow me on Twitter @knottyrope
    Want to thank me? Buy my KnottyRope App here
    BES 12 and BES 5.0.4 with Exchange 2010 and SQL 2012 Hyper V

  • Fetching null records out of a function takes much longer than non-null

    Hi,
    We have a function that is called thousands of times on SQL. This function has a SELECT than can return one row at max.
    We realized that when the SQL statement doesn't return any record, it takes 3x times longer in the fetch phase.
    I made a simple test with three functions were each one was executed 1000 times. The first one has an extra outer join that guarantees that it always returns one record, a second one with an explicit cursor that can return 0 records and a third one with an implicit cursor that can also return 0 records.
    Here is the sample test code:
    DECLARE
    -- Local variables here
    CURSOR c IS
    SELECT teste_vasco.teste_vasco1(epis.id_episode) as val
    FROM episode epis
    WHERE rownum <= 1000;
    TYPE t_c IS TABLE OF c%ROWTYPE;
    l_c t_c;
    BEGIN
    -- Test statements here
    OPEN c;
    FETCH c BULK COLLECT
    INTO l_c;
    CLOSE c;
              for i in l_c.first..l_c.last
              loop
              dbms_output.put_line(i || ' :' || l_c(i).val);
              end loop;
    END;
    The difference between the tests is that instead of calling the vasco1 function, vasco2 and vasco3 is called.
    ###Test1
    -Function vasco1:
    FUNCTION teste_vasco1(i_episode IN episode.id_episode%TYPE) RETURN VARCHAR2 IS
    l_dt_set TIMESTAMP WITH LOCAL TIME ZONE;
    l_flg_stage VARCHAR2(3);
    l_dt_warn TIMESTAMP WITH LOCAL TIME ZONE;
    CURSOR c_care_stage IS
    SELECT cs.dt_set, cs.flg_stage, cs.dt_warn
    FROM episode epis
    LEFT JOIN care_stage cs ON (cs.id_episode = epis.id_episode AND cs.flg_active = 'Y')
    WHERE epis.id_episode = i_episode;
    BEGIN
    OPEN c_care_stage;
    FETCH c_care_stage
    INTO l_dt_set, l_flg_stage, l_dt_warn;
    CLOSE c_care_stage;
    IF l_dt_set IS NULL
    THEN
    RETURN NULL;
    END IF;
    RETURN l_dt_set || l_flg_stage || l_dt_warn;
    EXCEPTION
    WHEN OTHERS THEN
    pk_alert_exceptions.raise_error(error_code_in => SQLCODE, text_in => SQLERRM);
    pk_alert_exceptions.reset_error_state;
    RETURN NULL;
    END teste_vasco1;
    -Trace file:
    SELECT TESTE_VASCO.TESTE_VASCO1(EPIS.ID_EPISODE) AS VAL
    FROM
    EPISODE EPIS WHERE ROWNUM <= 1000
    call count cpu elapsed disk query current rows
    Parse 1 0.01 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 1 0.04 0.06 0 8 0 1000
    total        3      0.06       0.07          0          8          0        1000
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 286 (recursive depth: 1)
    Rows Row Source Operation
    1000 COUNT STOPKEY (cr=8 pr=0 pw=0 time=2035 us)
    1000 INDEX FAST FULL SCAN EPIS_EPISODE_INFO_UI (cr=8 pr=0 pw=0 time=1030 us)(object id 153741)
    SELECT CS.DT_SET, CS.FLG_STAGE, CS.DT_WARN
    FROM
    EPISODE EPIS LEFT JOIN CARE_STAGE CS ON (CS.ID_EPISODE = EPIS.ID_EPISODE AND
    CS.FLG_ACTIVE = 'Y') WHERE EPIS.ID_EPISODE = :B1
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1000 0.07 0.05 0 0 0 0
    Fetch 1000 0.01 0.02 0 4001 0 1000
    total     2001      0.09       0.07          0       4001          0        1000
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 286 (recursive depth: 2)
    ###Test2
    -Function vasco2:
    FUNCTION teste_vasco2(i_episode IN episode.id_episode%TYPE) RETURN VARCHAR2 IS
    l_dt_set TIMESTAMP WITH LOCAL TIME ZONE;
    l_flg_stage VARCHAR2(3);
    l_dt_warn TIMESTAMP WITH LOCAL TIME ZONE;
    CURSOR c_care_stage IS
    SELECT cs.dt_set, cs.flg_stage, cs.dt_warn
    FROM care_stage cs
    WHERE cs.id_episode = i_episode
    AND cs.flg_active = 'Y';
    BEGIN
    OPEN c_care_stage;
    FETCH c_care_stage
    INTO l_dt_set, l_flg_stage, l_dt_warn;
    IF c_care_stage%NOTFOUND
    THEN
    CLOSE c_care_stage;
    RETURN NULL;
    END IF;
    CLOSE c_care_stage;
    IF l_dt_set IS NULL
    THEN
    RETURN NULL;
    END IF;
    RETURN l_dt_set || l_flg_stage || l_dt_warn;
    EXCEPTION
    WHEN OTHERS THEN
    pk_alert_exceptions.raise_error(error_code_in => SQLCODE, text_in => SQLERRM);
    pk_alert_exceptions.reset_error_state;
    RETURN NULL;
    END teste_vasco2;
    -Trace File:
    SELECT TESTE_VASCO.TESTE_VASCO2(EPIS.ID_EPISODE) AS VAL
    FROM
    EPISODE EPIS WHERE ROWNUM <= 1000
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 1 0.00 0.27 0 8 0 1000
    total        3      0.00       0.27          0          8          0        1000
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 286 (recursive depth: 1)
    Rows Row Source Operation
    1000 COUNT STOPKEY (cr=8 pr=0 pw=0 time=2048 us)
    1000 INDEX FAST FULL SCAN EPIS_EPISODE_INFO_UI (cr=8 pr=0 pw=0 time=1045 us)(object id 153741)
    SELECT CS.DT_SET, CS.FLG_STAGE, CS.DT_WARN
    FROM
    CARE_STAGE CS WHERE CS.ID_EPISODE = :B1 AND CS.FLG_ACTIVE = 'Y'
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1000 0.03 0.05 0 0 0 0
    Fetch 1000 0.00 0.00 0 2001 0 1
    total     2001      0.03       0.06          0       2001          0           1
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 286 (recursive depth: 2)
    Rows Row Source Operation
    1 TABLE ACCESS BY INDEX ROWID CARE_STAGE (cr=2001 pr=0 pw=0 time=11082 us)
    1 INDEX RANGE SCAN CS_EPIS_FACT_FST_I (cr=2000 pr=0 pw=0 time=7815 us)(object id 688168)
    ###Test3
    -Function vasco3
    FUNCTION teste_vasco3(i_episode IN episode.id_episode%TYPE) RETURN VARCHAR2 IS
    l_dt_set TIMESTAMP WITH LOCAL TIME ZONE;
    l_flg_stage VARCHAR2(3);
    l_dt_warn TIMESTAMP WITH LOCAL TIME ZONE;
    BEGIN
    BEGIN
    SELECT cs.dt_set, cs.flg_stage, cs.dt_warn
    INTO l_dt_set, l_flg_stage, l_dt_warn
    FROM care_stage cs
    WHERE cs.id_episode = i_episode
    AND cs.flg_active = 'Y';
    EXCEPTION
    WHEN no_data_found THEN
    RETURN NULL;
    END;
    IF l_dt_set IS NULL
    THEN
    RETURN NULL;
    END IF;
    RETURN l_dt_set || l_flg_stage || l_dt_warn;
    EXCEPTION
    WHEN OTHERS THEN
    pk_alert_exceptions.raise_error(error_code_in => SQLCODE, text_in => SQLERRM);
    pk_alert_exceptions.reset_error_state;
    RETURN NULL;
    END teste_vasco3;
    -Trace file:
    SELECT TESTE_VASCO.TESTE_VASCO3(EPIS.ID_EPISODE) AS VAL
    FROM
    EPISODE EPIS WHERE ROWNUM <= 1000
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 1 0.25 0.27 0 8 0 1000
    total        3      0.25       0.27          0          8          0        1000
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 286 (recursive depth: 1)
    Rows Row Source Operation
    1000 COUNT STOPKEY (cr=8 pr=0 pw=0 time=2033 us)
    1000 INDEX FAST FULL SCAN EPIS_EPISODE_INFO_UI (cr=8 pr=0 pw=0 time=1031 us)(object id 153741)
    SELECT CS.DT_SET, CS.FLG_STAGE, CS.DT_WARN
    FROM
    CARE_STAGE CS WHERE CS.ID_EPISODE = :B1 AND CS.FLG_ACTIVE = 'Y'
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1000 0.07 0.06 0 0 0 0
    Fetch 1000 0.00 0.00 0 2001 0 1
    total     2001      0.07       0.06          0       2001          0           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 286 (recursive depth: 2)
    Rows Row Source Operation
    1 TABLE ACCESS BY INDEX ROWID CARE_STAGE (cr=2001 pr=0 pw=0 time=11119 us)
    1 INDEX RANGE SCAN CS_EPIS_FACT_FST_I (cr=2000 pr=0 pw=0 time=7951 us)(object id 688168)
    As you can see, in the first example the fetch time of the SELECT in the function vasco1 takes 0.02 seconds and 0.06 in the SELECT of the test script. This test returned 1000 non-null records.
    In the tests 2 and 3, the fetch phase of the SELECT in the test script takes much more time - 0.27 seconds, despite the fetch of the SELECT in the functions (vasco2 and vasco3) took 0.00 seconds (as it only returned 1 row for the 1000 executions) and the only difference between them is the function that is called. Both test2 and test3 returned 999 null records and 1 non-null record.
    How it's possible than a select null records takes much longer than selecting non-null records?
    Hope you can understand the problem and thank you in advance for any help or suggestions.

    Thank you for the replies...
    But the thing is that the SELECT in the function is very fast and the fetch phase takes no time (0.00 second).
    And, as you can see in the execution plan, there's no need for a full index scan...only a range scan is performed:
    SELECT CS.DT_SET, CS.FLG_STAGE, CS.DT_WARN
    FROM
    CARE_STAGE CS WHERE CS.ID_EPISODE = :B1 AND CS.FLG_ACTIVE = 'Y'
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1000 0.07 0.06 0 0 0 0
    Fetch 1000 0.00 0.00 0 2001 0 1
    total     2001      0.07       0.06          0       2001          0           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 286 (recursive depth: 2)
    Rows Row Source Operation
    1 TABLE ACCESS BY INDEX ROWID CARE_STAGE (cr=2001 pr=0 pw=0 time=11119 us)
    1 INDEX RANGE SCAN CS_EPIS_FACT_FST_I (cr=2000 pr=0 pw=0 time=7951 us)(object id 688168)
    But, the fetch phase of the SQL that calls the function that has this query takes 0,27 seconds.
    As far as the contex switch, we are aware of that, but we can have modularity with this solution and the first function also have many context switching and is must faster.
    Edited by: Pretender on Mar 18, 2009 3:38 PM

  • Why does my FaceTime take long to connect and still does nothing

    why does my FaceTime take long to connect and still does nothing

    Apple has released a document which is reported to address the recent FaceTime issue.
    http://support.apple.com/kb/TS5419

  • Why does iPhone videos take so long to come up on the Apple TV?

    Why does iphone videos take so long to come up on the apple tv?
    1080P has a large file size but are there ways to get it to start to play faster?
    Hard wiring it into the LAN helped a bit but what is really slowing it down? WPA2?
    Thanks,

    could be the wifi speed as in 56Mbit vs. newer 300Mbit version
    or interfearing from other wifi networks which use the same channel
    or microwave or dect phones which also operate on the 2.4Ghz band

  • Why does apple tv take hours to record

    Why does Apple TV take hours to record movies?

    Not sure what you mean by 'record movies'
    If you are trying to rent a movie and it's taking a long time before it starts then that is due to your connection.
    720P requires 6mbps for instant streaming
    1080P requires 8mbps
    You can switch to SD in the settings
    To check your connection go to speedtest.net

  • TS3276 When I send an email no matter how small it now seems to take a much longer time than usual (by watching the gear wheel spinning). Anyone have any ideas how I can get my sending back to a much shorter time?

    When I send an email no matter how small it now seems to take a much longer time than usual (by watching the gear wheel spinning). Anyone have any ideas how I can get my sending back to a much shorter time?

    Have you burned Discs with other programs using this computer? Are you certain that you have a drive that will burn discs?

  • Why does my iBook connect to WiFi better than my much faster Macbook?

    Why does my iBook connect to WiFi better than my much faster Macbook?

    Because it has a RISC processor. Just brag about all the MHz or even GHz while you are waiting like other Intel users. Using my trusty G4 rather than MBP becase its simply faster.
    /usr/bin/gcc-4.4 -mcpu=G4 -mpowerpc-gfxopt -maltivec -mabi=altivec -fsigned-char

Maybe you are looking for