Build Table Within CPU Cycle Limits ::

I have a table that looks like this:
:Example Table:
customer_trail
database_update_date cust_activity cust_name
02/11/08 09:00 01/11/08 09:34 Bob
02/11/08 09:00 23/10/08 09:34 James
02/12/08 09:00 05/11/08 09:34 John
02/12/08 09:00 12/12/08 09:34 Mike
: Definitions:
The database_update_date is the primary key and is the date when everything gets loaded into the database.
The cust_activitity is when the customer came in and requested some work done.
The cust_name is the customers name.
:SQL:
SELECT TO_CHAR(cust.cust_activity ,'DD/MM/YY') AS Date_Raised,
TO_CHAR(cust.cust_activity,'HH24')||':00' AS 24HR_TIME,
cust.*
FROM customer_trail cust
WHERE database_update_date BETWEEN '01-nov-2008' AND '02-nov-2008'
AND cust_activity BETWEEN '01-nov-2008' AND '01-dec-2008'
AND cust_name IN ( 'Bob', 'Mike', 'Pete')
:PROBLEM:
My problem is this, due to the fact that the table is so large and we have so many customers. My query times out if I search for a months worth of data using the database_update_date attribute, so I am having to search 1 day at a time to build up a months worth of data in my new table called output. However this is a manual process of me changing the values within database_update_date and saving it to the output table.
Also there is no way to optimise my query and the table can not be changed easily.
So what I need to do is get it to update the database_update_date daily from the 01-nov-2008 to the 01-dec-2008 and store everything that matches the other two conditions without exceeding my CPU Cycle limit.
Any ideas?

Rob van Wijk wrote:
Davey,
The design of the table has to be such that it supports its use the best way. If the query you showed is the query that it needs to be optimized for, you'll want to look into partitioning and indexing this table. Range partitioning on cust_activity and a local index on (cust_name,database_update_date) maybe?
But there is really too little information here. Is this the main query and a typical one? How many rows are you typically retrieving here? How large is large? Can you show an explain plan and a tkprof file snippet?
Regards,
Rob.Plan
CREATE TABLE STATEMENT ALL_ROWSCost: 374 Bytes: 151 Cardinality: 1                               
     6 LOAD AS SELECT NOV                          
          5 PX COORDINATOR                     
               4 PX SEND QC (RANDOM) SYS.:TQ10000 Cost: 373 Bytes: 151 Cardinality: 1                
                    3 PX PARTITION RANGE ITERATOR Cost: 373 Bytes: 151 Cardinality: 1 Partition #: 4 Partitions accessed #83 - #88          
                         2 TABLE ACCESS BY LOCAL INDEX ROWID TABLE customer_trail Cost: 373 Bytes: 151 Cardinality: 1 Partition #: 4 Partitions accessed #83 - #88     
                              1 INDEX SKIP SCAN INDEX .I_customer_trail_1 Cost: 187 Cardinality: 262 Partition #: 4 Partitions accessed #83 - #88
Here is the plan, I hope that helps as this actually makes nosense to me at all.

