Calling an SP takes over 200% more time over the select statement

As part of my POC converting a SQL Server application over to SAP HANA, I'm find that CALL is taking over 200% more time than calling the SELECT statement directly. The result is that the application that uses ODBC against HANA with CALL statements is taking much more time than SQL Server. I'm finding this for all stored procedure calls in the application. Here is an example:
CREATE PROCEDURE dbo.usp_GetOrdersByCustomerID
(IN C_ID bigint)
LANGUAGE SQLSCRIPT DEFAULT SCHEMA "DBO" READS SQL DATA
AS BEGIN
SELECT  TOP 20
   C_F_NAME,
            C_L_NAME,
            C_EMAIL,
            O_ID,
            O_TOTAL,
            O_DTS,
            O_FM_DTS
FROM    dbo.Customer JOIN dbo.Orders ON C_ID = O_C_ID
WHERE   C_ID = :C_ID
    ORDER   BY O_ID DESC;
END;
When using the following CALL statement in SAP HANA Studio
CALL dbo.usp_GetOrdersByCustomerID(3429);
I get execution times that look like this:
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 9 ms 663 µs  (server processing time: 8 ms 115 µs)
Fetched 5 row(s) in 0 ms 69 µs (server processing time: 0 ms 0 µs)
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 11 ms 851 µs (server processing time: 8 ms 238 µs)
Fetched 5 row(s) in 0 ms 62 µs (server processing time: 0 ms 0 µs)
Statement 'CALL dbo.usp_GetOrdersByCustomerID(3429)'
successfully executed in 8 ms 522 µs  (server processing time: 6 ms 892 µs)
Fetched 5 row(s) in 0 ms 93 µs (server processing time: 0 ms 0 µs)
When I execute the select statement with the hard coded parameter value, I get much faster results:
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 430 µs  (server processing time: 2 ms 424 µs)
Fetched 5 row(s) in 0 ms 73 µs (server processing time: 0 ms 0 µs)
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 105 µs  (server processing time: 2 ms 210 µs)
Fetched 5 row(s) in 0 ms 69 µs (server processing time: 0 ms 0 µs)
Statement 'SELECT TOP 20 C_F_NAME, C_L_NAME, C_EMAIL, O_ID, O_TOTAL, O_DTS, O_FM_DTS FROM dbo.Customer JOIN ...'
successfully executed in 4 ms 694 µs  (server processing time: 2 ms 810 µs)
Fetched 5 row(s) in 0 ms 60 µs (server processing time: 0 ms 0 µs)
I have 500,000 rows in the Customers table and 2,500,000 rows in the Orders table. The tables are COLUMN tables.
Is there an optimization that I'm missing?
Regards,
Bill

Hi Bill,
Can you please try something:
tab_cust =
SELECT
   C_F_NAME,
            C_L_NAME,
            C_EMAIL
FROM    dbo.Customer
WHERE   C_ID = :C_ID;
tab_orders =
SELECT
            O_ID,
            O_TOTAL,
            O_DTS,
            O_FM_DTS
FROM    dbo.Orders ON C_ID = O_C_ID
WHERE   O_C_ID = :C_ID
SELECT  TOP 20
   C_F_NAME,
            C_L_NAME,
            C_EMAIL,
            O_ID,
            O_TOTAL,
            O_DTS,
            O_FM_DTS
FROM    :tab_cust JOIN :tab_orders ON C_ID = O_C_ID
    ORDER   BY O_ID DESC;
END;
Expected behavior: The data set for each of the tables is filtered out and then joined. Although the filter is expected to be pushed to each of the joined tables even in your case, but this is worth the try.
Regards,
Ravi

