Query Hangs in Apex but runs quickly in SQL

Hi,
I'm using Apex version 4.1.
I have an interactive report that just hangs when I run it, but the query runs in about 19 seconds in AquaData when I hard-code my bind variables. The bind variables are a start and end date, and they are used twice to pull a date range from two different fields. I'm wondering if the bad performance has something to do with that? I have to call the start and end date twice in my query. Even when I try Debug or SQL Commands in Apex it just hangs.
Any ideas on how to improve this?
Thanks for your help.

Greg,
You wrote: but the query runs in about 19 seconds in AquaData when I hard-code my bind variables.Do those same hard-coded bind variables not execute in SQL Commands ?
Here is your code formatted so others may see something that I am not seeing: Then again; where does the alias qce come from?
SELECT     f.fac_id AS "Office ID",
           f.fac_name AS "Office Name",
           SUM(CASE
                  WHEN ADD_MONTHS ( pt.date_posted, - ( 12 * 18 ) ) >=
                          p.date_of_birth
                  THEN
                     1
                  ELSE
                     0
               END)
              AS "Adult Pat Count",
           ROUND (
                   NVL (
                         SUM(CASE
                                WHEN ADD_MONTHS ( pt.date_posted,
                                                  - ( 12 * 18 ) ) >=
                                        p.date_of_birth
                                THEN
                                   1
                                ELSE
                                   0
                             END)
                         / COUNT ( * ),
                         0
                   2
           * 100
              AS "Adult Pat %",
           SUM(CASE
                  WHEN ADD_MONTHS ( pt.date_posted, - ( 12 * 18 ) ) <=
                          p.date_of_birth
                  THEN
                     1
                  ELSE
                     0
               END)
              AS "Pedo Pat Count",
           ROUND (
                   SUM(CASE
                          WHEN ADD_MONTHS ( pt.date_posted, - ( 12 * 18 ) ) <=
                                  p.date_of_birth
                          THEN
                             1
                          ELSE
                             0
                       END)
                   / COUNT ( * ),
                   2
           * 100
              AS "Pedo Pat %",
           SUM(CASE
                  WHEN ADD_MONTHS ( pt.date_posted, - ( 12 * 18 ) ) >=
                          p.date_of_birth
                  THEN
                     pt.amount_tot
                  ELSE
                     0
               END)
              AS "Adult Rev",
           DECODE (
                    SUM ( pt.amount_tot ),
                    0,
                    0,
                    ROUND (
                            NVL (
                                  SUM(CASE
                                         WHEN ADD_MONTHS ( pt.date_posted,
                                                           - ( 12 * 18 ) ) >=
                                                 p.date_of_birth
                                         THEN
                                            pt.amount_tot
                                         ELSE
                                            0
                                      END)
                                  / SUM ( pt.amount_tot ),
                                  0
                            2
           * 100
              AS "Adult Rev %",
           SUM(CASE
                  WHEN ADD_MONTHS ( pt.date_posted, - ( 12 * 18 ) ) <=
                          p.date_of_birth
                  THEN
                     pt.amount_tot
                  ELSE
                     0
               END)
              AS "Pedo Rev",
           DECODE (
                    SUM ( pt.amount_tot ),
                    0,
                    0,
                    ROUND (
                            NVL (
                                  SUM(CASE
                                         WHEN ADD_MONTHS ( pt.date_posted,
                                                           - ( 12 * 18 ) ) <=
                                                 p.date_of_birth
                                         THEN
                                            pt.amount_tot
                                         ELSE
                                            0
                                      END)
                                  / SUM ( pt.amount_tot ),
                                  0
                            2
           * 100
              AS "Pedo Rev %"
FROM                   pats p
                    JOIN
                       clinic_ext ce
                    ON p.clinic_id = ce.clinic_id AND p.loc_id = ce.loc_id
                 JOIN
                    pat_trans_rep pt
                 ON     p.clinic_id = pt.clinic_id
                    AND p.unique_id = pt.unique_id
                    AND pt.charge_yn = 'Y'
              JOIN
                 fac_hier_links fk
              ON qce.fac_id = fk.fac_id
           JOIN
              fac f
           ON qce.fac_id = f.fac_id
WHERE      p.date_of_first_visit BETWEEN TO_DATE ( :p5_start_date,
                                                   'MM/DD/YYYY' )
                                     AND  TO_DATE ( :p5_end_date,
                                                    'MM/DD/YYYY' )
           AND pt.date_posted BETWEEN TO_DATE ( :p5_start_date, 'MM/DD/YYYY' )
                                  AND  TO_DATE ( :p5_end_date, 'MM/DD/YYYY' )
GROUP BY   f.fac_id, f.fac_nameJeff
Edited by: jwellsnh on Sep 15, 2011 1:49 PM

Similar Messages

  • Authentication function not working in APEX but works in pl/sql

    Greetings, Jim here.
    I have written a very simple authentication funtion which uses the dbms_ldap package to authenticate using the userid and password from the login page.
    I've tested this function thru pl/sql and it returns true and false accordingly.
    I've created a custom authentication schema and in the authentication function I have return myfunction;
    The problem is, when called thru APEX, it appears to always return true and lets the login proceed, even if the password is correct. I know its using the function due to the fact that if I enter a bogus function as the authentication function, APEX spits up a message saying so.
    So, I know the function works, but I don't know why it does not work with APEX. Posting function below.
    CREATE OR REPLACE FUNCTION ODBS.CUSTAPEXLOGIN (p_username IN VARCHAR2,p_password IN VARCHAR2)
    RETURN BOOLEAN AS
    retval PLS_INTEGER;
    emp_session DBMS_LDAP.session;
    ldap_host VARCHAR2(256);
    ldap_port VARCHAR2(256);
    ldap_user VARCHAR2(256);
    ldap_passwd VARCHAR2(256);
    ldap_base VARCHAR2(256);
    BEGIN
    ldap_host := 'oraldap';
    ldap_port := '389';
    ldap_user := p_username;
    ldap_passwd := p_password;
    ldap_base := 'cn=users,dc=company,dc=com';
    emp_session := DBMS_LDAP.init(ldap_host,ldap_port);
    retval := DBMS_LDAP.simple_bind_s(emp_session,('cn=' || ldap_user || ',' || ldap_base),ldap_passwd);
    if retval = 0 then
    return true;
    else
    return false;
    end if;
    EXCEPTION
    WHEN OTHERS THEN
    begin
    if sqlcode = -31202 then
    return false;
    end if;
    end;
    END;
    /

    Hi Jim,
    Can you clarify this -
    The problem is, when called thru APEX, it appears to always return true and lets the login >proceed, even if the password is correctThat implies you're saying your authentication function ALWAYS returns true? Is that correct? Also 'even if the password is correct' doesn't read correctly to me, did you mean 'even if the password is incorrect'?
    You then say -
    now the function works, but I don't know why it does not work with APEX.So by 'does not work' you mean in APEX it is always returning true therefore allowing you to login regardless of the username/password you use? Is that correct?

  • Run of mvdemo.sql in Oracle9i failed

    Hi all,
    I'm new to this list and i have a question to the mvdemo Package.
    We are running Oracle 9i (9.2.0.8.0) with the spatial cartridge installed.
    (NLS_LANG=German_Germany.WE8ISO8859P15)
    Creating the mvdemo User and importing the mvdemo.dmp succeeded, but running the mvdemo.sql script failed while inserting the rows in the customer table:
    Example:
    insert into customers values('BLACKHAWK PLAZA','UNINC CONTRA COSTA COUNTY','CONTRA COSTA','CA',mdsys.sdo_geometry(2001,8307, sdo_point_type(-121.9192,37.80925,NULL),NULL,NULL),76.4)
    FEHLER in Zeile 1:
    ORA-00904: Ungültiger Spaltenname
    we tried the same on a developer machine with Oracle 10gr2 without error.
    Any hints for me ?
    Thanks,
    Wolfgang

    i changed the mvdemo.sql script to reflect this, but on the end of the script iget the following:
    create index opsdx on oriented_points(shape) indextype is mdsys.spatial_index
    FEHLER in Zeile 1:
    ORA-29855: Fehler bei Ausführung der Routine ODCIINDEXCREATE
    ORA-13249: internal error in Spatial index: [mdidxrbd]
    ORA-13249: Error in Spatial index: index build failed
    ORA-13249: Error in spatial index: [mdrcrtxfergm]
    ORA-13249: Error in spatial index: [mdpridxtxfergm]
    ORA-13200: Interner Fehler [ROWID:AAAIKRAABAAAMGaAAA] bei räumlicher
    Indizierung.
    ORA-13206: Interner Fehler [] beim Erstellen von räumlichem Index
    ORA-13354: Falscher Offset in ELEM_INFO_ARRAY
    ORA-06512: in "MDSYS.SDO_INDEX_METHOD_9I", Zeile 7
    ORA-06512: in Zeile 1
    Any hints on that ?
    Wolfgang

  • Apex query hanging

    Hi,
    I have a query which runs OK from SQL developer, I move SQL to APEX and it hangs and never returns any records. Any ideas.
    Thanks,
    Arik

    Arik,
    You may want to try explicitly converting your bind variables to the correct data type. For example:
    created_at between to_date(:a1, <format mask of a1>) and to_date(:a2, <format mask of a2>)
    I have an application where all the fields are manually created (not associated to a database column) and all there data types are reported as "varchar" in APEX_APPLICATION_PAGE_ITEMS view.
    Sima

  • Running a query in a View Designer results in an error, but running the same query in a Query window works

    Hi everyone,
    Just as my title says, I have a query which I've written in a query window and it works perfectly.
    But when I try to add the query code into the view designer, it throws a Syntax error.
    Error in ON clause near '('.Unable to parse query text.
    Also, when running the query from the view designer (pressing red exclamation mark) I get a different error.
    SQL Execution Error.Executed SQL statement: SELECT Sku, ParentSku, UPC, ...Error Source: .Net SqlClient Data ProviderError Message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
    Has anyone else experienced this and is there any workaround?
    I have tried to create the view with T-SQL (CREATE VIEW etc.), but when opening it in the view designer I get the error from the 1st image.
    Thank you,
    Radu

    Hi Radu,
    Yes, I have faced similar issue. I had a View and it was working totally fine but when once I opened it in via right click - View Design, it was giving parse error.
    Cause is that Query designer parse and executes the query without error but the way View designer works, it can't parse it.
    Later I ignored View desinger and just used T-SQL like CREATE/ALTER view.
    Workaround is to do right click on View - Script View as - CREATE To/ ATER To.
    Regarding Timeout error, again the issue with View designer which couldn't execute query in there and ended up with timeout error.
    If your SELECT query and SELECT * FROM YourView works fine in Query designer, you are good to go.
    Similar threads:
    View with errors still saved, and still works...
    Parsing error when creating view
    -Vaibhav Chaudhari

  • Why select query is not running on 10.2.0.2.0  but running on 10.2.0.1.0

    Hi Friends,
    The below given select statement is executing successfully in version
    select * from v$version;
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    but NOT in version
    select * from v$version;
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
    PL/SQL Release 10.2.0.2.0 - Production
    "CORE     10.2.0.2.0     Production"
    TNS for Solaris: Version 10.2.0.2.0 - Production
    NLSRTL Version 10.2.0.2.0 - Production
    the error message is :
    ORA-00904:"SSRP"."RESOURCE_ID" invalid identifier
    Error at Line 12 : Column 40
    SELECT SR.RESOURCE_NAME,
    SRG.RESOURCE_GROUP_NAME,
    MAX(NVL((SELECT NVL(CHECKED, UNCHECKED)
    FROM
    (SELECT 2 AS UNCHECKED,
    (SELECT 1
    FROM S_USAGE_RESOURCE_PERMISSIONS SURP
    WHERE SURP.USAGE_PROFILE_ID = 1
    AND SURP.RESOURCE_PERMISSION_ID = SRP.RESOURCE_PERMISSION_ID) AS CHECKED
    FROM S_RESOURCE_PERMISSIONS SRP
    WHERE SRP.RESOURCE_PERMISSION_ID = SSRP.RESOURCE_PERMISSION_ID
    AND SRP.RESOURCE_ID = SSRP.RESOURCE_ID
    AND SRP.RESOURCE_PERMISSION_VAL = 4 )),0)) AS ALL_PERMISSION
    FROM
    S_RESOURCE_PERMISSIONS SSRP
    INNER JOIN
    S_RESOURCE SR ON SR.RESOURCE_ID = SSRP.RESOURCE_ID
    INNER JOIN
    S_RESOURCE_GROUP SRG ON SRG.RESOURCE_GROUP_ID = SR.RESOURCE_GROUP_ID
    GROUP BY SR.RESOURCE_NAME, SRG.RESOURCE_GROUP_NAME;
    Given SCHEMA is similar in all respects at both the databases.
    can someone suggest me what could be the problem?

    Sorry, didn't look close enough, here a corrected query you can try to run.
    If you still have problems, try to post a ddl scripts and small sample of data - this may do it easier for other to help you. When you post sql scripts, try as well to enclose them between [ pre ] [ pre ] or [ code ] [ code ] tags to increase readability.
    WITH t AS (
    SELECT NVL(CHECKED, UNCHECKED) NVL_CHECKED,
           RESOURCE_ID,
           RESOURCE_PERMISSION_ID
      FROM (SELECT 2 AS UNCHECKED,
                   (SELECT 1
                      FROM S_USAGE_RESOURCE_PERMISSIONS SURP
                     WHERE SURP.USAGE_PROFILE_ID = 1
                       AND SURP.RESOURCE_PERMISSION_ID =
                           SRP.RESOURCE_PERMISSION_ID) AS CHECKED,
                   SRP.RESOURCE_ID,RESOURCE_PERMISSION_ID
              FROM S_RESOURCE_PERMISSIONS SRP
             WHERE SRP.RESOURCE_PERMISSION_VAL = 4))
    SELECT SR.RESOURCE_NAME,
           SRG.RESOURCE_GROUP_NAME,
           MAX(NVL_CHECKED) AS ALL_PERMISSION
      FROM S_RESOURCE_PERMISSIONS SSRP INNER_JOIN T ON (T.RESOURCE_ID =
                                                       SSRP.RESOURCE_ID AND
                                                       T.RESOURCE_PERMISSION_ID =
                                                       SSRP.RESOURCE_PERMISSION_ID)
    INNER JOIN S_RESOURCE SR ON SR.RESOURCE_ID = SSRP.RESOURCE_ID
    INNER JOIN S_RESOURCE_GROUP SRG ON SRG.RESOURCE_GROUP_ID =
                                        SR.RESOURCE_GROUP_ID
    GROUP BY SR.RESOURCE_NAME, SRG.RESOURCE_GROUP_NAME;Best regards
    Maxim

  • I don't know what i need. I'am a mac user but i need to run quick books premier. This is the only software i need in windows 7. Could i have some advise in  what is better for me, Bootcamp or parallels

    I don't know what i need. I'am a mac user but i need to run quick books premier. This is the only software i need in windows . Could i have some advise in  what is better for me, Bootcamp or Parallels

    The Intuit rep said they don't "support" QuickbooksPremier on a "virtual machine." Do you know what I risk by using it, anyway? thanks for the advice about Boot Camp vs Parallels, BTW!
    I use QuickBooks Pro for Mac, so I haven't had need to try any of the Windows versions in a VM. But I can't think why it wouldn't work. From within the VM, QuickBooks Premier would believe it is operating on PC hardware within Windows.
    I would guess they mean that the multiple user support wouldn't work from within the VM. But I would think that would also work. Windows can see the Internet from within the VM, which means it can see your network. So if Windows can see the network, then QB Premier should be able to, too.
    I know you can get Parallels as a demo, and maybe you could get QB Premier as trial software. So if you already have a retail copy of Windows to load into a VM, it would only cost you time to test what's possible.

  • Query slow in testing but quick in production

    my query is slow in testing but very quick in production.help me..

    Hi,
    Check whether your Prod is Same as you Testing Environment.
    Whether Parameters in Both DB are same or not Mainly Stats are in Update and same or not
    One more thing is Plan of Query, how it is working in Prod and Test Server.
    that gives the idea how the query Executed. Check out these things.
    - Pavan Kumar N

  • Tuning OBIEE query with DB index, but it's getting slower

    Hello guys
    I just have a quick question about tuning the performance of sql query using bitmap indexes..
    Currently, there are 2 tables, date and fact. Fact table has about 1 billion row and date dim has about 1 million. These 2 tables are joined by 2 columns:
    Date.Dateid = Fact.snapshot.dates and Date.companyid = fact.companynumber
    I have query that needs to be run as the following:
    Select dates.dayofweek, dates,dates, fact.opened_amount from dates, facts
    where Date.Dateid = Fact.snapshot.dates and Date.companyid = fact.companynumber and dates.dayofweek = 'monday'.
    Currently this query is running forever. I think it is joining that takes a lot of time. I have created bitmap index on dayofweek column because it's low on distinctive rows. But it didn't seem to speed up with the performance, but rather made it worse. The explain plan before and after creating that index was the same as:
    Select statement optimizer
    nested loops
    partition list all
    index full scan RD_T.PK_FACTS_SNPSH
    TABLE ACCESS BY INDEX ROWID DATES_DIM
    INDEX UNIQUE SCAN DATES_DIM_DATE
    It seems the bitmap index I created for DATES_DIM wasn't used... Also, I am thinking what other indexes I should create for fact table..
    I'd like to know what other indexes will be helpful for me and on which table & columns?.. I am thinking of creating another one for companynumber since it also have low distinctive records.
    Currently I can't purge data or create smaller table, I have to what with what I have..
    So please let me know your thoughts in terms of performance tunings for such situation..
    Thanks

    Jack,
    Thank you for your response. It helped me to clean up the query. All the changes did not give a much better explain plan - at least not to my inexperienced eyes - but the total execution time for the query is now reduced to under two minutes. The query as it is now:
    select /*+ ordered all_rows */ x.rowid1
    from table(sdo_join('CYCLORAMA','GEOMETRIE','CYCLORAMA','GEOMETRIE','distance=3 mask=ANYINTERACT')) x
    , cyclorama s, cyclorama t
    where not x.rowid1 = x.rowid2
    and s.rowid = x.rowid1 and x.rowid2 = t.rowid
    and s.datasetid != t.datasetid
    and s.opnamedatum < t.opnamedatum;Because the docs state that mask=FILTER is the default, I added an explicit mask=ANYINTERACT to the sdo_join parameters when I removed the sdo_distance from the query. Still, the query returns 205035 records with the sdo_distance, and 205125 without. But this may be the result of the extra 0.001 from sdo_dim. I did not investigate as the 3 meter is not crucial.
    I believe I already had a mechanism in place to reduce the number of self-joins with "not x.rowid1 = x.rowid2" and "s.opnamedatum < t.opnamedatum". I can not guarantee that for all records s.opnamedatum < t.opnamedatum equals x.rowid1 < x.rowid2.
    Based on the [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14255/sdo_operat.htm#BGEDJIBF]docs, I finally added an 'ordered' hint and reshuffled the tables in the from clause.
    I'm happy with performance now, and creating a new table with the records to keep should not be a problem. Still I'm curious about the following:
    <li>Is it worth optimizing the SDO_DIM_ARRAY for the original table, e.g. narrowing the range of coordinate values?
    <li>How can sdo_join best be used for an anti-join, to select the records to keep?
    Thank you,
    J-----.

  • Oracle 9.2.0.6; query hangs if partition doesn't exist

    Hallo all,
    this is the first time I post on this forum.
    I work in a group of PL\SQL developers in Italy. Few day ago we had a problem with a query and like to find out what the problem is.
    We have an Oracle DB version 9.2.0.6 (old I know) in a production environment. Linux OS.
    The query was made to extract data from a partitined table, on a partioned field, in our casa one Year. By mistake we have serced for the wrong year, 2013. There where no data for that year and therefor no partition.
    So, happened that the query hangs and after 24 hours was terminated.
    What we expected indeed was a zero records retirned in, at the most, few minutes, see that the table, in severa partition contains about 16 million records.
    The we tested the same query but in a different enviroment, Oracle 11gr2, same table structure, same partitioning, without partition 2013, and the query completed in less tha 1 minute with zero records in output.
    At this point we thought of a bug, but can't find any reference.
    Has anyone had a similar experience or can give some indication of possible bug report.
    Thanks for any help.

    Hi Rob,
    thank you for your answer.
    Sorry if this is not the best forum. I am not very practical.
    I try to answer to your questions.
    At a first time we thought the query did a full scan on the table. Yes. But even to full scan 16.000.000 records split in no more than 8 partition (at this time) shouldn't take up to 24 hours and never stop running. I think.
    We don't have a DBA role so we do not have full control over what is running. And take too long time to open a ticket and ask the DBA to check.
    What we did is testing the same query in a pre-prod environment, which is an Oracle 11gr2.
    I understand that it is not very usual to have a pre-production environment with a latest version of oracle but this is the way we have to work.
    Anyway, the test in pre-production worked very well. Without 2013 partition the return was very fast and we had zero records as expected.
    Then we found a workaround for production, ora 9. Call it work around maybe is too much ........
    We created the 2013 partition and run the query. The respons was then succesfull in about the same time than in pre-prod. Less than one minute and zero records.
    And this is fine for us.
    What we don't understand is why this different behavior with two different version of DB. Thats why we think it is due to a bug. We only want to find out whether it is this or if there is a different reason.
    Some other response or help would help.
    Thank you.

  • Function returning query takes more time to run in Apex4.0

    Hi All,
    I created a report using function returning query. The function returns query based the parameters which returns dynamic columns. When I run the query in sql developer the query generates and returns the result in 3mins. But in apex it takes maximum of 35mins to return.
    The query will return around 10000 rows.
    Is it a performance issue in the query or in Apex?can anyone please help
    Regards
    Raj

    RajEndiran wrote:
    Hi Roel,
    Thanks much for your suggestion. I run in TOAD and got the result as
    Row 1 of 500 fetched so far in 3.31 minutes which means it queried for 500 records alone ? is that not the actual time taken to run the fulll query?That reflects the time to return the first 500 records...
    Please suggest.With all the best will in the world, if I was your user and I had to wait 3 minutes for the page to refresh, I'd steadily lose the will to live!
    As this is primarily an SQL tuning question, have a look at this message in the FAQ thread in the {forum:id=75} forum:
    {message:id=9360003}
    That should give you some pointers on the right approach.

  • Query hangs on Value Help

    Hi,
    We have created a query in which we are using quantity conversion ( defined in RSUOM ) , the target quantity is to be taken from a variable. The quantity conversions is running fine but when we do a value help for the target quantity variable in Portal, the query hangs. We are not facing any such  issue in Bex Analyzer.
    Please share your ideas on what could be the possible reason for this.
    Thanks and Regards,
    Manish Sharma

    Hello Manish,
    This is clearly a Portal issue.
    Probably an issue with BI Java.
    I recommend you to update your BI Java components to latest patch recommended by Java SP_Patch Matrix.
    If you are using Netweaver 7.0, please check the link below:
    http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/6010addf-e096-2b10-8893-e98586d005f9 [original link is broken]
    If you are using Netweaver 7.0 EHP 1 (7.01), please the this link:
    http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/c098b21c-e56f-2d10-2aad-b13915b396a4 [original link is broken]
    Applying the patches recommended should solve the issue.
    Also, as a recommendation, run the BI Diagnostics - note 937697 - and correct the red alerts.
    Best Regards,
    Edward John

  • Query hangs with outer query

    Hi,
    OS: SPARC 64 bit
    Oracle Version: 10.2.0.3.0 64 bit
    My query hangs when I include the outer query. When I execute without outer query It comes out in a fraction of second but when I includes outer query it starts hang
    Below is my original query which hangs
    select * from (select raw_sql_.**, rownum raw_rnum_ from (SELECT /*+ FIRST_ROWS */ NETWORK_ID||'","'||CALLER_NUMBER||'","'||CALLED_NUMBER FROM CDR FROM CDR WHERE 1 = 1
    AND day_of_year = 99 AND INTERFACE = 'TRAFIC' AND TIME_STAMP BETWEEN to_date('2009/04/08 00:00:00','yyyy/mm/dd hh24:mi:ss') AND to_date
    ('2009/04/09 00:00:00','yyyy/mm/dd hh24:mi:ss') AND NETWORK_ID IN (1025,1026) order by id desc) raw_sql_ WHERE rownum <= 10000) WHERE raw_rnum_ > 0;
    when I execute this it will come out immediately
    select raw_sql_.**, rownum raw_rnum_ from (SELECT /*+ FIRST_ROWS */ NETWORK_ID||'","'||CALLER_NUMBER||'","'||CALLED_NUMBER FROM CDR FROM CDR WHERE 1 = 1
    AND day_of_year = 99 AND INTERFACE = 'TRAFIC' AND TIME_STAMP BETWEEN to_date('2009/04/08 00:00:00','yyyy/mm/dd hh24:mi:ss') AND to_date
    ('2009/04/09 00:00:00','yyyy/mm/dd hh24:mi:ss') AND NETWORK_ID IN (1025,1026) order by id desc) raw_sql_ WHERE rownum <= 10000
    select * from (select raw_sql_.**, rownum raw_rnum_ from (SELECT /*+ FIRST_ROWS */ NETWORK_ID||'","'||CALLER_NUMBER||'","'||CALLED_NUMBER FROM CDR FROM CDR WHERE 1 = 1
    AND day_of_year = 99 AND INTERFACE = 'TRAFIC' AND TIME_STAMP BETWEEN to_date('2009/04/08 00:00:00','yyyy/mm/dd hh24:mi:ss') AND to_date
    ('2009/04/09 00:00:00','yyyy/mm/dd hh24:mi:ss') AND NETWORK_ID IN (1025,1026) order by id desc) raw_sql_ WHERE rownum <= 10000) WHERE raw_rnum_ > 0;
    but when I includes outer query I hangs it is really very weird for me?
    Here is the explain plan for that query
    Execution Plan
    Plan hash value: 3493649369
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
    | 0 | SELECT STATEMENT | | 1 | 2015 | 1 (0)| 00:00:01 | | |
    |* 1 | VIEW | | 1 | 2015 | 1 (0)| 00:00:01 | | |
    |* 2 | COUNT STOPKEY | | | | | | | |
    | 3 | PARTITION RANGE SINGLE | | 1 | 5894 | 1 (0)| 00:00:01 | 99 | 99 |
    | 4 | PARTITION LIST ALL | | 1 | 5894 | 1 (0)| 00:00:01 | 1 | 48 |
    |* 5 | TABLE ACCESS BY LOCAL INDEX ROWID| CDR | 1 | 5894 | 1 (0)| 00:00:01 | 4705 | 4752 |
    | 6 | BITMAP CONVERSION TO ROWIDS | | | | | | | |
    |* 7 | BITMAP INDEX SINGLE VALUE | IX_CDR_INTERFACE | | | | | 4705 | 4752 |
    Predicate Information (identified by operation id):
    1 - filter("RAW_RNUM_">0)
    2 - filter(ROWNUM<=10000)
    5 - filter("DAY_OF_YEAR"=99 AND "TIME_STAMP">=TO_DATE('2009-04-08 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND
    "TIME_STAMP"<=TO_DATE('2009-04-09 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND ("NETWORK_ID"=1025 OR
    "NETWORK_ID"=1026))
    7 - access("INTERFACE"='TRAFIC')
    can one explain why it happen? what could be the reason? Is it a bug or something? what should I do now? Issue is critical in the production enviromentent
    Waiting for your Valuable Reply
    Thanks In Advance
    With Regards
    Boo

    user454189 wrote:
    I suspect the issue with the where clause (raw_rnum_ > 0)
    Actually I using bitmap index on ' INTERFACE' column. Does it causing a prob or raw_rnum_ causing a problem?Boo,
    a couple of comments:
    1. Why do you use the deprecated FIRST_ROWS hint? From 9i on the FIRST_ROWS_n mode should be used instead, and since you're using a top-N query format the hint should be superfluous anyway since the optimizer should switch to FIRST_ROWS_n mode automatically.
    2. Why do you use a BITMAP index and not a conventional b*tree index? Let me hazard a guess: Because the INTERFACE column has a small number of distinct values? That would be in most cases a bad idea.
    3. What seems to be odd that you're accessing the data via the BITMAP index on INTERFACE, but request an ORDER BY ID DESC. But there is no order by in the execution plan posted. I wonder where the order should come from? Can you show us the DDL of the bitmap index?
    4. What does the plan look like if you run only the inner query without the outer query?
    You can always gain more information by tracing the statement execution or using the GATHER_PLAN_STATISTICS hint together with the DBMS_XPLAN.DISPLAY_CURSOR function.
    Please read this HOW TO: Post a SQL statement tuning request - template posting that explains what you should provide if you have SQL statement tuning question and how to format it here so that the posted information is readable by others.
    This accompanying blog post shows step-by-step instructions how to obtain that information.
    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/

  • My Query hangs

    Hi,
    I've a quick question. I've installed Oracle Database 10g Express Edition (Western Europen). I encountered the problem where it runs on port 8080 so I decided to change it by running the following script from the SQL>SQL Command>Enter Command
    BEGIN dbms_xdb.sethttpport(8081); END;
    Now it actually works but the query never terminates. The status remains at "SQL Statement Running".
    I'm just wondering if there's a reason for it? It is because I have now changed the port and need to shutdown and startup the console again?
    If I change the port using sqlplus on the command line, the query executes and finishes.
    Thanks,
    Mike

    Well, it seems quite normal. Just think of it : you are connected on port 8080, and you change it on the fly to yourself. Of course port 8080 does not answer anymore.
    Sql*Plus does not use that port, so no problems from there.
    BTW, you don't need to shutdown/startup anything. Just try : change port to 8081 from console, the console does not work anymore. Change it back to 8080 from Sql*Plus : the console works again.

  • Error while running Quick Pay

    Hi Friends,
    I am trying to run Quick Pay for an employee. I have put the dates and then saved it. Now when I click the Start Run button nothing happens. I click on the Override Payment method field and see this error
    "APP-PAY-07263: Choose a Quick Pay run. Query a QuickPay process with a status of Complete before trying to define or process a QuickPay Pre-payment."
    This is the first time I am running the Quick Pay for the person. Infact this is a new hire I just created and trying to run the QuickPay process.
    Can someone please help.
    Thanks
    Shekar.

    First run only the quick pay. after that you will see start pre-payments button enabled. Then select the override payment method and run the pre-payment process.

Maybe you are looking for

  • How to get system and boot on one volume - currently on 2 volumes

    I have ended up with 2 hard drives one of which has Windows 7 on one partition and the other one has 2 volumes each with Windows 8.1 installed.  This 8.1 drive has one volume (D) marked as Active, Boot and the other volume (C) marked as System.   I w

  • SWING, STUDIO CREATOR OR WHAT PLEASE

    I am new to development and started on VB where they had a GUI that was easy for me to learn. I was worried when I switched to JAVA, although I enjoy it I was worried about the GUI, until I found Studio Creator. Can you use Studio Creator for program

  • IBOTS work in a strange manner in OBIEE 10G why..?

    Hi All, I have set up an IBOT and define my email id as well as email id of user B in my accounts. I clicked on my email id radio button. Now i created IBOT and in receipent tab I defined Me and specfic user from list i.e. B When I run the IBOT both

  • PLSQL and Java XML type mapping

    Running database 10gR2.  Trying to create a Java stored procedure that returns an XML type (oracle.xdb.XMLType) like so: class MyCoolClass    static oracle.xdb.XMLType doSomething( String xmldata)      oracle.xdb.XMLType xmlt = new oracle.xdb.XMLType

  • How to document a view?

    hello friends, how to document a sight? thank you in advance! Any help would be appreciated. Ghalem.