SELECT DISTINCT very slow

hi @all
I'm using Oracle 11g R2 on Windows 7
Unfortunately i have a column in a table that stored multiple vales delimited with *,* e.g. [+*execute 1B-B-06-34-61-00A-281A-A, 1B-B-06-37-10-00A-281A-A, 1B-B-06-37-20-00A-281A-A, 1B-B-06-37-30-00A-281A-A*+]
I have to query that column to get seperate values after execute
Example:
Serial_No Remarks
---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AS0007 execute 1B-B-06-34-61-00A-281A-A, 1B-B-06-37-10-00A-281A-A, 1B-B-06-37-20-00A-281A-A, 1B-B-06-37-30-00A-281A-A
---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AS0007 execute 1B-B-28-52-00-00A-340C-A
---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AS0007 execute 1B-B-57-11-03-06A-281A-A, 1B-B-57-11-03-07A-281A-A, 1B-B-57-11-03-07B-281A-A,
---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
expected Output:
Serial_No Remarks
---------|----------------------------------------------------------------
AS0007 1B-B-06-34-61-00A-281A-A
---------|----------------------------------------------------------------
AS0007 1B-B-06-37-10-00A-281A-A
---------|----------------------------------------------------------------
AS0007 1B-B-06-37-20-00A-281A-A
---------|----------------------------------------------------------------
AS0007 1B-B-06-37-30-00A-281A-A
---------|----------------------------------------------------------------
AS0007 1B-B-28-52-00-00A-340C-A
---------|----------------------------------------------------------------
AS0007 1B-B-57-11-03-06A-281A-A
---------|----------------------------------------------------------------
AS0007 1B-B-57-11-03-07A-281A-A
---------|----------------------------------------------------------------
AS0007 1B-B-57-11-03-07B-281A-A
I have the following Script to query this:
select distinct SCHED_MAINT.AC_SERIAL_NO, regexp_substr (SUBSTR(SCHED_MAINT.Remarks, 9), '[^,]+', 1, level) as DMC
from SCHED_MAINT
where SCHED_MAINT.NEXT_DUE_MINS = '24000'
and SCHED_MAINT.AC_SERIAL_NO = 'AS0007'
connect by prior SCHED_MAINT.AC_SERIAL_NO = SCHED_MAINT.AC_SERIAL_NO
and regexp_instr (SCHED_MAINT.Remarks, '[^,]+', 1, level) > 0
and prior dbms_random.string ('p', 10) is not null;
The Problem is that, with this few rows it works, but slow, if i have more rows e.g 1000, I killed the runtime after 2h without any output
If I run this script without the DISTINCT it runs fast in one second but i get duplicated rows
any suggestions to solve this problem
unfortunately i cannot use funktions or procedures
thanks in advanced
cu ice