Similar Messages

  • Adding one more table to the select statement joining 4 tables gives dump

    Hi All,
    There is a select statement using which four tables namely VBAK,VBAP,LIPS and LIKPUK(view) are joined(inner join).Here, date and time fields are selected from LIPS and used.
    My requirement is to consider the Date (LIKP - WADAT_IST) instead of LIPS-ERDAT  and time(LIKP-SPE_WAUHR_IST) is to be used instead of LIPS-erzet.
    Neither LIPS nor LIKPUK contains time(SPE_WAUHR_IST) field. And, I cannot remove LIPS table or LIKPUK view as each contains a unique field which is used in the report.
    When I tried to join LIPS in the select query, it is going to dump.
    Can someone suggest a good approach ?
    Thanks,
    Pavan

    Thank you for the detailed explanation of the dump.
    The dump details together with your code lead to the answer: 42.
    Regards,
    Clemens

  • Saving a book as PDF takes significantly more time when the file binary *.fm rater than *.mif?

    Is it possible, that saving a book (with FrameMaker 10) as PDF takes significantly more time when the file is formatted in the binary *.fm rather than the *.mif format?
    We have books (+160p) that take about 20 min to be saved as PDF, whereas the same book in MIF format can be saved as PDF within about 4 minutes. Is this a known issue?
    Or could that be a problem with our books?
    Does anyone know how to speed up the process (how to tweak) or are there any special adjustments in the books or documents that might slowdown the process of saving them as PDF?
    The distiller seems not to be the problem. The distiller takes equally long for both formats.
    best regards

    Strikes me as peculiar. I would expect that FM is rendering from the data structures in memory, which I would expect to be essentially identical whether originally opened as .fm or .mif.
    If return-to-UI time is important, the fastest path is:
    print to local .ps file
    Distill separately.
    And it sounds like you have the full Acrobat product, and thus have full Distiller.
    I don't have sufficient experience with Print-to-PDF vs. Save-as-PDF to opine on potential time differences for those paths.

  • XML Publisher(XDODTEXE) in EBS taking more time with the same SQL in TOAD

    HI
    XML Publisher(XDODTEXE) in EBS taking more time with the same SQL in TOAD.
    The sql has 5 union clauses.
    It takes 20-30 minutes in TOAD compared to running through Concurrent Program in XML Publisher in EBS taking around 4-5 hours.
    The Scalable Flag at report level is turned on with the JVM options set to -Xmx1024m -Xmx1024m in Concurrent Program definition.
    Other configurations for Data Template like XSLT, Scalable, Optimization are turned on though didn't bounce the OPP Server for these to take effect as I am not sure whether it is needed.
    Thanks in advance for your help.

    But the question is that how come it is working in TOAD and takes only 15-20 minutes?
    with initialization of session ?
    what about sqlplus ?
    Do I have to set up the the temp directory for the XML Publisher report to make it faster?
    look at
    R12: Troubleshooting Known XML Publisher and E-Business Suite (EBS) Integration Issues (Doc ID 1410160.1)
    BI Publisher - Troubleshooting Oracle Business Intelligence (XML) Publisher For The Oracle E-Business Suite (Doc ID 364547.1)

  • Can call a function in the select statement?

    Is there any ways to call a function in the select statement?
    what I like to do is this:
    select deptno, totalEmployees(deptno), TotalSalary(deptno)
    from emp;
    I know it can be done by count(*) and join tables, but my case
    is much more complex and the where clauses are different from
    one function to another, and have many tables to join and many
    combinations
    Thanks

    Functions can be used in a select statement subject to certain
    restrictions, see
    http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/
    server.817/a85397/statem9b.htm#2062024
    It's under "CREATE FUNCTION> Keywords and Parameters> function>
    Restrictions on User-Defined Functions"
    Here is an except...
    When a function is called from within a query or DML statement,
    the function cannot:
    a) Have OUT or IN OUT parameters
    b) Commit or roll back the current transaction, create or roll
    back to a savepoint, or alter the session or the system. DDL
    statements implicitly commit the current transaction, so a user-
    defined function cannot execute any DDL statements.
    c) Write to the database, if the function is being called from a
    SELECT statement. However, a function called from a subquery in
    a DML statement can write to the database.
    d) Write to the same table that is being modified by the
    statement from which the function is called, if the function is
    called from a DML statement.
    Except for the restriction on OUT and IN OUT parameters, Oracle
    enforces these restrictions not only for the function called
    directly from the SQL statement, but also for any functions that
    function calls, and on any functions called from the SQL
    statements executed by that function or any function it calls.

  • How can I call a Page Process from the Select statement for Report Page

    I'm able to call a javascript using the below:
    img src="#IMAGE_PREFIX#add2.gif" border="0" alt="Icon 4" onClick="javascript:add_connect1('||CPORT.ID||')"
    But Now,
    I'd like to accomplish (2) New things:
    1. instead of using,....... onClick="javascript:add_connect1,
    I'd like to call a Page Process, onClick=
    2. I'd like to be able to call two different processes onClick.
    a. onClick="javascript:passBack('||ID||')"
    b. onClick= <Please see my question #1 above>
    Can someone please help me with the syntax for this,
    If indeed it can even be done?
    Thanks- Gary

    Greg.
    It seems that my situation is the one you describe in you second paragraph, where you mention:
    you could then add the ID column value as a parameter to the javascript functionBut,
    I do not know how to reference the variable in my javascript nor how to use it in my on-demand process.
    If you can hellp me past this last little bump, then I think I will be able to use these skills in Sooo many different areas of my design.
    Here's what I've got so far:
    A. In the select statement I identify the javascript as:
    onClick="javascript:connect_port('<font color=blue>''||ID||''</font>')";
    B. In my javascript I have this:
    <script language="JavaScript" type="text/javascript">
    function connect_port(ID)
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=CONNECT_PORT',0);
    gReturn = get.get();
    get = null;
    </script>
    C. In my on demand function I have this:
    BEGIN
    INSERT INTO CCONNECTIONS_B
    BLDG_ID,CLST_ID,PORT_ID,STRAND_ID
    ) VALUES
    :P2004_BLDG_ID,:P2004_CLST_ID,:P2004_PORT_ID,:P2004_STRAND_ID1
    END;
    You can see that I dont know how to use the value for 'ID' in either the javascript or the On-Process function.
    If you can help me out with this one, Then I can imitate it for the rest.
    -Gary
    Edited by: garyNboston on Apr 3, 2009 6:44 AM
    Edited by: garyNboston on Apr 3, 2009 6:44 AM
    Edited by: garyNboston on Apr 3, 2009 6:45 AM
    Edited by: garyNboston on Apr 3, 2009 6:47 AM

  • Class not getting called by the Select Statement

    Dear All,
    I have created a new class "Z1_EXIT_VARIABLES" in my Dev system and coded for a new Exit Variable for InfoObject "0FISCPER3" in this class.
    But on debugging the Function module "EXIT_SAPLRRS0_001" (INCLUDE ZXRSRU01), I could find that the Select statement
    <i>select CLSNAME
    into  l_clsname
    from VSEOIMPLEM
    where REFCLSNAME = 'ZBWIF_VAR_EXIT'.
    </i>
    calls ALL the classes mentioned in the table "VSEOIMPLEM" with    REFCLSNAME = ZBWIF_VAR_EXIT, EXCEPT the class "Z1_EXIT_VARIABLES". Therefore, the code written by me is not getting executed.
    Also, after debugging the same function module in Quality system, I could find that not all of the classes mentioned in the table "VSEOIMPLEM"are getting called by the select statement.
    (I do not have authorization for CMOD in my Dev system)
    Can anyone suggest a possible solution to the problem ?
    Regards
    Shalabh Jain

    Hi,
    Still waiting for response.
    The issue is not with finding control and performing action on it.
    The coded UI automation script is able to find the control and performing click on that, and after that is is supposed to display the results, which is not happening.
    I am not able to find out why the results are not displaying with coded UI but it's working as expected with SELENIUM web driver.
    I have to do it with CODED UI VS2013, So i request you to give me some solution for this issue, I have done automation earlier for some similar web applications, but never faced this situation.
    Studio: VS2013
    Scripting Language: C#
    HtmlHyperlink performSearchLink = new HtmlHyperlink(inventoryWindow);
     performSearchLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Search");
                Mouse.Click(performSearchLink);
    this code is working fine, it's clicking on search but not displaying the results.
    someone reply asap.
    Thanks
    Adrusta

  • How do we tune a query that takes more time for the first time?

    Hi,
    First time it takes 20 secs and subsequent times 2 secs.
    Let me know if you need more info
    Thanks

    Following are the parameters set at the DB level.
    .__db_cache_size=2214592512
    .__java_pool_size=16777216
    .__large_pool_size=16777216
    .__shared_pool_size=1543503872
    .__streams_pool_size=33554432
    *._optimizer_cost_based_transformation='off'
    *._smu_debug_mode=4
    *.compatible='10.2.0.1.0'
    *.cursor_sharing='SIMILAR'
    *.db_block_size=8192
    *.db_domain=''
    *.db_file_multiblock_read_count=16
    *.job_queue_processes=10
    *.open_cursors=5000
    *.optimizer_mode='ALL_ROWS'
    *.pga_aggregate_target=1277165568
    *.processes=250
    *.remote_login_passwordfile='EXCLUSIVE'
    *.sessions=1000
    *.sga_target=3833593856
    *.undo_management='AUTO'
    *.undo_tablespace='UBPTAB_UNDO'
    Execution Plan
    Plan hash value: 2107556093
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 45157 | 29M| | 9094 (1)| 00:01
    :50 |
    | 1 | SORT ORDER BY | | 45157 | 29M| 78M| 9094 (1)| 00:01
    :50 |
    |* 2 | TABLE ACCESS FULL| <tname>| 45157 | 29M| | 2564 (2)| 00:00
    :31 |
    Following are result from dba_tab_statistics.
    NUM_ROWS BLOCKS EMPTY_BLOCKS AVG_CACHE_HIT_RATIO AVG_ROW_LEN
    112704 11520 768 685
    AVG_SPACE_FREELIST_BLOCKS NUM_FREELIST_BLOCKS
    0 0
    Follwing was the time it has taken to generate the explain plan report after issuing the below command.
    set autotrace traceonly
    Elapsed: 00:00:15.49
    Following is the statistics
    Statistics
    0 recursive calls
    0 db block gets
    11380 consistent gets
    0 physical reads
    0 redo size
    8823636 bytes sent via SQL*Net to client
    37731 bytes received via SQL*Net from client
    3019 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    45267 rows processed
    Pl let us know how to tune the same.
    Thank you all for the help

  • Why HTML report takes more time than the PDF one?

    Hi,
    I have created report in Reports 6i. When I run the report on the web with FORMAT = PDF it runs very fast and shows all the pages in 2 minutes. But when I run with
    FORMAT = HTML it shows the first page in 2 minutes, after that it takes lot of time to show the remaining pages. If the total pages are more than 40, the browser just freezes
    Can somebody give me the reason?
    Is there any way to rectify this?
    Thanks alot.
    Ram.

    Hi Senthil,
    Iam running with the below parameters.
    Format : HTML
    Destination : Screen.
    My default browser is IE. When I try to run using Netscape it showed only 1 page out of 34 pages.
    When I run Format as PDF it is faster but font size is small when it opens up. Offcourse user can zoom it.
    If I increase the report width from 11 to 14 the font size becomes very small when it open up in browser.
    Is there any way that I can set up zoom when I run as PDF?
    Thanks for your help.
    Ram.

  • How can I call the SubVI like a child window one or more times in the front panel of my main VI ? See the example atached...

    I would like to create a aplication where I call dynamically the same SubVi many times in the front panel of my main VI ... I saw this kind of programmation in other languages like Delphi, C++ Builder and Visual Basic.
    For explanation: I have 10 channels to read in the list, but I would like to see only 3 channels ... Then I will click in the channels choosed of my list and will open the same SubVI 3 times, where each one will show the individual channel.
    Thanks for attention...
    Cleber
    Attachments:
    Opening SubVi many times.jpg ‏118 KB

    TiTou certainly pointed you down the right path... For a few more details, refer to my post to this thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=141811
    You could use the same technique, except instead of opening the clone's front panel, use the VI reference you have to it to poke it into a subpanel. Please note: I have never actually tried building a VI with more than one subpanel on its front panel, but it should work. Also you will not want to close the VI references because you will need them to stop the clones when you shutdown your application.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Select Statement takes more time after immediate insert statement..

    Hello,
    I found below scenario
    1. I have table TABLE1 which has index on COL1 field. It has around 40 columns and 100000 rows.
    2. whenever i insert 100000 rows in bulk with changing indexed key column and executing SELECT statement in same session then it takes around 3 mins to complete.
    3. However, if i open new session and execute same select statement then it returns in 2-3 seconds.
    I didnt get anything in XPLAN.. :(
    I felt Buffer Clean is cause to take time. please let me know your opinion.
    Thanks in Advance
    Sach

    sach09 wrote:
    Hello,
    I found below scenario
    1. I have table TABLE1 which has index on COL1 field. It has around 40 columns and 100000 rows.
    2. whenever i insert 100000 rows in bulk with changing indexed key column and executing SELECT statement in same session then it takes around 3 mins to complete.
    3. However, if i open new session and execute same select statement then it returns in 2-3 seconds.
    I didnt get anything in XPLAN.. :(
    I felt Buffer Clean is cause to take time. please let me know your opinion.Are you running the query in the other session after running it from the first?
    Aman....

  • Return value from database function taking a lot more time than the query

    Hi guys,
    I have a Query that does a call to a database function. The function takes in a few parameters and returns a Date. Now, the query within the function takes barely .05 seconds. However, doing a select get_join_dates from dual is taking almost 6 seconds for each call.
    Here is the Query:
    select s.student_id, s.student_name, s.organization_code
    from   student s
    where  s.student_id = :p_student_id
    and    s.student_enrollment_date = get_join_dates( :p_year,
                                                       :p_month,
                                                       :p_student_id,
                                                       s.organization_code );And here is the database function. The select inside this function barely takes 0.05 seconds per call. This function gets called 3 times in my case as there are 3 records in the org_body table for this student.
    create or replace function
    get_join_dates( p_yyyy in org_body.fiscal_yyyy%type,
                           p_month in  org_body.fiscal_mm%type,
                           p_student_id in student.student_id%type,
                           p_organization_code in org_body.organization_code%type) return date as
        t_enrollment_date  date;
        cursor cur_latest_enrollment_date is
          select max(enrollment_date)
          from   org_body
          where  fiscal_yyyy = p_yyyy
          and    fiscal_mm = p_month
          and    student_id = p_student_id
          and    organization_code = p_organization_code;
      BEGIN
        open cur_latest_enrollment_date ;
        fetch cur_latest_enrollment_date into t_enrollment_date;
        close cur_latest_enrollment_date ;
        return t_enrollment_date;
      exception
        when others then
          null;
    end;owever, when I run the following statement below, it takes close to 6 seconds to retrieve a record. In turn, my Query is becoming really slow and taking almost 35 seconds. Imagine that with more records.
    select get_join_dates( 2010, '01', '2167543', 'PSYCH01' ) from dual;If I run my query with this condition below, it takes 0.5 seconds.
    select s.student_id, s.student_name, s.organization_code
    from   student s
    where  s.student_id = :p_student_id
    and      s.student_enrollment_date = '01-JAN-10'Any ideas would be greatly appreciated.

    Any reason why you are doing this with the stored function?
    You could just do this with SQL. Embed the query in the function as a subquery in your initial query from STUDENT.
    select s.student_id, s.student_name, s.organization_code
    from   student s
    where  s.student_id = :p_student_id
    and    s.student_enrollment_date =
    (select max(enrollment_date)
          from   org_body
          where  fiscal_yyyy = :p_year
          and    fiscal_mm = :p_month
          and    student_id = s.student_id
          and    organization_code = s.organization_code);Why your function is not performing: I cannot say that with the information you have provided.
    Maybe sqltrace a call and see what the reason is.

  • I have a 5.4 tb external hard (1.87 tb used) drive, which seems to take a very long time when the Time Machine is in the cleaning up phase, why?

    I am wondering why the Time Machine gets stuck during the Cleaning Up phase of Backing Up???

    Hallo  Kieth ,
    I am not quite ready to restore the full iphoto library , as I have days of work re - imputting titles,descriptions and enhancement . I hope that your suggestion works , as I use my Macbook basically to work with digital photography. Through time , I will need to delete my library to recover more disc space and I would hate to have to spend more time re - imputting titles and descriptions all over again .
    Thanks for your interest and advice.
    regards  - Alan

  • Time issue of select statement

    Hi friends,
       I have a doubt about select single statement in this particular statement below.
    i have the code which goes this way.
    loop at itab.
    concatenate *year *materail no * item type into dummy variable.
    select single dmbtr from bsis into itab-dmbtr where xref3 = dummy variable and belnr = itab-migodoc and gjahr = itab-mjahr and hkont = '0000123'.
    clear dummy variable.
    modify itab.
    endloop.
    the bsis table has around 4,000,000 records.
    The report when executed goes smoothly till the point where the above select statement is encountered.
    my question is does it take time to execute because of so many records ?
    If not then why dies it take a lot of time to execute a single select statement ? 
    and how can i optimise the time consumed by this select query or report. ?
    Thank you.
    Moderator message: please understand the basic concept of using primary or secondary indexes in your queries, you will sure find the missing field in your where-clause, read the sticky threads of this forum.
    Edited by: Thomas Zloch on Nov 20, 2010 5:31 PM

    Hi Vivek,
    Data volume definitely gives impact on SQL.
    Don't use sql inside the loop, it will decrease the performance.
    Year material no. and item type may have duplicate entries. filter that. It may also gives impact on performance.
    Write a single Select query.
    Instead of fetching the data at once use packet size.
    http://wiki.sdn.sap.com/wiki/display/ABAP/ABAP4TuningChecklist
    Regards,
    Sudha
    Edited by: Sudha Rani Pathuri on Nov 20, 2010 6:42 PM
    Edited by: Sudha Rani Pathuri on Nov 20, 2010 6:48 PM
    Edited by: Sudha Rani Pathuri on Nov 20, 2010 6:51 PM

  • CTAS is over x10 faster than it's select statement, why?

    Hi gurus -
    Oracle 11gR2
    Exadata
    CREATE TABLE AS SELECT .......................... FROM................. runs over 10 times faster than just the SELECT stmt from the CTAS.
    Why and how CTAS is faster than it's SELECT stmt?
    Thanks,
    Prakash

    No it's not guessing game. Here is my query with elapsed time,
    SELECT CURRENT_CONTRACT,
    JOB_TITLE,
    EXPENDITURE_ITEM_DATE_WEEK_END,
    HIRING_MANAGER,
    RATE_TYPE,
    OT_PAY_RATE,
    DT_PAY_RATE,
    SUM (CONT_OT_SPEND_AMOUNT_ADJ) AS CONT_OT_SPEND_AMOUNT_ADJ,
    SUM (CONT_DT_SPEND_AMOUNT_ADJ) AS CONT_DT_SPEND_AMOUNT_ADJ,
    SUM (CONT_DT_HOURS_SPEND) AS CONT_DT_HOURS_SPEND,
    SUM (CONT_OT_HOURS_SPEND) AS CONT_OT_HOURS_SPEND
    FROM CONTRACTOR_TIME V -- Contractor view
    WHERE ORG IN (23245,33456)
    GROUP BY
    CURRENT_CONTRACT,
    JOB_TITLE,
    EXPENDITURE_ITEM_DATE_WEEK_END,
    HIRING_MANAGER,
    RATE_TYPE,
    OT_PAY_RATE,
    DT_PAY_RATE;
    --Elapsed : 30 minutes
    CREATE TABLE rslt AS
    SELECT CURRENT_CONTRACT,
    JOB_TITLE,
    EXPENDITURE_ITEM_DATE_WEEK_END,
    HIRING_MANAGER,
    RATE_TYPE,
    OT_PAY_RATE,
    DT_PAY_RATE,
    SUM (CONT_OT_SPEND_AMOUNT_ADJ) AS CONT_OT_SPEND_AMOUNT_ADJ,
    SUM (CONT_DT_SPEND_AMOUNT_ADJ) AS CONT_DT_SPEND_AMOUNT_ADJ,
    SUM (CONT_DT_HOURS_SPEND) AS CONT_DT_HOURS_SPEND,
    SUM (CONT_OT_HOURS_SPEND) AS CONT_OT_HOURS_SPEND
    FROM CONTRACTOR_TIME V -- Contractor view
    WHERE ORG IN (23245,33456)
    GROUP BY
    CURRENT_CONTRACT,
    JOB_TITLE,
    EXPENDITURE_ITEM_DATE_WEEK_END,
    HIRING_MANAGER,
    RATE_TYPE,
    OT_PAY_RATE,
    DT_PAY_RATE;
    --Elapsed: 3 mins                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for