Performance of SUM summary function

Hi All,
I would like to know a little bit about the SUM function from a cost perspective.
I've a SQL query where I'm getting the total time for all users by using "SUM" summary function. The SQL query also has some inetmediate joins/merges
Now my boss says that from the cost perspective we should use application code instead of SUM. He also cited a reason that since the SQL query has so many joins, it would be better to use application code to do the calculations.
Can anyone gimme some insite on this issue?
Appreciate your time
venk

I agree with 4 that is unlikely you could write application code that could join better than Oracle. You might be able to write application code that sums better (unlikely, but concievable). However, if you tried, you would probably blow out both the memory on the application server and the bandwidth on the network.
Even if you could write application code to do the joins and summing 10 times as fast as Oracle does (and if you can, you could certainly get a job with Oracle), the benefit would almost certainly be eliminated by the extra time to move the raw data across the network, and to allocate and free the enormous amounts of memeory that would be required.
Real databases are made to join, sort and aggregate, that's why we buy them.
John

Similar Messages

  • How to replicate the sum by function in RPD.

    Hi All,
    Below is the function being used in report.
    CASE WHEN sum ("product sales information". "Sales amount" by "master calendar". "Years description") is NULL THEN 0 WHEN sum ("product sales information". "Sales amount" by "master calendar". "Date of description ") <= 0 THEN 0 ELSE CASE WHEN sum (" product sales information "." sales amount "by" product master "." product name "," master calendar "." years description ") is NULL THEN 0 ELSE 100 * sum ("product sales information". "sales amount" by "product master". "product name", "master calendar". "years description") / sum ("product sales information". "sales amount "by" master calendar "." years description ") END END
    I am trying to create aggregate measure in RPD and use that in report. The above function works fine when I use that in report but when I tried to create a measure in RPD its giving syntax error.
    Can anyone please help me to create the measure in RPD? Is there any change of syntax for sum by function if we use in RPD?
    Thanks
    Krishna

    HI Srini
    Thanks for your reply. Is there any other way I can replicate this in RPD. Customer is using this function in many places in a dashboard so due to this performance is very slow.
    I am trying to move these functions to RPD.
    Thanks
    Krishna

  • Using The Summary Function in ADG

    Hello All,
    Please see my code below. Im using the advance data grid to create a summary row. The summary row currenty SUMs up the 'unqiuevists' and 'redemptions' columns and all is working well.
    What i want to do is then create a 3rd row called 'conversion rate' this conversion rate is a calculation between the uniquevisits and the redemptions columns. If you review the code at the bottom I have managed to create a custom summary func and that function seems to be working fine (using trace)..
    However, I cannot then get the calculated result back into the advance data grid, am i missing something really obvious or is what Im trying to do not possible using the summary row function?
    Please try and help, Ive been on this for days!
    Thanks
    <?xml version="1.0"?>
    <!-- dpcontrols/adg/SummaryGroupADGCustomSummary.mxml -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="createGrouping(dpFlat)">
        <mx:Script>
            <![CDATA[
                import mx.collections.GroupingField;
                import mx.collections.Grouping;
                import mx.collections.SummaryField;
                import mx.collections.SummaryRow;
                import mx.collections.GroupingCollection;
                import mx.collections.ArrayCollection;
                import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
                import mx.collections.IViewCursor;    
                import mx.collections.SummaryObject;
                private var groupingCollection:GroupingCollection = new GroupingCollection();
                private function createGrouping(tmpArray:ArrayCollection):GroupingCollection
                    groupingCollection.source = tmpArray;
                    var summaryRow:SummaryRow = new SummaryRow;
                    var summaryField:SummaryField = new SummaryField;
                    summaryField.dataField="redemptions";
                    summaryField.operation="SUM";
                    var summaryField1:SummaryField = new SummaryField;
                    summaryField1.dataField="newvisits";
                    summaryField1.operation="SUM";
                    var summaryField2:SummaryField = new SummaryField;
                    summaryField2.dataField="conversionrate";
                    summaryField2.summaryFunction = summFunc;
                    summaryRow.fields = [summaryField,summaryField1,summaryField2];
                    summaryRow.summaryPlacement = "group";
                    summaryRow.summaryObjectFunction = summObjFunc;
                    var grouping:Grouping = new Grouping();
                    var groupingField:GroupingField = new GroupingField("site");
                    var groupingField1:GroupingField = new GroupingField("merchant");
                    grouping.fields=[groupingField,groupingField1];
                    groupingField.summaries = [summaryRow];
                    groupingField1.summaries = [summaryRow];
                    groupingCollection.grouping = grouping;
                    groupingCollection.refresh();
                    return groupingCollection;
               [Bindable]
                private var dpFlat:ArrayCollection = new ArrayCollection([
                  {site:"BBVA", merchant:"TALLINK", Offer:"10% Off", newvisits:38865, redemptions:40000},
                  {site:"BBVA", merchant:"LIVEIT", Offer:"10% Off", newvisits:29885, redemptions:30000}, 
                  {site:"CartaSi", merchant:"Central California", Offer:"10% Off", newvisits:29134, redemptions:30000}, 
                  {site:"CartaSi", merchant:"Nevada", Offer:"10% Off", newvisits:52888, redemptions:45000}, 
                  {site:"BarclayCard", merchant:"Northern California", Offer:"10% Off", newvisits:38805, redemptions:40000},
                  {site:"BarclayCard", merchant:"Northern California", Offer:"10% Off", newvisits:55498, redemptions:40000}, 
                  {site:"Nordea", merchant:"Southern California", Offer:"10% Off", newvisits:44985, redemptions:45000},
                  {site:"Nordea", merchant:"Southern California", Offer:"10% Off", newvisits:44913, redemptions:45000},
                  {site:"BBVA", merchant:"TALLINK", Offer:"10% Off", newvisits:38865, redemptions:40000},
                  {site:"BBVA", merchant:"LIVEIT", Offer:"10% Off", newvisits:29885, redemptions:30000}, 
                  {site:"CartaSi", merchant:"Central California", Offer:"10% Off", newvisits:29134, redemptions:30000}, 
                  {site:"CartaSi", merchant:"Nevada", Offer:"10% Off", newvisits:52888, redemptions:45000}, 
                  {site:"BarclayCard", merchant:"Northern California", Offer:"10% Off", newvisits:38805, redemptions:40000},
                  {site:"BarclayCard", merchant:"Northern California", Offer:"10% Off", newvisits:55498, redemptions:40000}, 
                  {site:"Nordea", merchant:"Southern California", Offer:"10% Off", newvisits:44985, redemptions:45000},
                  {site:"Nordea", merchant:"Southern California", Offer:"10% Off", newvisits:44913, redemptions:45000},
                private function summFunc(cursor:IViewCursor, dataField:String,
                    operation:String):Number {
                    var conversionrate:Number = 0;
                    conversionrate +=  (cursor.current["redemptions"] / cursor.current["newvisits"]) * 100
                    trace (dataField)
                    trace (conversionrate);      
                    return conversionrate;
                 private function summObjFunc():SummaryObject {
                    // Define the object containing the summary data.
                    var obj:SummaryObject = new SummaryObject();
                    // Add a field containing a value for the Territory_Rep column.
                    obj.conversionrate2 = "Alternating Reps";
                    return obj;
          ]]>
        </mx:Script>
        <mx:DataGrid id="test" dataProvider="{dpFlat}">
        </mx:DataGrid>
        <mx:AdvancedDataGrid id="myADG"  width="100%" height="100%"  dataProvider="{createGrouping(dpFlat)}">       
            <mx:columns>
                <mx:AdvancedDataGridColumn dataField="site"/>
                <mx:AdvancedDataGridColumn dataField="offer"/>
                <mx:AdvancedDataGridColumn dataField="newvisits"/>
                <mx:AdvancedDataGridColumn dataField="redemptions"/>
                <mx:AdvancedDataGridColumn dataField="conversionrate"/>
                <mx:AdvancedDataGridColumn dataField="conversionrate2"/>
            </mx:columns>
       </mx:AdvancedDataGrid>
        <mx:Button label="Button" click="groupingCollection.refresh()"/>
    </mx:Application>

    For those who are interested this is the corrected custom summary function -
    private function summFunc(cursor:IViewCursor, dataField:String,
                    operation:String):Number {
                    var totalNewVisits:Number = 0
                    var totalNewRedemptions:Number = 0
                    var tmpVisits:Number = 0;
                    var tmpRedemptions:Number = 0;      
                    while (!cursor.afterLast)
                        tmpVisits = cursor.current["newvisits"];
                        totalNewVisits += tmpVisits;
                        tmpRedemptions = cursor.current["redemptions"];
                        totalNewRedemptions += tmpRedemptions;
                        cursor.moveNext()
                    var conversionrate:Number = 0;
                    conversionrate =  (totalNewRedemptions / totalNewVisits) * 100
                    return conversionrate;

  • Performance issue for this function-module(HR_TIM_REPORT_ABSENCE_DATA)

    Hi Friends
    I am having performance issue for this function-module(HR_TIM_REPORT_ABSENCE_DATA) and one my client got over 8 thousend employees . This function-module taking forever to read the data. is there any other function-module to read the absences data IT2001 .
    I did use like this .if i take out this F.M 'HR_TIM_REPORT_ABSENCE_DATA_INI' its not working other Function-module.please Suggest me .
    call function 'HR_TIM_REPORT_ABSENCE_DATA_INI'
    exporting "Publishing to global memory
    option_string = option_s "string of sel org fields
    trig_string = trig_s "string of req data
    alemp_flag = sw_alemp "all employee req
    infot_flag = space "split per IT neccessary
    sel_modus = sw_apa
    importing
    org_num = fdpos_lines "number of sel org fields
    tables
    fieldtab = fdtab "all org fields
    field_sel = fieldnametab_m. "sel org fields
    To Read all infotypes from Absences type.
    RP_READ_ALL_TIME_ITY PN-BEGDA PN-ENDDA.
    central function unit to provide internal tables: abse orgs empl
    call function 'HR_TIM_REPORT_ABSENCE_DATA'
    exporting
    pernr = pernr-pernr
    begda = pn-begda
    endda = pn-endda
    IMPORTING
    SUBRC = SUBRC_RTA
    tables
    absences = absences_01
    org_fields = orgs
    emp_fields = empl
    REFTAB =
    APLTAB =
    awart_sel_p = awart_s[]
    awart_sel_a = awart_s[]
    abstp_sel = abstp_s[]
    i0000 = p0000
    i0001 = p0001
    i0002 = p0002
    i0007 = p0007
    i2001 = p2001
    i2002 = p2002
    i2003 = p2003.
    Thanks & Regards
    Reddy

    guessing will not help you much, check with SE30 to get a better insight
    SE30
    The ABAP Runtime Trace (SE30) -  Quick and Easy
    what is the total time, what are the Top 10 in the hitlist.
    Siegfried

  • Problem using SUM standard function  during Field Mapping

    Hi Experts ,
    I am trying to sum all LIFMG 's in in the lineitems of a particular
    header and map this result to Lifmg of the header.(Idoc with multiple headers and line item).I am using SUM standard function.
    Rough Source structure.
    Header1
          vbeln
    ....Lineitem1
          vbeln
          posnr
    ......LIFMG
    ....Lineitem2
            vbeln
            posnr
    ......LIFMG
    Header2
         vbeln
    ....Lineitem1
            vbeln
           posnr
    ......LIFMG
    ....Lineitem2
            vbeln
           posnr
    ......LIFMG
    I am able to find the SUM ...but in the target structure's Header field  I am getting
    repeated value of the corresponding sum in each header ...i.e.
    Header1
    LFIMG-- 100
    LFIMG    100
    Header2
    LFIMG-- 102
    LFIMG    102
    How to get a single value for each .
    Regards,
    Deepak

    Solved Myself ...
    Placed  sum after  if without else ...
    placing it before was causing ...those values to be replicated.

  • Why does the Summary function give a datatype error when opening a data model for editing?

    I have two datasets (G1 and G2) within a data model; i've used a field in G2 and placed it into G1 as a Summary Function of G2. The datatype of this field in G2 is Integer, however if you set the Summary field in G1 to the same datatype - Integer, an error appears.

    Oracle have provided a patch.
    We are running OBIEE  at patchset  11.1.1.7.140715, Oracle have provided us with a  patch p17563277  backported to the 140715 patchset.
    This fix will presumably be incorporated in later releases.

  • SUM analytical function

    Hi,
    I am using the SUM analytical function to accumulate some data from one record to the other record (data per month):
    TPS_MOI_CODE     PRD_PRD_CODE     PDV_PDV_CODE     RTTCAVCANV
    200510     01     9302     -8050
    200511     01     9302     -15500
    200512     01     9302     -16150
    200601     01     9302     -16150
    200602     01     9302     -16150
    200603     01     9302     -16150
    The result is correct. However, I also want to restart the sum from January, i.e every months contain the sum of all the previous month, and it must restart in January.
    How do I do that ?
    Thanks in advance for your answers.

    You should extract a year and use it as the partition in over() clause, for example:
    SQL> select * from t;
         DATE#        QTY
        200510          1
        200511          2
        200512          3
        200601          4
        200602          5
        200603          6
    6 rows selected.
    SQL> desc t;
    Name                                      Null?    Type
    DATE#                                              NUMBER
    QTY                                                NUMBER
    SQL> select date#, sum(qty) over(partition by substr(date#,1,4) order by date#) cum_sum
      2  from t;
         DATE#    CUM_SUM
        200510          1
        200511          3
        200512          6
        200601          4
        200602          9
        200603         15
    6 rows selected.Rgds.

  • We had some accuracy issues with NI 5112 scope in one of the ATE and then I decided to perform self calibration using Labvidew vi to perform "niScope_CalSelfCalibrate(handle, "", 0);" function.

    We had some accuracy issues with NI 5112 scope in one of the ATE and then I decided to perform self calibration using Labvidew vi to perform “niScope_CalSelfCalibrate(handle, "", 0);” function.
    But it made it worse. I tried using option 2 to restore but it did not work.
    Could you pls advice me to resolve this issue.

    Hi Ana10,
    Are you using this digitizer with NI VideoMaster? if not you should probably post this in the Digitizer forums. That said I would suggest using the self calibrate function in MAX for this device rather than the LabVIEW API method just so that you can rule out any errors in correctly configuring the digitizer for self cal in LabVIEW. Also you should ensure that all inputs are disconnected before performing a self cal. If this still results in an error in calibration you could refer to the following document or arrange to return the digitizer to NI for external calibration.
    http://www.ni.com/pdf/manuals/370328e.pdf
    Hope this helps,
    Nick

  • An extra parameter for Summary function..

    Why cant oracle give an extra parameter for summary function like MAX and MIN
    For example
    select max(salary,2)
    from empWill give the second max salary...
    Edited by: 884476 on Dec 19, 2012 7:13 AM
    Just a thought..

    Hi,
    884476 wrote:
    Frank Kulash wrote:
    The built-in function NTH_VALUE (new in Oracle 11.2) does that.This is not an actual GROUPING function, right..?That depends on what you mean.
    NTH_VALUE and GROUPING are two separate functions. MAX and GROUPING are also separate functions.
    If, by "actual GROUPING function" you mean something other than a single-row function, then, yes, it is an actual grouping function. The value returned by the function can depend on all the values in the group, and not just the arguments from one row.
    Are you asking if NTH_VALUE is an aggregate function? No, it is only an analytic function; it does not have an aggregate version. If you want aggregate-style results from analytic functions, then use SELECT DISTINCT.
    In Oracle 9.1 (or higher) you can write a user-defined function.:)I should have said you can write a user-defined aggregate function. Starting in Oracle 7, you could write user-defined functions, but they were not generic. For example, you could write a function that returned the n-th highest sal from scott.emp, but it wouldn't return anything from hr.employees, nor could it return the n-th highest empno from scott.emp. Using dynamic SQL, you could write a fucntion where you passed a table name and a column name as well as n, and it would return the n-th highest value, as long as that column had the right datatype.

  • HOW TO IMPROVE PERFORMANCE ON SUM FUNCTION IN INLINE SQL QUERY

    SELECT NVL(SUM(B1.T_AMOUNT),0) PAYMENT,B1.ACCOUNT_NUM,B1.BILL_SEQ
    FROM
    SELECT P.T_AMOUNT,P.ACCOUNT_NUM,P.BILL_SEQ
    FROM PAYMENT_DATA_VIEW P
    WHERE TRUNC(P.ACC_PAYMENT_DATE) < '01-JAN-2013'
    AND P.CUSTOMER_NAME ='XYZ'
    AND P.CLASS_ID IN (-1,1,2,94)
    ) B1
    GROUP BY B1.ACCOUNT_NUM,B1.BILL_SEQ
    Above is the query.If we run inner query it takes few second to execute but while we are summing up the same amount and bill_Seq using inline view, it takes time to execute it.
    Note: Count of rows selected from inner query will be around >10 Lac
    How to improve the performance for this query?
    Pls suggest
    Thanks in advance

    989209 wrote:
    SELECT NVL(SUM(B1.T_AMOUNT),0) PAYMENT,B1.ACCOUNT_NUM,B1.BILL_SEQ
    FROM
    SELECT P.T_AMOUNT,P.ACCOUNT_NUM,P.BILL_SEQ
    FROM PAYMENT_DATA_VIEW P
    WHERE TRUNC(P.ACC_PAYMENT_DATE) < '01-JAN-2013'
    AND P.CUSTOMER_NAME ='XYZ'
    AND P.CLASS_ID IN (-1,1,2,94)
    ) B1
    GROUP BY B1.ACCOUNT_NUM,B1.BILL_SEQ
    Above is the query.If we run inner query it takes few second to execute but while we are summing up the same amount and bill_Seq using inline view, it takes time to execute it.
    Note: Count of rows selected from inner query will be around >10 Lac
    How to improve the performance for this query?
    Pls suggest
    Thanks in advancea) Lac is not an international unit, so is not understood by everyone. This is an international forum so please use international units.
    b) Please read the FAQ: {message:id=9360002} to learn how to format your question correctly for people to help you.
    c) As your question relates to performance tuning, please also read the two threads linked to in the FAQ: {message:id=9360003} for an idea of what specific information you need to provide for people to help you tune your query.

  • Performing math on Decode function tags and moving averages

    I have a query shown below to create columns for my report. Can I use the field names as shown in bold to perform math functions? Is there an easy way to do this?
    select Data_date,
    SUM(DECODE(tag_id,'SEF_F0348I',avg_value,NULL))"TE_Flow_mgd",
    SUM(DECODE(tag_id,'L_STEbod_con',avg_value,NULL))"TE_BOD_mgl",
    "TE_FLOW_mgd" * "TE_BOD_mgl" * 8.34*.45359 as "KG_BOD"FROM daily_tag_data
    Where data_date >= to_date('12/31/2002','mm/dd/yyyy')
    GROUP BY data_date;
    Also how would I perform a seven day moving average on "KG_BOD"
    Thanks - Very new at this.

    If you want avoid a sub-query, try this...
    select Data_date,
    SUM(DECODE(tag_id,'SEF_F0348I',avg_value,NULL))"TE_Flow_mgd",
    SUM(DECODE(tag_id,'L_STEbod_con',avg_value,NULL))"TE_BOD_mgl",
    SUM(DECODE(tag_id,'SEF_F0348I',avg_value,NULL)) * SUM(DECODE(tag_id,'L_STEbod_con',avg_value,NULL)) * 8.34*.45359 "KG_BOD"
    FROM daily_tag_data
    Where data_date >= to_date('12/31/2002','mm/dd/yyyy')
    GROUP BY data_date;
    just replace the 'column-alias' with the actual arithmetic fuction...

  • How to use sum analytic function in adf

    Hi
    jdev 11.1.1.5
    oracle 11g r2
    I want to use analytic function (sum,count,avg and ...) .
    I see [url http://andrejusb.blogspot.co.uk/2013/02/oracle-analytic-functions-for-total-and.html]Oracle Analytic Functions for Total and Average Calculation in ADF BC
    and use it in my vo and jsf page,my vo have too much record and I want to have sum in table footer on demand (because of performance) and if user do not want to see the sum in footer of table it do not calculate sum,
    what is your idea?

    Before I read that blog I use another vo for sum but after that blog decide to use analytic fuction becuase we have some page that have to many dvt graph and table and know we use seperate vo for them and it has not good performance and too many query must run in database ,I want to have 1 vo with some analytic function for graph and tables

  • Bad performance when calling a function in where clause

    Hi All,
    I have a performance problem when executing a query that contains a function call in my where clause.
    I have a query with some joins and a where clause with some regular filters. But one of these filters is a function, and its input parameters are columns of the tables used in the query.
    When I run it with only a few rows in the tables, it goes ok. But as the number of rows grows, performance falls geometrically, even when my where clause filters the result to only a few rows.
    If I take the function call off of the where clause, then run the query and then call the function for each returned row, performance is ok. Even when the number of returned rows is big.
    But I need the function call to be in the where clause, because I can't build a procedure to execute it.
    Does anyone have any clue on how to improve performance?
    Thanks,
    Rafael

    You have given very little information...
    >
    If I take the function call off of the where clause, then run the query and then call the function for each returned row, performance is ok. Even when the number of returned rows is big. Can you describe how you measured the performance for a big result set without the function? For example lets say there had been 10.000 rows returned (which is not really big, but it is astarting point). Did you see all 10.000 rows? A typical mistake is to execute the query in some tool like Oracle SQL Developer or TOAD and measure how fast the first couple of rows are returned. Not the performance of the full select.
    As you can see from this little detail there are many questions that you need to address first before we can drill down to the root of your problem. Best way is to go through the thread that Centinul linked and provide all that information first. During the cause of that you might discover that you learn things on the way that help a lot for later tuning problems/approaches.
    Edited by: Sven W. on Aug 17, 2009 5:16 PM

  • Oracle Query Performance While calling a function in a View

    Hi,
    We have a performance issue in one of our Oracle queries.
    Here is the scenario
    We use a hard coded value (which is the maximum value from a table) in couple of DECODE statements in our query. We would like to remove this hard coded value from the query. So we wrote a function which will return a maximum value from the table. Now when we execute the query after replacing the hard coded value with the function, this function is called four times which hampers the query performance.
    Pl find below the DECODE statements in the query. This query is part of a main VIEW.
    Using Hardcoded values
    =================
    DECODE(pro_risk_weighted_ctrl_scr, 10, 9.9, pro_risk_weighted_ctrl_scr)
    DECODE(pro_risk_score, 46619750, 46619749, pro_risk_score)
    Using Functions
    ============
    DECODE (pro_risk_weighted_ctrl_scr, rprowbproc.fn_max_rcsa_range_values ('CSR'), rprowbproc.fn_max_rcsa_range_values('CSR')- 0.1, pro_risk_weighted_ctrl_scr)
    DECODE (pro_risk_score, rprowbproc.fn_max_rcsa_range_values ('RSR'), rprowbproc.fn_max_rcsa_range_values ('RSR') - 1, pro_risk_score)
    Can any one suggest a way to improve the performance of the query.
    Thanks & Regards,
    Raji

    drop table max_demo;
    create table max_demo
    (rcsa   varchar2(10)
    ,value  number);
    insert into max_demo
    select case when mod(rownum,2) = 0
                then 'CSR'
                else 'RSR'
           end
    ,      rownum
    from   dual
    connect by rownum <= 10000;   
    create or replace function f_max (
      i_rcsa    in   max_demo.rcsa%TYPE
    return number
    as
      l_max number;
    begin
       select max(value)
       into   l_max
       from   max_demo
       where  rcsa = i_rcsa;
       return l_max;
    end;
    -- slooooooooooooowwwwww
    select m.*
    ,      f_max(rcsa)
    ,      decode(rcsa,'CSR',decode(value,f_max('CSR'),'Y - max is '||f_max('CSR'),'N - max is '||f_max('CSR'))) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,f_max('RSR'),'Y - max is '||f_max('RSR'),'N - max is '||f_max('RSR'))) is_max_rsr
    from   max_demo m
    order by value desc;
    -- ssllooooowwwww
    with subq_max as
         (select f_max('CSR') max_csr,
                 f_max('RSR') max_rsr
          from   dual)
    select m.*
    ,      decode(rcsa,'CSR',s.max_csr,'RSR',s.max_rsr) max
    ,      decode(rcsa,'CSR',decode(value,s.max_csr,'Y - max is '||s.max_csr,'N - max is '||s.max_csr)) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,s.max_rsr,'Y - max is '||s.max_rsr,'N - max is '||s.max_rsr)) is_max_rsr
    from   max_demo m
    ,      subq_max s
    order by value desc;
    -- faster
    with subq_max as
         (select /*+materialize */
                 f_max('CSR') max_csr,
                 f_max('RSR') max_rsr
          from   dual)
    select m.*
    ,      decode(rcsa,'CSR',s.max_csr,'RSR',s.max_rsr) max
    ,      decode(rcsa,'CSR',decode(value,s.max_csr,'Y - max is '||s.max_csr,'N - max is '||s.max_csr)) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,s.max_rsr,'Y - max is '||s.max_rsr,'N - max is '||s.max_rsr)) is_max_rsr
    from   max_demo m
    ,      subq_max s
    order by value desc;
    -- faster
    with subq_max as
         (select f_max('CSR') max_csr,
                 f_max('RSR') max_rsr,
                 rownum
          from   dual)
    select m.*
    ,      decode(rcsa,'CSR',s.max_csr,'RSR',s.max_rsr) max
    ,      decode(rcsa,'CSR',decode(value,s.max_csr,'Y - max is '||s.max_csr,'N - max is '||s.max_csr)) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,s.max_rsr,'Y - max is '||s.max_rsr,'N - max is '||s.max_rsr)) is_max_rsr
    from   max_demo m
    ,      subq_max s
    order by value desc;
    -- sloooooowwwwww
    select m.*
    ,      decode(rcsa,'CSR',s.max_csr,'RSR',s.max_rsr) max
    ,      decode(rcsa,'CSR',decode(value,s.max_csr,'Y - max is '||s.max_csr,'N - max is '||s.max_csr)) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,s.max_rsr,'Y - max is '||s.max_rsr,'N - max is '||s.max_rsr)) is_max_rsr
    from   max_demo m
    ,      (select /*+ materialize */
                 f_max('CSR') max_csr,
                 f_max('RSR') max_rsr
          from   dual) s
    order by value desc;
    -- faster
    select m.*
    ,      decode(rcsa,'CSR',s.max_csr,'RSR',s.max_rsr) max
    ,      decode(rcsa,'CSR',decode(value,s.max_csr,'Y - max is '||s.max_csr,'N - max is '||s.max_csr)) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,s.max_rsr,'Y - max is '||s.max_rsr,'N - max is '||s.max_rsr)) is_max_rsr
    from   max_demo m
    ,      (select f_max('CSR') max_csr,
                   f_max('RSR') max_rsr,
                   rownum
            from   dual) s
    order by value desc;

  • Performance improvement in a function module

    Hi All,
    I am using SAP 6.0 version. I have a function module to retrive the PO's . for just 10,000 records its taking long time.
    Can any one sugguest the ways to improve the performance.
    Thanks in advance.

    Moderator message - Welcome to SCN.
    But
    Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting
    Just 10,000 records? The first rule in performance improvement is to reduce the amount of selected data. If you cannot do that, it's going to take time.
    I wouldn't bother with a BAPI for so many records. Write some custom code to get only the data you need.
    Tob

Maybe you are looking for

  • Is there a way to create a dynamic random playlist?

    I am upgrading (downgrading?) from a 60gb 5G iPod to a Touch. Since the Touch has less space on it than my former iPod, I would like to know if there is a way to have it filled with different random songs each time it is docked. I know how to create

  • Lock screen question? :)

    Let me start off by saying that I absolutely LOVE the ICS update. Great job SONY There is one minor negative I noticed.On GB the lock screen would show unread text messages, missed calls and facebook notificatiuon count. On ICS it no longer shows thi

  • Tabular form- button to save primary key to variable?

    Hi guys. I have a tabular data block that has results. Now I have put a command button next to each record. How would I go about when I click the button, it actually refers to that record? I have put the buttons on (when you put it on with the data b

  • Correct cover icon size

    Good day When exporting for Adobe Indesign, what is the size and format for the cover in order for the icon to display correctly in ADE? I have created an ePub3 document in indesign in 1536px x 2048px size and the cover icon keeps cropping on the rig

  • Problems with my printer

    I bought a printer and I can't print with it. I called the support of canon and they said that they can't do anything because when I go in Finder, and then library and then Printers, there is no «Canon» file.... How can I unninstall my printer if the