UCCX 5 SQL Dbase Query Issues - Slow Returns

For several months it seemed to me that our UCCX 5 system was beginning to have trouble. At first it appeared as a problem with our wallboard system being unable to display the real-time data properly. I had deduced that queries to the db_cra database were taking 4 - 5 minutes to return data.
At first I called on the vendor for our wallboard, but they were unable to help stating that it was a UCCX database issue - and I agreed. I then went to Cisco TAC and fed them all my information and asked them for help. They also were unable to help figure out what was happening, but they could see that the SQL queries that used to take 2 seconds were now taking several minutes. Since the wallboard system queried the database every 10 seconds, it was over-taxing the database.
This began to cause little anomalies in things like call-distribution, dropped calls, slow to no Historical reports returns, and this ultimately began to cause failovers to our backup node. I could not go a day without a failover and I had to reboot the servers almost every night.
I felt there was no solution and was afraid we needed to replace our system.
After talking to all the engineers around the world, my solution came from our very own SQL administrator. Within 5 minutes he was able to resolve all our issues.
The root of our problem was that the indexing of the db_cra database was extremely fragmented.
He wrote a SQL sript that he had me run against the database and he told me that this would correct any indexing issues.
It worked like a charm.
The system stopped behaving poorly immediately. This resolved many of our problems that I had been living with for a long time. It made the Admin page work so much faster, call distribution issues halted, the wallboard is running faster than ever with real-time data, and the list goes on. This resolved so many smaller issues that I cannot even list them all.
I would advise anyone using a SQL database, whether it be a Cisco product or not, to always keep their database 'defragmented'.
My SQL admin also setup the script to run automatically, on a schedule to keep our database running like a Ferrari. It has been sweet ever since.
KEEP YOUR INDEXES CLEAN AND YOU WILL REAP HAPPINESS!

I was equally shocked that there was no escalation, as was my boss and my Cisco rep. They let me go with no resolution and hung-up the phone leaving me with instructions to have some-one else take a look at the database. It was very unexpected, especially considering how close they were to the point when we were trouble-shooting.
The TAC SR # 611904619 - IPCC Database Not Returning Query Data.
With this resolution, it also raised to my mind the issue of Informix. We are using CUCM 6.1.2 and are concerned about the same issue happening there and we would like to determine if this can happen there also, and if there is a re-indexing tool available for Informix.