Similar Messages

  • Temporary table within a package

    I'm not sure this is the best way to achieve it, but I'm trying to use a temporary table within my package, but I failed!
    In my package, my procedure do receive 5 different phone numbers (vTel1 to vTel5) and I need to order them, using data from a table. Also, if 2 of them are the same, I need only the one with the highest rank.
    Let say my TelOrder table look likes:
    Reason
    Tel1
    Tel2
    Tel3
    Tel4
    Tel5
    Reason1
    2
    3
    1
    5
    4
    Reason2
    1
    2
    null
    3
    4
    And I receive those variable
    vTel1='5141111111'
    vTel2=null
    vTel3='5143333333'
    vTel4='5141111111'
    vTel5='5145555555'
    vReason='Reason1'
    Using the Reason1, I need to be able to get the result looking like:
    RowNum
    Phone
    Order
    1
    5143333333
    1
    2
    5141111111
    2
    3
    5145555555
    4
    And I need this code to be apart from the procedure, cause many procedures will use the same code, and I don't want to abuse the ctrl+c, ctrl+v at each update.
    I've come close by using something like:
    EXECUTE IMMEDIATE '
         INSERT INTO Table
         SELECT Rownum as RN, Ordre, contact_info, Contact_info_type
         FROM
           (SELECT a.contact_info, a.ordre, contact_info_type FROM
             (SELECT contact_info,min(ordre) as Ordre FROM
               (SELECT Tel1 as Ordre, ''' || vTel1 || ''' as contact_info, 1 as contact_info_type FROM TelOrder WHERE Reason=''' || vReason || '''
               UNION ALL
               SELECT Tel2 as Ordre, ''' || vTel2 || ''' as contact_info, 2 as contact_info_type FROM TelOrder WHERE Reason=''' || vReason || '''
               UNION ALL
               SELECT Tel3 as Ordre, ''' || vTel3 || ''' as contact_info, 4 as contact_info_type FROM TelOrder WHERE Reason=''' || vReason || '''
               UNION ALL
               SELECT Tel4 as Ordre, ''' || vTel4 || ''' as contact_info, 4 as contact_info_type FROM TelOrder WHERE Reason=''' || vReason || '''
               UNION ALL
               SELECT Tel5 as Ordre, ''' || vTel5 || ''' as contact_info, 1 as contact_info_type FROM TelOrder WHERE Reason=''' || vReason || '''
             WHERE Ordre is not null and contact_info is not null
             GROUP BY contact_info
             ) a
           JOIN
             (SELECT Tel1 as Ordre, ''' || vTel1 || ''' as contact_info, 1 as contact_info_type FROM TelOrder WHERE Reason=''' || vReason || '''
             UNION ALL
             SELECT Tel2 as Ordre, ''' || vTel2 || ''' as contact_info, 2 as contact_info_type FROM TelOrder WHERE Reason=''' || vReason || '''
             UNION ALL
             SELECT Tel3 as Ordre, ''' || vTel3 || ''' as contact_info, 4 as contact_info_type FROM TelOrder WHERE Reason=''' || vReason || '''
             UNION ALL
             SELECT Tel4 as Ordre, ''' || vTel4 || ''' as contact_info, 4 as contact_info_type FROM TelOrder WHERE Reason=''' || vReason || '''
             UNION ALL
             SELECT Tel5 as Ordre, ''' || vTel5 || ''' as contact_info, 1 as contact_info_type FROM TelOrder WHERE Reason=''' || vReason || '''
             ) b ON a.contact_info=b.contact_info AND a.ordre=b.ordre
           ORDER BY a.Ordre
    But when I try to remove this code and send it into another procedure/function, I can't make it work.
    PLEASE HELP!!!!  

    No Database to try it. Check at your own risk if this might work for you
    no version specified from your side, NOT TESTED from my side, so let's say we're even
    select row_number() over (order by the_order) "RowNum",
           the_val "Phone",
           the_order "Order"
      from (select v.the_val,t.the_order,
                   row_number() over (partition by v.the_val order by t.the_order) rn
              from (select reason,the_order,the_phone
                      from (select reason,tel1,tel2,tel3,tel4,tel5
                              from telorder
                             where reason = :the_reason
                    unpivot include nulls (the_order for the_phone in (tel1 as 'tel1',
                                                                       tel2 as 'tel2',
                                                                       tel3 as 'tel3',
                                                                       tel4 as 'tel4',
                                                                       tel5 as 'tel5'
                   ) t,
                   (select 'tel1' the_var,:v_tel1 the_val from dual union all
                    select 'tel2' the_var,:v_tel2 the_val from dual union all
                    select 'tel3' the_var,:v_tel3 the_val from dual union all
                    select 'tel4' the_var,:v_tel4 the_val from dual union all
                    select 'tel5' the_var,:v_tel5 the_val from dual
                   ) v
             where t.reason = :v_reason
               and t.the_phone = v.the_var
    where rn = 1
       and the_val is not null
    Regards
    Etbin

  • Error in Creating Advance table within Advanvce Table via view link

    Hii all,
    i hve created a Advance table within Advanvce Table as given in the developer guide using the Detail functionality of the advance table
    im facing the following error................
    ## Detail 0 ##
    java.lang.NullPointerException
         at oracle.apps.fnd.framework.webui.OAAdvancedTableHelper.updateInnerTableProperties(OAAdvancedTableHelper.java:1752)
    i hve done all the steps as suggested by gurus to implement this Master Detail functionality. Pl help me out if any one had implemented it
    thanks in advanve
    Pranav

    Hi Reetesh,
    thanks for the reply...
    I hve already created a transient attribute in Master VO attached to the outter advance table and had set this attribute in detail attribute property of outter
    advance table. But im facing the same error.
    I u hve implemented this pl let me know the correct steps
    thanks
    Pranav

  • Adding JUST ONE CELL to a table within Pages

    Hello,
    I would like to add +just one cell+ to a table within "Pages" - but as far as I can see the program only offers to add whole lines or columns. (Within "MS Word", you have the possibility to "add cells" in a table - you can decide whether you want to shift the other cells downward or to the right.)
    Do I miss something?
    Thanks for your help.
    nb.

    Maybe I should have said: Is there a function within Pages that is equivalent to the (very useful) one within Word. There isn't, I'm afraid.
    Can I adjust only the size of one cell (with the mouse, by clicking on the vertical/horizontal line) without changing the size of the whole column/line? I guess that it should be working - I didn't manage to do it - might be kind of tricky.
    As I said: Thank you!
    All the best,
    nb.

  • How do I create a table within another table?

    How do I create a table within another table?
    As shown in image below (document created with Words), I already have a table with 3 columns. How do I create another table with 6 columns to tabulate the data (the one below "3.1 Overall")?

    Last time I checked in Pages 5.5.2 that is not possible.
    Peter

  • Problem in using translation builder table??? pls help

    Dear OTN Users,
    I have to convert an existing application developed using forms 6i to Chinese for use in China. Kindly advice how to achieve this.
    We have tried to use the Translation Builder but it gives an error message " xbd-00024 Translation builder table does not exist" and another error " xbd - 00301 Project Insertion Failed".
    Pls reply back on Urgent basis.
    Thanks
    null

    Hi,
    You can add attributes in the View to store the selected values .
    For eg  Add gv_index type i.
    Now in the On select first table add a parameter NEW_LEAD_SELECTION type IF_WD_CONTEXT_ELEMENT in the action.
    Now
    use the get index method.
      CALL METHOD new_lead_selection->get_index
        RECEIVING
          my_index = lv_index.
    wd_this->gv_index = lv_index.
    Now when u press the Delete Button the wd_this->gv_index gives the current index which u have selected before
    And in the properties of the table SelectionMode use singleNoLead proerty so that the user has to select some value to delet the records.

  • How to build table join query in Jdeveloper

    Hi,
    Can someone tell me how to build table join query in Jdeveloper's Expression Builder UI?

    [Is it possible to create a table of contents in Crystal Reports?|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313335333133303330%7D.do]

  • How to give a hint on a table within a view

    How do I give a FULL hint to a table within a view?
    The table that I want to give a hint on resides in a different schema that I am working in. So, when I give the following hint, Oracle just sits on it and does nothing (I am afraid I can't do the same, so please help).
    /*+ FULL (VW.SCHEMA_NAME.TABLE) */

    Hi,
    In the hints documentation you have to pre cursor the table with the name of the view such as for example.
    /*+ full(view_name.table_name) */
    this is called a global table hint. Here is the link for your reading, it has an excellent example
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14211/hintsref.htm#i27644
    and this one lists all the hints available to use.
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14211/hintsref.htm
    enjoy.
    al

  • How to build Table of Content in Crystal Reports

    Hi,
    Initially, I am looking for an article about how to build Table of Content in Crystal Reports in table-based approach----including how to write to DB table from report:
    http://support.businessobjects.com/library/kbase/articles/c2011950.asp
    However, the link above is invalid. I also searched through SDN articles, but no luck.
    Can someone please forward me the link if you happend to know?---does not have to link to this specific article, any working solution is just fine.
    I am aware of another approach which put the TOC to the end of the report(http://www.ml-consult.co.uk/cryst-05.htm), which probably does not satisfy the requirement.
    If you have other solutions, your share is greatly appreciated.
    Thanks a ton!

    [Is it possible to create a table of contents in Crystal Reports?|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313335333133303330%7D.do]

  • How to know which DML operation is taking place on a table within a procedu

    Hii all,
    My DB Version
    SQL> select *
      2  from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - ProductionHow to find what DML Operation is taking place on a particular table within a procedure??
    For suppose I've the below procedure
    create table r_dummy
    name varchar2(4000),
    emp_id number
    Create or replace procedure r_dummy_proc
    p_name          in     varchar2,
    p_emp_id     in     number
    is
    Begin
              Update r_dummy
              set name = p_name
              where emp_id = p_emp_id;
              if sql%rowcount > 1 then
                   dbms_output.put_line('Successfully updated employee name');
              end if;
    End;Here from the code I can identify that an update operation is taking place on table 'R_DUMMY'
    But how to find that without actually viewing the code?? I've hundreds of procedures in my DB and would like to find what DML is taking place on which table and in which procedure.
    Please help with some suggestions.

    And here is the solution
    with t as
      select distinct name,type,text,line
      from user_source s
      where regexp_like(s.text,'cp_ca_dtls','i')
    x as
      select name,line,text
      from
      select name,case when (regexp_instr(text,'(update)|(insert)|(delete)',1,1,1,'i') >0) and regexp_instr(ld,'CP_CA_DTLS',1,1,1,'i') >0
             then line
             else null
             end as line,text
      from
      Select   name,text,line,lead(text) over(partition by name order by line) ld
      from user_source
      where name in
          select distinct name
          from user_source
          where upper(text) like '%CP_CA_DTLS%'
      order by 1 nulls last
      )where line is not null
    select name,line,text
    from t t1
    where regexp_instr(text,'(update)|(insert)|(delete)',1,1,1,'i') >0
    and exists
         select 1
         from t t2
         where t1.name = t2.name
            and t1.type = t2.type
            and t1.line = t2.line
    union
    select name,line,text
    from x

  • Can you hide a column in a table within a Pages document?

    Is it possible to have a table within a Pages document that allows you to hide columns..... I am trying to make a template for client quotations that requires a column containing discounts which needs to be hidden before I print. Haven't figured out how to make this happen.... can it be done?.... works in Numbers[as per XL] but not in Pages
    many thanks
    Gary

    One of my biggest grievances with Forms Central is the lack of any kind of calculating (living in hope Adobe!)... you will have to do it in Excel.

  • If I have an EntityBean that mappes to two tables within one database, when I create that EJB, whoes reponsibilty to generate the primary key in database table? The RDBMS or EJB?

    If I have an EntityBean that mappes to two tables within one database, when I create
    that EJB, whoes reponsibilty to generate the primary key in database table? The
    RDBMS or EJB?
    Thanks,
    JW

    Refer to http://e-docs.bea.com/wls/docs81/faq/ejb.html/#257430
    "Jingwei Zhang" <[email protected]> wrote:
    >
    If I have an EntityBean that mappes to two tables within one database,
    when I create
    that EJB, whoes reponsibilty to generate the primary key in database
    table? The
    RDBMS or EJB?
    Thanks,
    JW

  • Make a script for build table

    Hi everyone
    How to make a script for build table:
    col width 25mm
    align decimal
    align on close paren
    Thanks
    Teetan

    Hi Teetan VK,
    Merry Chrismas.
    I'm not really an InDesign scripter.
    But you can try the following code:
    // TableCreate_simple.jsx
    // regards pixxxelschubser
    var aDoc = app.activeDocument;
    // your width of every column
    var w = Number(prompt("width of columns", 25));
    var NrOfColumns = 3;
    var aTextFrame = aDoc.textFrames.add({visibleBounds:[0, 0, 30, NrOfColumns*w + 1]});
    var aTable = aTextFrame.insertionPoints[0].tables.add({columnCount:NrOfColumns,bodyRowCount:1});
    for (i=0; i<aTable.columns.length; i++) {
    aTable.columns[i].width = w;
    // Paragraph sytyle with decimal aligning should already exists in your document
    for (j = 0; j < aTable.cells.length; j++) {
        aTable.cells[j].texts[0].appliedParagraphStyle = aDoc.paragraphStyles.item("AlignDecimal");
    Be sure, that a paragraph style (named with "AlignDecimal") exists in your Document.
    But what is:
    Teetan VK schrieb:
    … align on close paren …

  • Creating temp table within OPEN QUERY

    I am having trouble in creating a temp table within my OPEN QUERY.
    How do I modify the below script to do this?
    declare @sql nvarchar(max)
    set @sql =
    'SELECT *
    FROM audit.dbo.Comp AS a
    INNER JOIN audit.dbo.Pat AS b ON b.key = a.key
    AND b.reg = ''' + @id + '''
    INNER JOIN [prod].nfegh.dbo.flTest AS c ON c.id COLLATE Latin1_General_CI_AS = b.reg
    INNER JOIN (
    SELECT ''M1Q'' UNION ALL
    SELECT ''M0Q'' UNION ALL
    SELECT ''S1N''
    ) AS f(x) ON f.x = CLIN
    WHERE a.inv IN (''CR'', ''R'', ''EAT'')'
    set @sql = N'select * into MS_test1
    from openquery( ocles, ''' + replace (@sql , '''' , '''''') + ''' )'
    exec (@sql)

    OPENQUERY is designed to provide rows or to be user as target for DML.
    But even when this statement would create a temporary table, then it would be out of scope.

  • Where is the build table express vi located in the function table?

    I must be blind but I can't locate the build table express vi in lv8 or 8.5.  Someone slap be upside the head and point it out.  Thanks

    It's on the Controls palette. Were you looking on the Functions palette?
    Message Edited by Dennis Knutson on 04-23-2008 08:22 PM
    Attachments:
    Express XY Graph.PNG ‏17 KB

Maybe you are looking for