WITH clause is just aon-the-fly sample of your real table. Simply remove WITH clause and run:
select  distinct ac_serial_no,
                 trim(regexp_substr(remarks,'[^,]+',9,column_value)) as DMC
  from  sched_maint,
        table(
              cast(
                   multiset(
                            select  level
                              from  dual
                              connect by level < regexp_count(remarks,',',9) + 1
                   as sys.OdciNumberList
/ And it would take you less time to test multiple ac_serial_no than to post the question:
with sched_maint as (
                     select 'AS0007' ac_serial_no,'execute 1B-B-06-34-61-00A-281A-A, 1B-B-06-37-10-00A-281A-A, 1B-B-06-37-20-00A-281A-A, 1B-B-06-37-30-00A-281A-A' remarks from dual union all
                     select 'AS0007','execute 1B-B-28-52-00-00A-340C-A' from dual union all
                     select 'AS0007','execute 1B-B-57-11-03-06A-281A-A, 1B-B-57-11-03-07A-281A-A, 1B-B-57-11-03-07B-281A-A' from dual union all
                     select 'AS0008' ac_serial_no,'execute 1B-B-06-34-61-00A-281A-A, 1B-B-06-37-10-00A-281A-A, 1B-B-06-37-20-00A-281A-A, 1B-B-06-37-30-00A-281A-A' remarks from dual union all
                     select 'AS0008','execute 1B-B-28-52-00-00A-340C-A' from dual union all
                     select 'AS0008','execute 1B-B-57-11-03-06A-281A-A, 1B-B-57-11-03-07A-281A-A, 1B-B-57-11-03-07B-281A-A' from dual
select  distinct ac_serial_no,
                 trim(regexp_substr(remarks,'[^,]+',9,column_value)) as DMC
  from  sched_maint,
        table(
              cast(
                   multiset(
                            select  level
                              from  dual
                              connect by level < regexp_count(remarks,',',9) + 1
                   as sys.OdciNumberList
AC_SER DMC
AS0007 1B-B-06-34-61-00A-281A-A
AS0007 1B-B-06-37-10-00A-281A-A
AS0007 1B-B-06-37-20-00A-281A-A
AS0007 1B-B-28-52-00-00A-340C-A
AS0007 1B-B-57-11-03-06A-281A-A
AS0007 1B-B-57-11-03-07A-281A-A
AS0008 1B-B-06-34-61-00A-281A-A
AS0008 1B-B-06-37-10-00A-281A-A
AS0008 1B-B-06-37-20-00A-281A-A
AS0008 1B-B-28-52-00-00A-340C-A
AS0008 1B-B-57-11-03-06A-281A-A
AC_SER DMC
AS0008 1B-B-57-11-03-07A-281A-A
12 rows selected.
SQL> SY.

Similar Messages

  • Variable selection is very slow in WAD

    Hi All,
    Variable selection is very slow, It  takes 2 min to 3 min to get the variable list.
    There are Lots of Data in the system and This query is from Multicube
    please help me out from this issue. It's Urgent !!
    Thanks,
    Greg

    Hi Greg,
    I have the same issue.
    It is very important to improve performance of the F4 function in the web.
    For one query in BEx, it takes about 2 seconds to open the F4 screen for 0CUSTOMER. In the web (WAD) it takes a lot more even with HTTP compression enabled!
    Anybody with a solution to improve performance of the variable selection screen?
    Thanks!

  • Distinct very slow

    I was wondering what are the other approaches followed in SQL to avoid using a Distinct clause, It seems that it takes the major chunk of the sql processing time.

    In addition to Andrew's and Laurent's comments, I would add that use of DISTINCT is often a code smell.
    Since the DISTINCT refers to all of the columns in the SELECT list,it is often used to suppress duplicate records generated by incorrect queries. Some coders seem to add a DISTINCT to evey query, just in case.
    Whenever I see DISTINCT, I will run the query without it to see if it is really neccessary. If there are duplicate racords, I would review the query to find the reason, then correct the query.
    DISTINCT does have it's uses, but, in the real world, they are few and far between.
    TTFN
    John

  • SELECT query very slow, need suggestion.

    Dear all,
    Below stmt was coded in my report program.
    It was taking around 14 seconds in development system. The days in s_datum was just 1 or 2 days max.
    But when the same was transferred to test system, it is taking almost 10 minutes, though it we gave just 1 day.
      SELECT * FROM likp INTO TABLE i_likp                  
            WHERE erdat IN s_datum AND wadat_ist > '00000000' 
              AND lfart <> 'EL'                               
              AND vstel not in s_vstel.
    Some of you might suggest to make SELECT query with only s_datum, but i tried it in dev system, it was taking almost 22 secs with only s_datum.  I thought it could be more worse in test system so, did not move that idea.
    Can some one please suggest me why it is happening so.

    Hi,
    The difference, as I suppose you know, happens because LIKP probably has much more records in production than in the development system.
    You must think what is selective in your WHERE clause:
    - erdat in s_datum is selective if you are are only using one day
    - wadat_ist GE '00000000' is not selective (all deliveries with goods issue fulfill that condition)
    - lfart NE 'EL' probably is not selective
    - vsten not in s_vstel probably is not selective
    So in the end only erdat is selective. There is no index in LIKP by ERDAT, so if you really want to make it faster you would need an index by ERDAT.
    Still, if you are only making one SELECT (not inside a loop) I wouldn't expect that to take more than 10 minutes.
    I would measure the program with SE30 to make sure it is really the SELECT that is taking so much time (post here the results), and if it really is the select post here the explain plan.
    By the way, if you need to know all goods issues for the last day I would use change pointers instead.
    Hope this helps,
    Rui Dantas

  • Select count(*) VERY slow!

    The table has only 8 columns and 5 way partitioned.
    It was fine till it had 550 million rows [Oracle 11g + Windows XP Pro]. Select count(*) from table used to take ~ 500 seconds.
    When records count reached 600 million, suddenly looks like database hit a brick wall. Now even select count(*) runs for whopping 2800 seconds!!
    What went wrong by just adding 50 million extra records??
    Thanx.

    analyze table Has been obsoleted by DBMS_STATS package.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_4005.htm#sthref5767
    Note:
    Do not use the COMPUTE and ESTIMATE clauses of ANALYZE to collect optimizer statistics. These clauses are supported for backward compatibility. Instead, use the DBMS_STATS package, which lets you collect statistics in parallel, collect global statistics for partitioned objects, and fine tune your statistics collection in other ways. The optimizer, which depends upon statistics, will eventually use only statistics that have been collected by DBMS_STATS. See PL/SQL Packages and Types Reference for more information on the DBMS_STATS package.
    Edited by: sb92075 on May 16, 2009 11:36 AM

  • A very slow select with sub selects sql statement on Oracle

    Hi,
    I'm moving an application from MySql to Oracle. The following select were very efficiently executed in MySql. In oracle its slow like a snail.
    Do anyone have a hint on how to speed it up?
    The slow part is the four sub selects in the select part. Removing them makes the select about 50 times faster on Oracle.
    Best Regards,
    Stephane
    select
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and (rr.relation_type_id = 'link' OR rr.relation_type_id = 'product')) as relationList,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'number') as relationNumber,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'title') as relationTitle,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'content') as relationText,
    d.*
    from document d,(
    select distinct r.document_id id
    from relation r
    where
    r.product_id = ?
    ) dd
    where d.id=dd.id

    You are accessing the relation-table too many times, so a rewrite to a query like this
    SQL> select dept.deptno
      2       , dept.dname
      3       , count(decode(job,'CLERK',1)) clerk
      4       , count(decode(job,'MANAGER',1)) manager
      5       , count(decode(job,'SALESMAN',1)) salesman
      6    from dept, emp
      7   where dept.deptno = emp.deptno (+)
      8   group by dept.deptno
      9       , dept.dname
    10  /
        DEPTNO DNAME               CLERK    MANAGER   SALESMAN
            10 ACCOUNTING              1          1          0
            20 RESEARCH                2          1          0
            30 SALES                   1          1          4
            40 OPERATIONS              0          0          0
    4 rijen zijn geselecteerd.will be worth the effort.
    If still not satisfied, you have to do some investigation, as described [url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]here
    Regards,
    Rob.

  • The problem is with the new operating system  and sending photo via email when used in my iPad.   From photo I selected 3 photos to send via email. I choose the upload key and choose to send by email. Typing text on the email is very slow.

    The problem is with the new operating system  and sending photo via email when used in my iPad.
    From photo I selected 3 photos to send via email. I choose the upload key and choose to send by email. Typing text on the email is very slow. This is solved by saving the email as a draft and opening the email again from mail.
    Can you amend he system to allow emails to be sent from photo as previously.

    Have you tried restarting or resetting your iPad?
    Restart: Press On/Off button until the Slide to Power Off slider appears, select Slide to Power Off and, after the iPad shuts down, then press the On/Off button until the Apple logo appears.
    Reset: Press the Home and On/Off buttons at the same time and hold them until the Apple logo appears (about 10 seconds). Ignore the "Slide to power off"

  • Same select max is very slow in one program but fast in another

    Hi,
    I have a report that becomes very slow these few months. I used SQL trace for the report and found out its these codes that slow down the report:
    SELECT MAX( mkpf~budat )
                  FROM mkpf
        INNER JOIN mseg
                       ON mseg~mblnr = mkpf~mblnr AND mseg~mjahr = mkpf~mjahr
                    INTO posting_date
               WHERE mseg~werks  = w_matl-batch_reservations-werks
                     AND mseg~charg  = w_matl-batch_reservations-charg
                     AND mseg~bwart  IN ('261', 'Z61').
    The thing is these codes have been used in different system, DEV, QAS, and PRD. But only in PRD it is very slow, other systems are pretty fast.
    I even created a local copy of that report in PRD, with the same code. The local file runs fast and perfectly. But the original code is just slow.
    Just wondering if anybody met this problem too? any ideas??

    Hi Liu,
    Index creation is not a advisable solution.Please follow the existing indexes by adding Mandt field.
    Try like this
    SELECT MAX( mkpf~budat )
                  FROM mkpf
        INNER JOIN mseg
                       ON mseg~mblnr = mkpf~mblnr AND mseg~mjahr = mkpf~mjahr
                    INTO posting_date
               WHERE mseg~mandt = sy-mandt
                      AND mkpf~mandt = sy-mandt
                      AND mseg~werks  = w_matl-batch_reservations-werks
                     AND mseg~charg  = w_matl-batch_reservations-charg
                     AND mseg~bwart  IN ('261', 'Z61').
    Hope it will be helpful.
    Regards,
    Kannan

  • My Photoshop CS3 goes very slow/choppy when I have a selection made.

    Hello,
    My Photoshop CS3 goes very slow/choppy when I have a selection made, with those little moving lines indicating the selection (the lines that look like walking ants). When I'm adding to the selection, it's fine again, because the "ants" aren't moving, same with when I hit Q to enter Quick Mask Mode--as long as the "ants" aren't moving, my Photoshop isn't slow. Is there any way to fix this? To either speed up Photoshop or to stop the "ants" from moving, and simply allow selections to be indicated by broken lines, but not moving broken lines?
    Thanks

    Operating System: Windows 7 Ultimate 32-bit (6.1, Build 7600) (7600.win7_rtm.090713-1255)
               Language: English (Regional Setting: English)
    System Manufacturer: Tyan Computer Corporation
           System Model: S2668 Tiger i7505              
                   BIOS: PhoenixBIOS 4.0 Release 6.0    
              Processor: Intel(R) Xeon(TM) CPU 3.06GHz (4 CPUs), ~3.1GHz
                 Memory: 4096MB RAM
    Available OS Memory: 3072MB RAM
              Page File: 2548MB used, 3589MB available
    49.9 GB of 465 GB free.

  • Scrolling slow with initial marquee selection, but very fast when adding to selection

    I've found that when I zoom in and try to make a selection that requires me to scroll beyond the viewable area, the scrolling becomes very slow when I scroll down. And if I add to the selection (via shift) the scroll becomes very fast, as if the shift key nudges the screen by x number of pixels, just as if I were to shift-move a layer. Is this the intended behavior?

    Ramon, my apologies. I own a MacBook Pro running OS 10.5.6, 2.4 GHz prcoessor with 2 GB of RAM, and 256 MB of VRAM. I'm using Photoshop CS4.
    So I ran a couple tests and I think I know what's occurring. The scroll speed seems dependent on how close or far the cursor is from the canvas edge (the axis in between the image and the scrollbar). So for example, if I were to do a max zoom the window would expand to the very edge of the desktop. When I start the marquee and move my cursor to scroll it's unable to move any further from the axis because of the desktop edge. This would cause it to scroll more slowly.
    Here are a couple of test vids (The zoom is at 3200% and I set up the camera to focus on the top right of the screen):
    Window right up against desktop edge (automatically positioned via Photoshop max zoom)
    http://s87.photobucket.com/albums/k156/darthsauce/mac/?action=view&current=horiz01.flv
    Window edge moved a little away from desktop edge
    http://s87.photobucket.com/albums/k156/darthsauce/mac/?action=view&current=horiz03.flv
    Window edge moved past the desktop edge (but axis is still visible)
    http://s87.photobucket.com/albums/k156/darthsauce/mac/?action=view&current=horiz00.flv
    Could this be considered an oversight in the design since zoom automatically resizes the window for us (of course, this would affect users differently depending on their zoom ratio and display resolution)? This means that I'll have to resize the window each time the zoom fills the desktop in order to scroll at a proper rate.

  • Very slow distinct

    Guys,
    Please any of you experts, help me re-write the query.. I see the physical IO seems to be extreamly slow with this query.. I think it may be due to the joins. Is there a better way to re-write this ? I think SORT_UNIQUE is holding up the performance of this query.
    SELECT DISTINCT ld.lock_id, ev.entity_id, ev.entity_volume_id,
    -- to get new evid
    ev.last_updated_by, ev.last_updated_date_time, ev.created_by,
    ev.created_date_time
    FROM entity_volume ev,
    entity_volume_lock evl,
    lock_detail ld,
    period p
    WHERE ev.program_id = :b5
    AND ld.program_id = :b4
    AND ev.volume_type = :b3
    AND ld.period_id = ev.period_id
    AND evl.entity_id = ev.entity_id
    AND evl.lock_id = ld.lock_id
    AND ld.period_id = p.period_id
    AND p.month_year BETWEEN :b2 AND :b1
    Explain plan is as below
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=ALL_ROWS          7           1993                     
    SORT UNIQUE          7      679      1993                     
    FILTER                                        
    TABLE ACCESS BY LOCAL INDEX ROWID     ENTITY_VOLUME     1      61      3                     
    NESTED LOOPS          7      679      1970                     
    NESTED LOOPS          553      19 K     311                     
    NESTED LOOPS          135      3 K     41                     
    TABLE ACCESS FULL     PERIOD     1      11      2                     
    INDEX RANGE SCAN     LOCK_DETAIL_IDX002     1      15      39                     
    INDEX RANGE SCAN     ENTITY_VOLUME_LOCK_IDX_002     41      410      2                     
    PARTITION RANGE SINGLE                                   KEY     KEY
    INDEX RANGE SCAN     ENTITY_VOLUME_IDX_001     1           2                KEY     KEY

    I'm not certain why Mr. Beilstein never replied and I believe his claim that "a programmer can almost always bypass the need to do a distinct" may be a little optomistic.
    However, consider the two queries below:
    SELECT CBONAME CBONAME
    FROM (
    SELECT 1 ORDNUM, 'MAN_'||TO_CHAR(SYSDATE,'YYYYMMDD')||UPPER('_'||:STRUSER) CBONAME FROM DUAL
    UNION ALL
    SELECT DISTINCT 2 ORDNUM, BATCHNAME CBONAME FROM LND_STAGESALESTRANSACTION
    WHERE UPPER(BATCHNAME) LIKE UPPER('%_'||:STRUSER) OR :ISADMIN = 1
    AND SUBSTR(UPPER(BATCHNAME),1,4)='MAN_'
    AND (STAGEPROCESSFLAG = 0 OR STAGEPROCESSFLAG = :SHOWPROCESSED)
    ORDER BY ORDNUM
    SELECT CBONAME CBONAME, SUBSTR(CBONAME,LENGTH(:STRUSER)*-1)
    FROM (
    SELECT 1 ORDNUM, 'MAN_'||TO_CHAR(SYSDATE,'YYYYMMDD')||UPPER('_'||:STRUSER) CBONAME FROM DUAL
    UNION ALL
    SELECT 2 ORDNUM, BATCHNAME CBONAME FROM LND_STAGESALESTRANSACTION
    WHERE SUBSTR(UPPER(BATCHNAME),1,4)='MAN_'
    AND UPPER(SUBSTR(BATCHNAME,LENGTH(:STRUSER)*-1)) = UPPER(:STRUSER) OR :ISADMIN = 1
    AND (STAGEPROCESSFLAG = 0 OR STAGEPROCESSFLAG = :SHOWPROCESSED)
    GROUP BY BATCHNAME
    The first is an example using distinct and like clauses. The second uses group by and substr. The second is twice as fast as the first.

  • Selecting sidebar actions under Lion very slow

    Under Snow Leopard, when I would move between some sidebard items like iPhone, iPad, or the apps list, my system was very quick.  I synch my devices very frequently to keep my business calendar updated all the time so switching is happening all the time.
    Under Lion, the store, the library items, in the sidebard all switch very fast.  But selecting the iPhone, the iPad or the list of apps in the library is incredibly slow.  Timed, its 12 to 13 seconds every time they are selected before the change takes place.  I even get the spinning beachball every time.  And, same thing reselecting, its not just the first time.
    Is this unusual?  Any suggestions appreciated.  It just seems very unusual that this one app would have some specific things like this suddenly get so very slow.
    Thanks!

    Hello, the problem seems to be more specific about my use of mod_auth_kerb with apache. The authentication seems to take quite some time.
    Greetings,
    Michel

  • LR 5 is very slow to give me a visual so I can properly select them for import. What's the problem?

    LR 5 is very very very slow in giving me a visual of my images so I can properly select them for import. What's the problem? I'm very disappointed with this glitch! Please Adobe fix it quickly! Has anyone else come across this problem? Any solutions? thanks

    trygzuz wrote:
    LR 5 is very very very slow in giving me a visual of my images so I can properly select them for import. What's the problem? I'm very disappointed with this glitch! Please Adobe fix it quickly! Has anyone else come across this problem? Any solutions? thanks
    Is "very very very slow" 30 seconds or 30 minutes or 30 hours or 30 years?
    It is possible that you have a hardware problem which is causing the slow operation (in my case, it was a bad card reader, but it could also be a bad USB port or USB cable or bad camera card). In fact, in my opinion, these issues are 99.9% of the time hardware issues.

  • Report running very slow.. taking too much time

    Dear Oracle Report experts,
    I have developed report in oracle reports bulider 10g. while running it from report builder through main menu *** data is coming very SLOW *** within 55 Minuts.
    But, If same query is executing from SQL/PLSQL deverloper it is very fast within 45 second.
    Please suggest any configuration or setting ; is having Idea.
    Thanks
    Muhammad Salim
    Query is as below: generating result in 48 second.
    select cns.consultant,
    sum(cns.nof_pat) noof_pat,
    sum(cns.opd_amnt) opd_amnt,
    sum(cns.discount_amnt) discount_amnt,
    sum(cns.net_amnt) net_amnt,
    sum(cns.dr_share) dr_share,
    sum(cns.hosp_share) hosp_share,
    sum(cns.net_dis) net_dis
    from
    select rec.consultant,
    count(distinct rec.consultant) nof_pat,
    -- rec.receipt_date, bysalim
    pay_mode,
    rec.patient_mrno,rec.patient,
    service_name,rcpt_no,
    company,rec.docno,
    sum(distinct return_amnt) return_amnt,
    sum(distinct rec.opd_amnt) opd_amnt,
    sum(distinct dis.discount_amnt) discount_amnt,
    (sum(distinct nvl(rec.opd_amnt,0))-sum(distinct nvl(dis.discount_amnt,0))/count(rec.consultant)) net_amnt,
    round((((sum(distinct nvl(rec.opd_amnt,0))-sum(distinct nvl(dis.discount_amnt,0))/count(rec.consultant) ) *
    max(dr_per))/100),0) dr_share,
    round((((sum(distinct nvl(rec.opd_amnt,0))-sum(distinct nvl(dis.discount_amnt,0))/count(rec.consultant) ) *
    max(100-dr_per))/100),0) hosp_share,
    count(distinct rec.consultant) net_dis
    from
    select -- bokm_doc_dt receipt_date, bysalim
    bil_recept_no_a rcpt_no,
    fnc_org_sname(bokm_panel_comp_id) company,
    0 return_amnt,
    pr_mrno patient_mrno,pr_fname patient,
    bokm_doc_no docno,
    gcd_desc(bil_pay_mode_a) pay_mode,
    fnc_service_name(rslt_tst_code) service_name,
    dr_name consultant,
    pt_tst_rate opd_amnt,
    cons_share cons_share,
    (select max((nvl(rt_dr_share,0)*(100))/nvl(rt_amount,0))
    from hms_adm_dr_rt rt
    where dr.dr_id = rt.rt_dr_id
    and book.rslt_tst_code = rt.rt_scs_id) dr_per,
    dr_on_rent dr_rent,dr_share
    from hms_pat_pers pat,hms_lab_pat_mst pmst,hms_opd_book book,
    hms_pat_amnt amt,hms_adm_dr dr
    where pat.pr_mrno = pmst.bokm_mrno
    and pmst.bokm_mrno = book.rslt_mrno
    and pmst.bokm_doc_no = book.pt_pat_doc_no
    and pmst.bokm_mrno = amt.bil_mrnum_a
    and pmst.bokm_doc_no = amt.bil_docno_a
    and pmst.bokm_ref_conusltant_id = dr.dr_id
    and amt.bil_rcp_type_a = '075002'
    and pmst.bokm_pat_type in('PVT_OPD','CP_OPD')
    and amt.bil_void_a = 'N'
    and (pmst.bokm_user_dept_code != '039')
    and BOOK.CREATED_ON between '01-OCT-2011' and '17-OCT-2012'
    /* and (pat.pr_curr_cont_id = :P_CONT_ID or :P_CONT_ID = '000')
    and (pat.pr_curr_prvnc_id = :P_PRVNC_ID or :P_PRVNC_ID = '00')
    and (pat.pr_curr_city_id = :P_CITY_ID or :P_CITY_ID = '000')
    and (pat.pr_curr_area = :P_AREA_ID or :P_AREA_ID = '000')
    and (pat.pr_gender = :P_GENDER or :P_GENDER = 'A')
    and (pat.pr_marital_status = :P_MARITAL_STAT or :P_MARITAL_STAT = 'ALL')
    and (to_char(pmst.bokm_panel_comp_id) = :P_PANEL_COMP or :P_PANEL_COMP = 'ALL')
    and (pmst.bokm_ref_conusltant_id = :P_CONS or :P_CONS = 'ALL')
    and (decode(pmst.bokm_panel_comp_id,'1','PVT_IPD','CP_IPD') = :P_PAT_TYPE or :P_PAT_TYPE = 'ALL')
    &LPARA_RCPT_DT */
    ) rec,
    select -- bokm_doc_dt receipt_date, bysalim
    pr_mrno patient_mrno,
    bokm_doc_no docno,
    nvl(bil_disc_amont_a,0) discount_amnt
    from hms_pat_pers pat,hms_lab_pat_mst pmst,hms_opd_book book,
    hms_pat_amnt amt
    where pat.pr_mrno = pmst.bokm_mrno
    and pmst.bokm_mrno = book.rslt_mrno
    and pmst.bokm_doc_no = book.pt_pat_doc_no
    and pmst.bokm_mrno = amt.bil_mrnum_a
    and pmst.bokm_doc_no = amt.bil_docno_a
    and amt.bil_rcp_type_a = '075001'
    and pmst.bokm_pat_type in('PVT_OPD','CP_OPD')
    and amt.bil_void_a = 'N'
    and (pmst.bokm_user_dept_code != '039')
    and BOOK.CREATED_ON between '01-OCT-2011' and '17-OCT-2012'
    /* and (pat.pr_curr_cont_id = :P_CONT_ID or :P_CONT_ID = '000')
    and (pat.pr_curr_prvnc_id = :P_PRVNC_ID or :P_PRVNC_ID = '00')
    and (pat.pr_curr_city_id = :P_CITY_ID or :P_CITY_ID = '000')
    and (pat.pr_curr_area = :P_AREA_ID or :P_AREA_ID = '000')
    and (pat.pr_gender = :P_GENDER or :P_GENDER = 'A')
    and (pat.pr_marital_status = :P_MARITAL_STAT or :P_MARITAL_STAT = 'ALL')
    and (to_char(pmst.bokm_panel_comp_id) = :P_PANEL_COMP or :P_PANEL_COMP = 'ALL')
    and (pmst.bokm_ref_conusltant_id = :P_CONS or :P_CONS = 'ALL')
    and (decode(pmst.bokm_panel_comp_id,'1','PVT_IPD','CP_IPD') = :P_PAT_TYPE or :P_PAT_TYPE = 'ALL')
    and BOOK.CREATED_ON between :P_RCPT_DTFR and :P_RCPT_DTTO
    -- and BOOK.CREATED_ON between :P_RCPT_DTFR and :P_RCPT_DTTO
    &LPARA_RCPT_DT */
    ) dis
    where rec.patient_mrno = dis.patient_mrno (+)
    and rec.docno = dis.docno (+)
    --and patient = 'SHAHMEER'
    group by rec.consultant, --rec.receipt_date, bysalim
    rec.patient_mrno,rec.patient,
    pay_mode,service_name,rec.docno,
    rcpt_no,company
    order by rcpt_no,rec.consultant
    ) cns
    group by cns.consultant
    order by 1
    Edited by: user6431550 on Nov 15, 2012 3:10 AM

    Dear Oracle Report experts,
    I have developed report in oracle reports bulider 10g. while running it from report builder through main menu *** data is coming very SLOW *** within 55 Minuts.
    But, If same query is executing from SQL/PLSQL deverloper it is very fast within 45 second.
    Please suggest any configuration or setting ; is having Idea.
    Thanks
    Muhammad Salim
    Query is as below: generating result in 48 second.
    select cns.consultant,
    sum(cns.nof_pat) noof_pat,
    sum(cns.opd_amnt) opd_amnt,
    sum(cns.discount_amnt) discount_amnt,
    sum(cns.net_amnt) net_amnt,
    sum(cns.dr_share) dr_share,
    sum(cns.hosp_share) hosp_share,
    sum(cns.net_dis) net_dis
    from
    select rec.consultant,
    count(distinct rec.consultant) nof_pat,
    -- rec.receipt_date, bysalim
    pay_mode,
    rec.patient_mrno,rec.patient,
    service_name,rcpt_no,
    company,rec.docno,
    sum(distinct return_amnt) return_amnt,
    sum(distinct rec.opd_amnt) opd_amnt,
    sum(distinct dis.discount_amnt) discount_amnt,
    (sum(distinct nvl(rec.opd_amnt,0))-sum(distinct nvl(dis.discount_amnt,0))/count(rec.consultant)) net_amnt,
    round((((sum(distinct nvl(rec.opd_amnt,0))-sum(distinct nvl(dis.discount_amnt,0))/count(rec.consultant) ) *
    max(dr_per))/100),0) dr_share,
    round((((sum(distinct nvl(rec.opd_amnt,0))-sum(distinct nvl(dis.discount_amnt,0))/count(rec.consultant) ) *
    max(100-dr_per))/100),0) hosp_share,
    count(distinct rec.consultant) net_dis
    from
    select -- bokm_doc_dt receipt_date, bysalim
    bil_recept_no_a rcpt_no,
    fnc_org_sname(bokm_panel_comp_id) company,
    0 return_amnt,
    pr_mrno patient_mrno,pr_fname patient,
    bokm_doc_no docno,
    gcd_desc(bil_pay_mode_a) pay_mode,
    fnc_service_name(rslt_tst_code) service_name,
    dr_name consultant,
    pt_tst_rate opd_amnt,
    cons_share cons_share,
    (select max((nvl(rt_dr_share,0)*(100))/nvl(rt_amount,0))
    from hms_adm_dr_rt rt
    where dr.dr_id = rt.rt_dr_id
    and book.rslt_tst_code = rt.rt_scs_id) dr_per,
    dr_on_rent dr_rent,dr_share
    from hms_pat_pers pat,hms_lab_pat_mst pmst,hms_opd_book book,
    hms_pat_amnt amt,hms_adm_dr dr
    where pat.pr_mrno = pmst.bokm_mrno
    and pmst.bokm_mrno = book.rslt_mrno
    and pmst.bokm_doc_no = book.pt_pat_doc_no
    and pmst.bokm_mrno = amt.bil_mrnum_a
    and pmst.bokm_doc_no = amt.bil_docno_a
    and pmst.bokm_ref_conusltant_id = dr.dr_id
    and amt.bil_rcp_type_a = '075002'
    and pmst.bokm_pat_type in('PVT_OPD','CP_OPD')
    and amt.bil_void_a = 'N'
    and (pmst.bokm_user_dept_code != '039')
    and BOOK.CREATED_ON between '01-OCT-2011' and '17-OCT-2012'
    /* and (pat.pr_curr_cont_id = :P_CONT_ID or :P_CONT_ID = '000')
    and (pat.pr_curr_prvnc_id = :P_PRVNC_ID or :P_PRVNC_ID = '00')
    and (pat.pr_curr_city_id = :P_CITY_ID or :P_CITY_ID = '000')
    and (pat.pr_curr_area = :P_AREA_ID or :P_AREA_ID = '000')
    and (pat.pr_gender = :P_GENDER or :P_GENDER = 'A')
    and (pat.pr_marital_status = :P_MARITAL_STAT or :P_MARITAL_STAT = 'ALL')
    and (to_char(pmst.bokm_panel_comp_id) = :P_PANEL_COMP or :P_PANEL_COMP = 'ALL')
    and (pmst.bokm_ref_conusltant_id = :P_CONS or :P_CONS = 'ALL')
    and (decode(pmst.bokm_panel_comp_id,'1','PVT_IPD','CP_IPD') = :P_PAT_TYPE or :P_PAT_TYPE = 'ALL')
    &LPARA_RCPT_DT */
    ) rec,
    select -- bokm_doc_dt receipt_date, bysalim
    pr_mrno patient_mrno,
    bokm_doc_no docno,
    nvl(bil_disc_amont_a,0) discount_amnt
    from hms_pat_pers pat,hms_lab_pat_mst pmst,hms_opd_book book,
    hms_pat_amnt amt
    where pat.pr_mrno = pmst.bokm_mrno
    and pmst.bokm_mrno = book.rslt_mrno
    and pmst.bokm_doc_no = book.pt_pat_doc_no
    and pmst.bokm_mrno = amt.bil_mrnum_a
    and pmst.bokm_doc_no = amt.bil_docno_a
    and amt.bil_rcp_type_a = '075001'
    and pmst.bokm_pat_type in('PVT_OPD','CP_OPD')
    and amt.bil_void_a = 'N'
    and (pmst.bokm_user_dept_code != '039')
    and BOOK.CREATED_ON between '01-OCT-2011' and '17-OCT-2012'
    /* and (pat.pr_curr_cont_id = :P_CONT_ID or :P_CONT_ID = '000')
    and (pat.pr_curr_prvnc_id = :P_PRVNC_ID or :P_PRVNC_ID = '00')
    and (pat.pr_curr_city_id = :P_CITY_ID or :P_CITY_ID = '000')
    and (pat.pr_curr_area = :P_AREA_ID or :P_AREA_ID = '000')
    and (pat.pr_gender = :P_GENDER or :P_GENDER = 'A')
    and (pat.pr_marital_status = :P_MARITAL_STAT or :P_MARITAL_STAT = 'ALL')
    and (to_char(pmst.bokm_panel_comp_id) = :P_PANEL_COMP or :P_PANEL_COMP = 'ALL')
    and (pmst.bokm_ref_conusltant_id = :P_CONS or :P_CONS = 'ALL')
    and (decode(pmst.bokm_panel_comp_id,'1','PVT_IPD','CP_IPD') = :P_PAT_TYPE or :P_PAT_TYPE = 'ALL')
    and BOOK.CREATED_ON between :P_RCPT_DTFR and :P_RCPT_DTTO
    -- and BOOK.CREATED_ON between :P_RCPT_DTFR and :P_RCPT_DTTO
    &LPARA_RCPT_DT */
    ) dis
    where rec.patient_mrno = dis.patient_mrno (+)
    and rec.docno = dis.docno (+)
    --and patient = 'SHAHMEER'
    group by rec.consultant, --rec.receipt_date, bysalim
    rec.patient_mrno,rec.patient,
    pay_mode,service_name,rec.docno,
    rcpt_no,company
    order by rcpt_no,rec.consultant
    ) cns
    group by cns.consultant
    order by 1
    Edited by: user6431550 on Nov 15, 2012 3:10 AM

  • Why is the select Count too slow

    I am doing the following select count and calling it from my JSP to get the total number of records... why is it so slow...
    select count(*)
    from
    (select distinct o.receive_id, o.name, o.address
    from order o, item i
    where o.id = i.id
    and o.status = 2 and i.status = 0)

    If the data in the table that you are referring to in the query gets refreshed very often and your high water mark on your table not reset, then this query always runs longer. While deleting data in the table, use 'TRUNCATE' rather than 'DELETE' in your data queries. that would help reset the high water mark and your count() queries will run very very fast.