Similar Messages

  • PL/SQL region query issue

    Dears;
    I'm in trouble for a moment with my PL/sql block in a region.
    Could you take a look on the following block and tell me what i do wrong?
    DECLARE
    v_counter INTEGER := 0;
    v_line VARCHAR2 (4000);
    v_rec_in_row INTEGER := 12;
    lpar varchar2(50;
    BEGIN
    HTP.prn ('&lt table &gt ');
    HTP.prn ('&lt tr &gt ');
    HTP.prn ('&lt td &gt ');
    lpar:=v('P48_LVAR')
    CASE lpar
    WHEN 'SERVERS'
    THEN
                   FOR c IN
                        ( SELECT CASE
    WHEN SERVER_MARK='SUN'
    THEN '&lt table &gt '
    || '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
    || '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
    || SERVER_NAME
    || '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
    WHEN SERVER_MARK='HP'
    THEN '&lt table &gt '
    || '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#hp.GIF"/ &gt &lt /td &gt &lt /tr &gt '
    || '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
    || SERVER_NAME
    || '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
                                       END emp
                             FROM SERVERS)
                             LOOP
                             v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
                             v_counter := v_counter + 1;
                             IF v_counter = v_rec_in_row
                             THEN
                                  HTP.prn (v_line);
                                  HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
                                  v_line := NULL;
                                  v_counter := 0;
                             END IF;
                        END LOOP;
                        HTP.prn (v_line);
                        HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
    WHEN 'ZONES'
              THEN
                   FOR c IN
                        ( SELECT '&lt table &gt '
    || '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
    || '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
    || ZONE_NAME
    || '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
    END emp
                        FROM ZONES)
                        LOOP
                             v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
                             v_counter := v_counter + 1;
                             IF v_counter = v_rec_in_row
                             THEN
                                  HTP.prn (v_line);
                                  HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
                                  v_line := NULL;
                                  v_counter := 0;
                             END IF;
                        END LOOP;
                        HTP.prn (v_line);
                        HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
    WHEN 'ALIAS'
              THEN
                   FOR c IN
                        ( SELECT           
              '&lt table &gt '
    || '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
    || '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
    || ALIAS_NAME
    || '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
                                  END emp
                                  FROM ALIAS)
                                  LOOP
                                  v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
                                  v_counter := v_counter + 1;
                                  IF v_counter = v_rec_in_row
                                  THEN
                                       HTP.prn (v_line);
                                       HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
                                       v_line := NULL;
                                       v_counter := 0;
                                  END IF;
                             END LOOP;
                             HTP.prn (v_line);
                             HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
              WHEN 'FS'
              THEN
                   FOR c IN
                        ( SELECT
                        '&lt table &gt '
    || '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
    || '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
    || FS_NAME
    || '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
    END emp
    FROM FS
    LOOP
    v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
    v_counter := v_counter + 1;
    IF v_counter = v_rec_in_row
    THEN
    HTP.prn (v_line);
    HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
    v_line := NULL;
    v_counter := 0;
    END IF;
    END LOOP;
    HTP.prn (v_line);
    HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
    END CASE;
    END;
    I get this error :
    1 error has occurred
    ORA-06550: line 56, column 21: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 51, column 7: PL/SQL: SQL Statement ignored ORA-06550: line 83, column 13: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 77, column 7: PL/SQL: SQL Statement ignored ORA-06550: line 110, column 12: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 104, column 7: PL/SQL: SQL Statement ignored
    I know it's a long post but i hope u will take the time to look.
    Thx.
    Celio

    Okay, when using CASE you have to flavours.
    One for PL/SQL statements and one in a query.
    In PL/SQL the structure is like this:
    case n
      when 1 then Action1;
      when 2 then Action2;
      when 3 then Action3;
      else        ActionOther;
    end case;In a query it's like this:
    SELECT CASE WHEN (<column_value>= <value>) THEN
                WHEN (<column_value> = <value>) THEN
                ELSE <value>
                END AS <alias>
    FROM <table_name>;So rewriting your code, this should work:
    DECLARE
       v_counter     INTEGER         := 0;
       v_line        VARCHAR2 (4000);
       v_rec_in_row  INTEGER         := 12;
       lpar varchar2(50);
    BEGIN
       HTP.prn ('<table>');
       HTP.prn ('<tr>');
       HTP.prn ('<td>');
       lpar:=v('P48_LVAR');
       CASE
        WHEN lpar='SERVERS'
                    THEN 
                      FOR c IN
                          ( SELECT   CASE
                    WHEN SERVER_MARK='SUN'
                    THEN     '<table>'
                             || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                             || '<tr><td style="text-align:center"><h1>'
                             || SERVER_NAME
                             || '</td></tr></a></table>'
                    WHEN SERVER_MARK='HP'
                    THEN     '<table>'
                             || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#hp.GIF"/></td></tr>'
                             || '<tr><td style="text-align:center"><h1>'
                             || SERVER_NAME
                             || '</td></tr></a></table>'
                                       END AS emp
                              FROM SERVERS)
                              LOOP
                               v_line := v_line || c.emp || '</td><td>';
                               v_counter := v_counter + 1;
                               IF v_counter = v_rec_in_row
                               THEN
                                   HTP.prn (v_line);
                                   HTP.prn ('</td></tr><tr><td>');
                                   v_line := NULL;
                                   v_counter := 0;
                               END IF;
                           END LOOP;
                           HTP.prn (v_line);
                           HTP.prn ('</td></tr></table>');
       WHEN lpar='ZONES'
                THEN 
                      FOR c IN
                          ( SELECT '<table>'
                             || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                             || '<tr><td style="text-align:center"><h1>'
                             || ZONE_NAME
                             || '</td></tr></a></table>'
                     emp
                        FROM ZONES)
                        LOOP
                               v_line := v_line || c.emp || '</td><td>';
                               v_counter := v_counter + 1;
                               IF v_counter = v_rec_in_row
                               THEN
                                   HTP.prn (v_line);
                                   HTP.prn ('</td></tr><tr><td>');
                                   v_line := NULL;
                                   v_counter := 0;
                               END IF;
                           END LOOP;
                           HTP.prn (v_line);
                           HTP.prn ('</td></tr></table>');
       WHEN lpar='ALIAS'
                THEN 
                      FOR c IN
                          ( SELECT           
                               '<table>'
                             || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                             || '<tr><td style="text-align:center"><h1>'
                             || ALIAS_NAME
                             || '</td></tr></a></table>'
                                      emp
                                  FROM ALIAS)
                                  LOOP
                                    v_line := v_line || c.emp || '</td><td>';
                                    v_counter := v_counter + 1;
                                    IF v_counter = v_rec_in_row
                                    THEN
                                        HTP.prn (v_line);
                                        HTP.prn ('</td></tr><tr><td>');
                                        v_line := NULL;
                                        v_counter := 0;
                                    END IF;
                                END LOOP;
                                HTP.prn (v_line);
                                HTP.prn ('</td></tr></table>');
               WHEN lpar='FS'
                THEN 
                      FOR c IN
                          ( SELECT
                                  '<table>'
                             || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                             || '<tr><td style="text-align:center"><h1>'
                             || FS_NAME
                             || '</td></tr></a></table>'           
             emp
          FROM FS
       LOOP
          v_line := v_line || c.emp || '</td><td>';
          v_counter := v_counter + 1;
          IF v_counter = v_rec_in_row
          THEN
             HTP.prn (v_line);
             HTP.prn ('</td></tr><tr><td>');
             v_line := NULL;
             v_counter := 0;
          END IF;
       END LOOP;
       HTP.prn (v_line);
       HTP.prn ('</td></tr></table>');
    END CASE;
    END;Unless I'm missing something aswell ;-)
    Edited by: Michel van Zoest on Oct 6, 2009 10:46 PM

  • SQL Group Query issue

    Dear All,
    I have a result set like this
    A
    UK
    A
    USA
    A
    Canada
    B
    Canada
    B
    UK
    I need a query that can give me results like this
    A
    UK
    USA
    B
    Canada
    UK
    Any help would be greatly appreciated
    cheers,
    Sammy

    Thanks for your reply.  But I want the results to be like this
     A
    UK
    USA
    Canada
    B
    Australia
    Germany
    Like all the resuts of A should be combined into one row. and same is with B right now when I run the query It looks like this:
    A
     UK
    null
    USA
    null
    Canada
    B
    Australia
    null
    Germany
    Thank you for your help in advance

  • Sql tuning query running slow -2

    oracle : 10g
    os : linux
    SELECT *
      FROM (SELECT elance_paginated_data.*, ROWNUM elance_current_row_number
              FROM (SELECT elance_original_data.*
                      FROM (SELECT   /*+first_rows ordered use_nl(cont) use_nl(conthub) use_nl(sps) */
                                     cont.ID AS workorderid,
                                     cont.status_id AS statusid,
                                     cont.code AS workordercode,
                                     cont.NAME AS workordertitle,
                                     cont.description AS workorderdescription,
                                     cont.start_dt AS startdate,
                                     cont.end_dt AS enddate,
                                     cont.termination_dt AS terminationdate,
                                     cont.user_id AS hiring_manager_user_id,
                                     cont.org_id AS org_id,
                                     conthub.user_id AS contractorid,
                                --     cand.last_name AS last_name,
                                        cand.last_name
                                     || ',  '
                                     || cand.first_name AS candidatename,
                                     cand.became_userid AS became_userid,
                                     su.display_name AS hiring_manager_name,
                                     ord.cat_id AS cat_id, ord.ID AS order_id,
                                     ord.code AS order_code,
                                     ord.NAME AS order_name,
                                     ord.version_number AS version_number
                                FROM spm_contracts cont,
                                     spm_contracts_hub conthub,
                                     spm_candidates cand,
                                     spm_users su,
                                     spm_pmt_sched_hub spsh,
                                     spm_payment_schedule sps,
                                     spm_contracts ord
                               WHERE cont.owner_id = 4000 /* Change for GE env. : changed value from 100 to 4000 */
                                 AND cont.contract_type_id = 323
                                 AND cont.status_id IN (8705, 8709, 8708, 8702)
                                 AND EXISTS (
                                        SELECT 1
                                          FROM spm_user_folder_details ufd
                                         WHERE ufd.contract_id = cont.ID
                                           AND ufd.user_id IN (
                                                  SELECT ru.role_id
                                                    FROM spm_role_users ru,
                                                         spm_roles r
                                                   WHERE ru.user_id = 29 /* Change for GE env. : changed value from 257698 to 29 */
                                                     AND ru.role_id = r.ID
                                                     AND r.type_of =
                                                                 'ROLE_GROUP_TYPE'
                                                  UNION ALL
                                                  SELECT 29 /* Change for GE env. : changed value from 257698 to 29 */
                                                    FROM DUAL))
                                 AND NOT EXISTS (
                                        SELECT /*+ use_nl(pcr) */ 1
                                          FROM spm_contract_pcr pcr,
                                               spm_contracts ord2
                                         WHERE pcr.contract_id_child = ord.ID
                                           AND pcr.contract_id_parent = ord2.ID
                                           AND ord2.status_id = 2612
                                           AND pcr.type_of_relation IN
                                                  ('CONTR_NEW_VERSION',
                                                   'CONTRACTOR_REENGAGED'
                                 AND cont.ID = conthub.contract_id
                                 AND conthub.type_of = 'CANDIDATE'
                                 AND conthub.candidate_id = cand.ID
                                 AND cont.user_id = su.ID
                                 AND cont.ID = spsh.contract_id
                                 AND spsh.pmt_sched_id = sps.ID
                                 AND sps.contract_id = ord.ID
                            ORDER BY workorderid DESC) elance_original_data) elance_paginated_data
             WHERE ROWNUM <= 31)
    WHERE elance_current_row_number >= 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.60       0.57          1        148          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        4     12.70      21.37       3459     481585          0          31
    total        6     13.30      21.94       3460     481733          0          31
    Misses in library cache during parse: 1
    Optimizer mode: FIRST_ROWS
    Parsing user id: 21  (TLADM01)
    Rows     Row Source Operation
         31  VIEW  (cr=481585 pr=3459 pw=0 time=21365544 us)
         31   COUNT STOPKEY (cr=481585 pr=3459 pw=0 time=21365480 us)
         31    FILTER  (cr=481585 pr=3459 pw=0 time=21365455 us)
         31     VIEW  (cr=481491 pr=3459 pw=0 time=21366696 us)
         31      SORT ORDER BY (cr=481491 pr=3459 pw=0 time=21366310 us)
      32745       NESTED LOOPS  (cr=481491 pr=3459 pw=0 time=19266638 us)
      32745        NESTED LOOPS  (cr=415999 pr=3459 pw=0 time=18415173 us)
      32745         HASH JOIN  (cr=350507 pr=2907 pw=0 time=16695622 us)
      32745          HASH JOIN  (cr=349756 pr=2823 pw=0 time=16056095 us)
      32745           HASH JOIN  (cr=349581 pr=2780 pw=0 time=16950617 us)
      32745            TABLE ACCESS BY INDEX ROWID SPM_CONTRACTS_HUB (cr=347407 pr=610 pw=0 time=8351793 us)
      65491             NESTED LOOPS  (cr=332023 pr=338 pw=0 time=105243492 us)
      32745              NESTED LOOPS  (cr=299202 pr=298 pw=0 time=6616161 us)
    149239               VIEW  VW_SQ_2 (cr=724 pr=53 pw=0 time=1118731 us)
    149239                HASH UNIQUE (cr=724 pr=53 pw=0 time=969487 us)
    197161                 NESTED LOOPS  (cr=724 pr=53 pw=0 time=394854 us)
          9                  VIEW  VW_NSO_1 (cr=100 pr=0 pw=0 time=1288 us)
          9                   UNION-ALL  (cr=100 pr=0 pw=0 time=1269 us)
          8                    NESTED LOOPS  (cr=100 pr=0 pw=0 time=1133 us)
         97                     INDEX RANGE SCAN ROLE_TYPE_NDX (cr=1 pr=0 pw=0 time=514 us)(object id 30685)
          8                     INDEX UNIQUE SCAN ROLE_USERS_PK (cr=99 pr=0 pw=0 time=1140 us)(object id 30691)
          1                    FAST DUAL  (cr=0 pr=0 pw=0 time=4 us)
    197161                  INDEX RANGE SCAN UFD_CONTRACT_FK_I (cr=624 pr=53 pw=0 time=197643 us)(object id 30848)
      32745               TABLE ACCESS BY INDEX ROWID SPM_CONTRACTS (cr=298478 pr=245 pw=0 time=7787761 us)
    149238                INDEX UNIQUE SCAN CONTRACTS_PK (cr=149240 pr=59 pw=0 time=2627776 us)(object id 30085)
      32745              INDEX RANGE SCAN CONT_HUB_CONTRACT_FK_I (cr=32821 pr=40 pw=0 time=1129934 us)(object id 30106)
      44590            TABLE ACCESS FULL SPM_CANDIDATES (cr=2174 pr=2170 pw=0 time=695935 us)
      35864           INDEX FAST FULL SCAN SPM_USERS_SNZ1_IDX (cr=175 pr=43 pw=0 time=49486 us)(object id 30832)
      44547          INDEX FAST FULL SCAN PMT_SCHED_HUB_IDX_1 (cr=751 pr=84 pw=0 time=101490 us)(object id 30474)
      32745         TABLE ACCESS BY INDEX ROWID SPM_PAYMENT_SCHEDULE (cr=65492 pr=552 pw=0 time=3084181 us)
      32745          INDEX UNIQUE SCAN PMT_SCHED_PK (cr=32747 pr=34 pw=0 time=512373 us)(object id 30427)
      32745        TABLE ACCESS BY INDEX ROWID SPM_CONTRACTS (cr=65492 pr=0 pw=0 time=820633 us)
      32745         INDEX UNIQUE SCAN CONTRACTS_PK (cr=32747 pr=0 pw=0 time=344850 us)(object id 30085)
          0     NESTED LOOPS  (cr=94 pr=0 pw=0 time=3048 us)
          8      TABLE ACCESS BY INDEX ROWID SPM_CONTRACT_PCR (cr=70 pr=0 pw=0 time=2354 us)
          8       INDEX RANGE SCAN CONTRACT_PCR_CHILD_FK_I (cr=62 pr=0 pw=0 time=1915 us)(object id 30116)
          0      TABLE ACCESS BY INDEX ROWID SPM_CONTRACTS (cr=24 pr=0 pw=0 time=583 us)
          8       INDEX UNIQUE SCAN CONTRACTS_PK (cr=16 pr=0 pw=0 time=328 us)(object id 30085)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: HINT: FIRST_ROWS
         31   VIEW
         31    COUNT (STOPKEY)
         31     FILTER
         31      VIEW
         31       SORT (ORDER BY)
      32745        NESTED LOOPS
      32745         NESTED LOOPS
      32745          HASH JOIN
      32745           HASH JOIN
      32745            HASH JOIN
      32745             TABLE ACCESS   MODE: ANALYZED (BY INDEX
                            ROWID) OF 'SPM_CONTRACTS_HUB' (TABLE)
      65491              NESTED LOOPS
      32745               NESTED LOOPS
    149239                VIEW OF 'VW_SQ_2' (VIEW)
    149239                 HASH (UNIQUE)
    197161                  NESTED LOOPS
          9                   VIEW OF 'VW_NSO_1' (VIEW)
          9                    UNION-ALL
          8                     NESTED LOOPS
         97                      INDEX   MODE: ANALYZED
                                     (RANGE SCAN) OF 'ROLE_TYPE_NDX' (INDEX)
          8                      INDEX   MODE: ANALYZED
                                   (UNIQUE SCAN) OF 'ROLE_USERS_PK' (INDEX
                                     (UNIQUE))
          1                     FAST DUAL
    197161                   INDEX   MODE: ANALYZED (RANGE
                                  SCAN) OF 'UFD_CONTRACT_FK_I' (INDEX)
      32745                TABLE ACCESS   MODE: ANALYZED (BY
                               INDEX ROWID) OF 'SPM_CONTRACTS' (TABLE)
    149238                 INDEX   MODE: ANALYZED (UNIQUE SCAN)
                                OF 'CONTRACTS_PK' (INDEX (UNIQUE))
      32745               INDEX   MODE: ANALYZED (RANGE SCAN) OF
                              'CONT_HUB_CONTRACT_FK_I' (INDEX)
      44590             TABLE ACCESS   MODE: ANALYZED (FULL) OF
                            'SPM_CANDIDATES' (TABLE)
      35864            INDEX   MODE: ANALYZED (FAST FULL SCAN) OF
                           'SPM_USERS_SNZ1_IDX' (INDEX)
      44547           INDEX   MODE: ANALYZED (FAST FULL SCAN) OF
                          'PMT_SCHED_HUB_IDX_1' (INDEX)
      32745          TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF
                         'SPM_PAYMENT_SCHEDULE' (TABLE)
      32745           INDEX   MODE: ANALYZED (UNIQUE SCAN) OF
                          'PMT_SCHED_PK' (INDEX (UNIQUE))
      32745         TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF
                        'SPM_CONTRACTS' (TABLE)
      32745          INDEX   MODE: ANALYZED (UNIQUE SCAN) OF
                         'CONTRACTS_PK' (INDEX (UNIQUE))
          0      NESTED LOOPS
          8       TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF
                      'SPM_CONTRACT_PCR' (TABLE)
          8        INDEX   MODE: ANALYZED (RANGE SCAN) OF
                       'CONTRACT_PCR_CHILD_FK_I' (INDEX)
          0       TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF
                      'SPM_CONTRACTS' (TABLE)
          8        INDEX   MODE: ANALYZED (UNIQUE SCAN) OF 'CONTRACTS_PK'
                       (INDEX (UNIQUE))output of tkprof attached

    Hi Tom,
    just a very basic hint:
    Are the statistics computed on your schema? It definetely helps the optimizer choose the right path to access the data.
    With up-to-date statistics, I did not experience major performance problem, while using the standard (java) search method.
    Regards
    Daniel

  • SQL Azure - query with row_number() executes slow if columns with nvarchar of big size are included

    I am linking my question from Stack Overflow here. The link: http://stackoverflow.com/questions/27943913/sql-azure-query-with-row-number-executes-slow-if-columns-with-nvarchar-of-bi
    Appreciate your help!
    Gorgi

    Hi,
    Thanks for posting here.
    I suggest you to check this link and optimize your query on sql azure.
    http://www.sqlusa.com/articles/query-optimization/
    http://sqlblog.com/blogs/paul_white/archive/2011/02/23/Advanced-TSQL-Tuning-Why-Internals-Knowledge-Matters.aspx
    Also check this blog which had similar issue.
    https://social.msdn.microsoft.com/Forums/en-US/c1da08b4-265d-4ec8-a252-8d7090234e3e/simple-select-query-takes-long-time-to-execute-with-nvarchar-columns?forum=transactsql
    Girish Prajwal

  • How to capture all the rows returned from a sql select query in CPO

    Hi,
      I am executing an sql select query which returns multiple rows. I need to capture the values of each row to specific variables. How do I proceed.
    Thanks,
    Swati

    The select activities  ("Select from Oracle," Select from SQL Server," etc.) against database already return tables.  Use one of the database adapters to do your select, and it will already be in a table form.  Just put your query in the select and identify the columns in your result table. The online help or the database adapter guides in the product documentation can help.

  • SQL Query (PL/SQL Function Body returning SQL query) doesn't return any row

    I have a region with the following type:
    SQL Query (PL/SQL Function Body returning SQL query).
    In a search screen the users can enter different numbers, separated by an ENTER.
    I want to check these numbers by replacing the ENTER, which is CHR(13) || CHR(10) I believe, with commas. And then I can use it like this: POD IN (<<text>>).
    It's something like this:
    If (:P30_POD Is Not Null) Then
    v_where := v_where || v_condition || 'POD IN (''''''''||REPLACE(''' || :P30_POD || ''', CHR(13) || CHR(10), '','')||'''''''''')';
    v_condition := ' AND ';
    End If;
    But the query doesn't return any rows.
    I tried to reproduce it in Toad:
    select * from asx_worklistitem
    where
    POD IN (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
    ==> This is the query that does't return any rows
    select (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
    from dual;
    ==> This returns '541449200000171813','541449206006341366'
    select * from asx_worklistitem
    where pod in ('541449200000171813','541449206006341366');
    ==> and when I copy/paste this in the above query, it does return my rows.
    So why does my first query doesn't work?
    Doe anyone have any idea?
    Kind regards,
    Geert
    Message was edited by:
    Zorry

    Thanks for the help.
    I made it work, but via the following code:
    If (:P30_POD Is Not Null) Then
    v_pods := REPLACE(:P30_POD, CHR(13) || CHR(10));
    v_where := v_where || v_condition || 'POD IN (';
    v_counter := 1;
    WHILE (v_counter < LENGTH(v_pods)) LOOP
    v_pod := SUBSTR(v_pods, v_counter, 18);
    IF (v_counter <> 1) THEN
    v_where := v_where || ',';
    END IF;
    v_where := v_where || '''' || v_pod || '''';
    v_counter := v_counter + 18;
    END LOOP;
    v_where := v_where || ')';
    v_condition := ' AND ';
    End If;But now I want to make an update of all the records that correspond to this search criteria. I can give in a status via a dropdownlist and that I want to update all the records that correspond to one of these POD's with that status.
    For a region you can build an SQL query via PL/SQL, but for a process you only have a PL/SQL block. Is the only way to update all these records by making a loop and make an update for every POD that is specified.
    Because I think this will have a lot of overhead.
    I would like to make something like a multi row update in an updateable report, but I want to specify the status from somewhere else. Is this possible?

  • Slow Query Issues Oracle 11GR1

    Hi All,
    Oracle 11.1.0.6 on AIX 6.1. CPU-8 CORES, Memory - 32G db size - 500G
    Recently we did a OS Hardening(mainly on OS security) followed by upgrade of RAM (from 16G to 32G) in a production environment.
    We restarted the DB but did not restart the server.
    1> Just after the activity our Stored Programs in PL/SQL all running very slow.
    2> Other issues present from before the activity;
    a. High log file switch completion (avg > 140ms)
    b. High waits in db sequential reads, db file scattered read, direct path write temp
    c. Redo log file siizes are 500M, switching every 2 mins without much activity.
    3> data, redo, control, arch all share 2 mount points.
    4> We never run any dbms_stats as we recently went to production.
    5) After running EXEC DBMS_STATS.GATHER_FIXED_OBJECTS_STATS(NULL); the Stored Programs were more slow.
    6) ping and tnsping was Ok.
    What should be the action plan to resolve the immediate and long term issues..?

    user13355115 wrote:
    Hi All,
    Oracle 11.1.0.6 on AIX 6.1. CPU-8 CORES, Memory - 32G db size - 500G
    Recently we did a OS Hardening(mainly on OS security) followed by upgrade of RAM (from 16G to 32G) in a production environment.
    We restarted the DB but did not restart the server.
    1> Just after the activity our Stored Programs in PL/SQL all running very slow.
    2> Other issues present from before the activity;It is expected that the upgrades/patches you did (OS and RAM) would not affect the IO times. The bigger RAM should have reduced the need to do IO though. You need address your IO system if you need faster responses there.
    >
    a. High log file switch completion (avg > 140ms)
    b. High waits in db sequential reads, db file scattered read, direct path write temp
    c. Redo log file siizes are 500M, switching every 2 mins without much activity.There must be some activity that generates that redo. It is either directly or indirectly (delayed block cleanout) generated by a user. The overall amount of redo (15G per hour) is kind of high, but not extreme for most modern hardware.
    >
    3> data, redo, control, arch all share 2 mount points.
    4> We never run any dbms_stats as we recently went to production.Please gather application tables/indexes statistics – they are essential for achieving optimal performance.
    >
    5) After running EXEC DBMS_STATS.GATHER_FIXED_OBJECTS_STATS(NULL); the Stored Programs were more slow.
    6) ping and tnsping was Ok.
    What should be the action plan to resolve the immediate and long term issues..?Iordan Iotzov
    http://iiotzov.wordpress.com/

  • How to connect to SQL*Plus and issue a query all in one command?

    Hi everyone,
    Does anyone know of a way to connect to a db with SQL*Plus, and issue a simple query, all with one command?
    I know that I can save a .sql script with a query, then do this:
    sqlplus user/pwd@db @myscript.sql
    But I'm wondering if there's any way to put the actual query right into the connect command, something like:
    sqlplus user/pwd@db "select count(*) from dba_tables;"
    Does anyone know of a way to do this?

    you didn't mention windows or unix. so, here's a link with both
    Re: windows sql script
    it also has a link to another thread on how to deal with the parens when using ehco in dos.

  • OTL I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?

    Hi
    I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?
    I basically need person name who submitted, date - time it was submitted for approval, then the person who approved it and the date - time that it was approved
    Thanks
    Ruby

    Ruby,
    you can start with HXC_TIMECARD_SUMMARY table for submitter detail. But for approver details, i think you need WF tables to get the data for item type HXCEMP.

  • Physical query issued by Obiee when cache is on is different and slow

    When the same report runs in OBIEE 10g and cache is OFF it takes less then 1min to get results. If cache is turned ON physical query issued by Obiee is totally different and it takes 2h to get results. Has anyone experienced this with having cache on that some queries are performing poorly.
    Thanks,
    Tatjana

    We are using BI Apps Order Management and Fulfillment Analytics and all tables are cached anyway. Dimensions used are not that huge up to 40K rows. What should I check when it comes to DB query? As I said is different than one generated when cache is disabled although both have the almost the explain plan.

  • PL/SQL procedure is 10x slower when running from weblogic

    Hi everyone,
    we've developed a PL/SQL procedure performing reporting - the original solution was written in Java but due to performance problems we've decided to switch this particular piece to PL/SQL. Everything works fine as long as we execute the procedure from SQL Developer - the batch processing 20000 items finishes in about 80 seconds, which is a serious improvement compared to the previous solution.
    But once we call the very same procedure (on exactly the same data) from weblogic, the performance seriously drops - instead of 80 seconds it suddenly runs for about 23 minutes, which is 10x slower. And we don't know why this happens :-(
    We've profiled the procedure (in both environments) using DBMS_PROFILER, and we've found that if the procedure is executed from Weblogic, one of the SQL statements runs noticeably slower and consumes about 800 seconds (90% of the total run time) instead of 0.9 second (2% of the total run time), but we're not sure why - in both cases this query is executed 32742-times, giving 24ms vs. 0.03ms in average.
    The SQL is
    SELECT personId INTO v_personId FROM (            
            SELECT personId FROM PersonRelations
            WHERE extPersonId LIKE v_person_prefix || '%'
    ) WHERE rownum = 1;Basically it returns an ID of the person according to some external ID (or the prefix of the ID). I do understand why this query might be a performance problem (LIKE operator etc.), but I don't understand why this runs quite fast when executed from SQL Developer and 10x slower when executed from Weblogic (exactly the same data, etc.).
    Ve're using Oracle 10gR2 with Weblogic 10, running on a separate machine - there are no other intensive tasks, so there's nothing that could interfere with the oracle process. According to the 'top' command, the wait time is below 0.5%, so there should be no serious I/O problems. We've even checked JDBC connection pool settings in Weblogic, but I doubt this issue is related to JDBC (and everything looks fine anyway). The statistics are fresh and the results are quite consistent.
    Edited by: user6510516 on 17.7.2009 13:46

    The setup is quite simple - the database is running on a dedicated database server (development only). Generally there are no 'intensive' tasks running on this machine, especially not when the procedure I'm talking about was executed. The application server (weblogic 10) is running on different machine so it does not interfere with the database (in this case it was my own workstation).
    No, the procedure is not called 20000x - we have a table with batch of records we need to process, with a given flag (say processed=0). The procedure reads them using a cursor and processes the records one-by-one. By 'processing' I mean computing some sums, updating other table, etc. and finally switching the record to processed=1. I.e. the procedure looks like this:
    CREATE PROCEDURE process_records IS
        v_record records_to_process%ROWTYPE;
    BEGIN
         OPEN records_to_process;
         LOOP
              FETCH records_to_process INTO v_record;
              EXIT WHEN records_to_process%NOTFOUND;
              -- process the record (update table A, insert a record into B, delete from C, query table D ....)
              -- and finally mark the row as 'processed=1'
         END LOOP;
         CLOSE records_to_process;
    END process_records;The procedure is actually part of a package and the cursor 'records_to_process' is defined in the body. One of the queries executed in the procedure is the SELECT mentioned above (the one that jumps from 2% to 90%).
    So the only thing we actually do in Weblogic is
    CallableStatement cstmt = connection.prepareCall("{call ProcessPkg.process_records}");
    cstmt.execute();and that's it - there is only one call to the JDBC, so the network overhead shouldn't be a problem.
    There are 20000 rows we use for testing - we just update them to 'processed=0' (and clear some of the other tables). So actually each run uses exactly the same data, same code paths and produces the very same results. Yet when executed from SQL developer it takes 80 seconds and when executed from Weblogic it takes 800 seconds :-(
    The only difference I've just noticed is that when using SQL Developer, we're using PL/SQL notation, i.e. "BEGIN ProcessPkg.process_records; END;" instead of "{call }" but I guess that's irrelevant. And yet another difference - weblogic uses JDBC from 10gR2, while the SQL Developer is bundled with JDBC from 11g.

  • Update query is slow with merge replication

    Hello friend,
    I have a database with enabling merge replication.
    Then the problem is update query is taking more time.
    But when I disable the merge triggers then it'll update quickly.
    I really appreciate your
    quick response.
    Thanks.

    Hi Manjula,
    According to your description, the update query is slow after configuring merge replication. There are some proposals for you troubleshooting this issue as follows.
    1. Perform regular index maintenance, update statistics, re-index, on the following Replication system tables.
        •MSmerge_contents
        •MSmerge_genhistory
        •MSmerge_tombstone
        •MSmerge_current_partition_mappings
        •MSmerge_past_partition_mappings
    2. Make sure that your tables involved in the query have suitable indexes. Also do the re-indexing and update the statistics for these tables. Additionally, you can use
    Database Engine Tuning Advisor to tune databases for better query performance.
    Here are some related articles for your reference.
    http://blogs.msdn.com/b/chrissk/archive/2010/02/01/sql-server-merge-replication-best-practices.aspx
    http://technet.microsoft.com/en-us/library/ms177500(v=sql.105).aspx
    Thanks,
    Lydia Zhang

  • Join 25 M with 200 M - Query Issue

    I have 2 tables, CUSTOMER and CUSTOMER Transaction. CUSTOMER has 25 M records and CUSTOMER TRANSACTION has 200 M records. I need to get the count from CUSTOMER TRANSACTION divided by transaction type. below is my tables.
    CUSTOMER
    ========
    CUST_ID          LOC_ID          (OTHER COLUMNS)
    12345          001
    23456          002
    67890          910
    54298          789
    16754          909CUSTOMER TRANSACTION
    ====================
    CUST_ID          LOC_ID          TRANSACTION_TYPE     DATE          (OTHER COLUMNS)
    12345          001          CREDIT               01-jan-01
    12345          001          DEBIT               02-jan-02
    12345          001          CHEQUE               03-jan-03
    12345          001          CASH               04-jan-04
    12345          001          CASH               05-jan-06
    12345          001          CASH               11-feb-11
    54298          789          CREDIT               01-jan-01
    54298          789          CREDIT               02-jan-01I need to have below output
    CUST_ID          LOC_ID          CREDIT     DEBIT     CASH     TOTAL
    12345          001          1     1     3     5
    23456          002          0     0     0     0
    67890          910          0     0     0     0
    54298          789          2     0     0     2
    16754          909          0     0     0     0
    54298          789          0     0     0     0
    SELECT C.CUST_ID, C.LOC_ID, CT.TOTAL, CT.CREDIT, CT.DEBIT, CT.CASH
    FROM
    CUSTOMER C LEFT OUTER JOIN
    select      CUST_ID,
         LOC_ID,
         COUNT(*) TOTAL,
         SUM(CASE WHEN TRANSACTION_TYPE = 'CREDIT',1,0) CREDIT,
         SUM(CASE WHEN TRANSACTION_TYPE = 'DEBIT',1,0 END) DEBIT,
         SUM(CASE WHEN TRANSACTION_TYPE = 'CASH',1,0 END) CASH
    FROM      CUSTOMER_TRANSACTION
    GROUP BY CUST_ID, LOC_ID
    ) CT
    ON C.CUST_ID = CT.CUST_ID and C.LOC_ID = CT.LOC_IDNow my CUSTOMER table itself is joined with other 5 tables, with left outer join to get other information.I am joining the count as above. But i am facing severe performance issue, as it does group by on 200 M records in CUSTOMER_TRANSACTION and then joining this result set with CUSTIMER table using left outer join.
    Can some one help me on how to write efficient query?

    ace_friends22 wrote:
    The problem with this query is, it takes lots of time to reqturn the result set.Of course. You cannot expect it to be fast - not with the amount of I/O that needs to be done.
    The simple and harsh fact is that the more data there is for the SQL to crunch, the slower it will be, as I/O is the slowest and most expensive operation on a database.
    I just wanted to know if there is better way of writing this qyery?There's 2 basic ways to address this. Do less I/O. Do smarter I/O.
    Doing less I/O means using optimal I/O paths to get to the relevant data. Like indexes. Or partitions. Or both. And ensuring the CBO comes up with a sane execution plan and not one based on none or skewed statistics. Etc.
    Doing smarter I/O means trying to eliminate some of the I/O latency using parallel processing. Oracle supports both parallel DML and DDL. And (for example), instead of having a single process crunching 20 million rows, you could use 20 parallel processing each doing around a million rows - assuming of course you have the CPU capacity and 20 I/O intensive processes will not overload the I/O subsystem.
    More than that... get something like Oracle's Exadata storage cells that provide a 40Gb I/O fabric layer and a very intelligent storage server...
    And keep a firm grip on the realities of computing with regards your performance expectations.

  • How to pass 100+ tags in a single sql/tag query

    <b>In my current application I have to pass 180+ tags in a single query to retrieve data from iHistorian.
    I want to know how to pass more thatn 100 tags in a single SQL or TAG Query using OLEDB or UDC connectors.
    If anybody has done it in the past ,please share with me and also let me know how to do it</b>

    Currently you can only query a maximum of 128 tags, this is a hard limit and may be changed in future releases of xMII, but < 11.5 (im fairly sure 12 also) all have the limit of 128.
    As for iHistorian with the OLEDB UDS, you can write a query that would return over 128 queries becasue this is an input limitation on the UDSs. (PLEASE DON"T ASK US HOW TO WRITE iHistorian QUERIES... we aren't experts in iHistorian).
    Please note that though you can query over 128 tags, the performance may not be what you expect... This may take a very long time to return.
    Martin

Maybe you are looking for