Maybe you are looking for

  • Error while starting WebLogic at background

    Hi, All! I try to start WebLogic at background mode: nohup ./startWebLogic.sh 2&>1 & but got this error: JAVA Memory arguments: -Xms256m -Xmx512m -XX:CompileThreshold=8000 -XX:PermSize=48m -XX:MaxPermSize=192m WLS Start Mode=Development CLASSPATH=/ho

  • Other _root solution

    Hello, I'm coverting my code from AS2 to AS3. I have public variables I've declared on my main ".as" that I've always used in my custom classes by saying _root.varname. Of course _root is gone, so I was wondering if the code I have below is the best

  • Preview your photo book as pdf before clicking on 'Buy Book'.

    Hi, here is the learning from the recent problem I had with photo books. I would suggest that you save your book as a pdf file, before ordering. Preview your pdf file, and when you are satisfied, submit your order. Saving a book as a PDF file: 1. Sel

  • Automatic delivery & billing

    Hai guys, Can U help me out in this regard? there is an integration between third party software and SAP-sd at my client place, if enduser enters data in sales order screen of non-sap system,automatically delivery and billing happens in non-sap syste

  • Unable to update from version 4 to version 5

    I have a VISTA system with Itune that is up to date.  I have had trouble updating my iphone 4 to the new update.  It hangs up on the backing up portion of the sync.