Delete query is slow in one schema.

Hi All,
I have two schemas in a database PRDPUB and TOOLSERVER . In both the schemas i have a table BP_USER_PROFILE containg same amount of data , indexes and constrains. I am using one delete query to delete 26000 records from both the table , but in PRDPUB schema it is hanging but in TOOLSERVER schema it is running fine.When i tried to delete 100 records using the same query in PRDPUB schema it is taking 44 second nad 13 milisecond in TOOLSERVER.
when i generated the exution plan it is very much same .But when i see the trace file i see in PRDPUB schema it is accessing the disk and doing parsing and execution 2 times , while in TOOLSERVER schema it is deleting in memory and parsing and executing once.
For your reference i am attching the expalin plan and trace file output. Please help me out to resolve the issue.
explain plan for delete from bp_user_profile where id_user in (select id_user from (SELECT * FROM bp_user_profile WHERE
id_home_category=5005 AND DT_USER_LAST_UPDATED <'01-DEC-09' AND ID_USER_STATUS_ACTIVE ='DELETED_BY_ADMIN'
OR ID_USER_STATUS_ACTIVE ='DELETED_BY_USER') where rownum<=100);
PLAN_TABLE_OUTPUT in PRDPUB schema
Plan hash value: 288284804
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | DELETE STATEMENT | | 100 | 7600 | 1906 (1)| 00:00:23 |
| 1 | DELETE | BP_USER_PROFILE | | | | |
| 2 | NESTED LOOPS | | 100 | 7600 | 1906 (1)| 00:00:23 |
| 3 | VIEW | VW_NSO_1 | 100 | 1300 | 1885 (1)| 00:00:23 |
| 4 | SORT UNIQUE | | 100 | 2100 | | |
|* 5 | COUNT STOPKEY | | | | | |
|* 6 | TABLE ACCESS BY INDEX ROWID | BP_USER_PROFILE | 86428 | 1772K| 1885 (1)| 00:00:23 |
| 7 | BITMAP CONVERSION TO ROWIDS | | | | | |
| 8 | BITMAP OR | | | | | |
| 9 | BITMAP CONVERSION FROM ROWIDS | | | | | |
|* 10 | INDEX RANGE SCAN | BP_USER_PROFILE_ID_USER_STATUS | | | 12 (0)| 00:00:01 |
| 11 | BITMAP AND | | | | | |
| 12 | BITMAP CONVERSION FROM ROWIDS| | | | | |
|* 13 | INDEX RANGE SCAN | BP_USER_PROFILE_ID_USER_STATUS | | | 2 (0)| 00:00:01 |
| 14 | BITMAP CONVERSION FROM ROWIDS| | | | | |
|* 15 | INDEX RANGE SCAN | BP_USR_PROF_IDCATG | | | 79 (2)| 00:00:01 |
|* 16 | INDEX UNIQUE SCAN | BP_USR_PROF_PK_ID_USER | 1 | 63 | 1 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
5 - filter(ROWNUM<=100)
6 - filter("ID_USER_STATUS_ACTIVE"='DELETED_BY_USER' OR "ID_USER_STATUS_ACTIVE"='DELETED_BY_ADMIN' AND
"ID_HOME_CATEGORY"=5005 AND "DT_USER_LAST_UPDATED"<'01-DEC-09')
10 - access("ID_USER_STATUS_ACTIVE"='DELETED_BY_USER')
13 - access("ID_USER_STATUS_ACTIVE"='DELETED_BY_ADMIN')
15 - access("ID_HOME_CATEGORY"=5005)
PLAN_TABLE_OUTPUT
16 - access("ID_USER"="$nso_col_1")
PLAN_TABLE_OUTPUT
Plan hash value: 288284804
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | DELETE STATEMENT | | 102 | 7752 | 2892 (2)| 00:00:35 |
| 1 | DELETE | BP_USER_PROFILE | | | | |
| 2 | NESTED LOOPS | | 102 | 7752 | 2892 (2)| 00:00:35 |
| 3 | VIEW | VW_NSO_1 | 100 | 1300 | 2871 (1)| 00:00:35 |
| 4 | SORT UNIQUE | | 100 | 2100 | | |
|* 5 | COUNT STOPKEY | | | | | |
|* 6 | TABLE ACCESS BY INDEX ROWID | BP_USER_PROFILE | 170K| 3500K| 2871 (1)| 00:00:35 |
| 7 | BITMAP CONVERSION TO ROWIDS | | | | | |
| 8 | BITMAP OR | | | | | |
| 9 | BITMAP CONVERSION FROM ROWIDS | | | | | |
|* 10 | INDEX RANGE SCAN | BP_USER_PROFILE_ID_USER_STATUS | | | 22 (0)| 00:00:01 |
| 11 | BITMAP AND | | | | | |
| 12 | BITMAP CONVERSION FROM ROWIDS| | | | | |
|* 13 | INDEX RANGE SCAN | BP_USER_PROFILE_ID_USER_STATUS | | | 22 (0)| 00:00:01 |
| 14 | BITMAP CONVERSION FROM ROWIDS| | | | | |
|* 15 | INDEX RANGE SCAN | BP_USR_PROF_IDCATG | | | 78 (2)| 00:00:01 |
|* 16 | INDEX UNIQUE SCAN | BP_USR_PROF_PK_ID_USER | 1 | 63 | 1 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
5 - filter(ROWNUM<=100)
6 - filter("ID_USER_STATUS_ACTIVE"='DELETED_BY_USER' OR "ID_USER_STATUS_ACTIVE"='DELETED_BY_ADMIN' AND
"ID_HOME_CATEGORY"=5005 AND "DT_USER_LAST_UPDATED"<'01-DEC-09')
10 - access("ID_USER_STATUS_ACTIVE"='DELETED_BY_USER')
13 - access("ID_USER_STATUS_ACTIVE"='DELETED_BY_ADMIN')
15 - access("ID_HOME_CATEGORY"=5005)
PLAN_TABLE_OUTPUT
16 - access("ID_USER"="$nso_col_1")
34 rows selected.
=====================================
trace file out put:
delete from prdpub.bp_user_profile where id_user in (select id_user from (SELECT * FROM prdpub.bp_user_profile WHERE
id_home_category=:"SYS_B_0" AND DT_USER_LAST_UPDATED <:"SYS_B_1" AND ID_USER_STATUS_ACTIVE =:"SYS_B_2"
OR ID_USER_STATUS_ACTIVE =:"SYS_B_3") where rownum<=:"SYS_B_4")
call count cpu elapsed disk query current rows
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.61 0.61 1027 1574 8292 200
Fetch 0 0.00 0.00 0 0 0 0
total 4 0.61 0.61 1027 1574 8292 200
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Rows Row Source Operation
0 DELETE BP_USER_PROFILE (cr=1542994 pr=527 pw=0 time=43954914 us)
100 NESTED LOOPS (cr=794 pr=13 pw=0 time=125348 us)
100 VIEW VW_NSO_1 (cr=558 pr=0 pw=0 time=95818 us)
100 SORT UNIQUE (cr=558 pr=0 pw=0 time=95618 us)
100 COUNT STOPKEY (cr=558 pr=0 pw=0 time=94328 us)
100 TABLE ACCESS BY INDEX ROWID BP_USER_PROFILE (cr=558 pr=0 pw=0 time=94325 us)
103 BITMAP CONVERSION TO ROWIDS (cr=481 pr=0 pw=0 time=93891 us)
1 BITMAP OR (cr=481 pr=0 pw=0 time=93879 us)
1 BITMAP CONVERSION FROM ROWIDS (cr=88 pr=0 pw=0 time=11643 us)
22224 INDEX RANGE SCAN BP_USER_PROFILE_ID_USER_STATUS (cr=88 pr=0 pw=0 time=77 us)(object id 89712)
1 BITMAP AND (cr=393 pr=0 pw=0 time=80750 us)
1 BITMAP CONVERSION FROM ROWIDS (cr=10 pr=0 pw=0 time=1150 us)
1911 INDEX RANGE SCAN BP_USER_PROFILE_ID_USER_STATUS (cr=10 pr=0 pw=0 time=21 us)(object id 89712)
3 BITMAP CONVERSION FROM ROWIDS (cr=383 pr=0 pw=0 time=105831 us)
181506 INDEX RANGE SCAN BP_USR_PROF_IDCATG (cr=383 pr=0 pw=0 time=26 us)(object id 88278)
100 INDEX UNIQUE SCAN BP_USR_PROF_PK_ID_USER (cr=236 pr=13 pw=0 time=8945 us)(object id 88279)
delete from toolserver.bp_user_profile where id_user in (select id_user from (SELECT * FROM toolserver.bp_user_profile WHERE
id_home_category=:"SYS_B_0" AND DT_USER_LAST_UPDATED <:"SYS_B_1" AND ID_USER_STATUS_ACTIVE =:"SYS_B_2"
OR ID_USER_STATUS_ACTIVE =:"SYS_B_3") where rownum<=:"SYS_B_4")
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.13 0.12 0 741 3144 100
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.13 0.12 0 741 3144 100
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Rows Row Source Operation
0 DELETE BP_USER_PROFILE (cr=741 pr=0 pw=0 time=123855 us)
100 NESTED LOOPS (cr=741 pr=0 pw=0 time=95704 us)
100 VIEW VW_NSO_1 (cr=528 pr=0 pw=0 time=94093 us)
100 SORT UNIQUE (cr=528 pr=0 pw=0 time=94091 us)
100 COUNT STOPKEY (cr=528 pr=0 pw=0 time=93729 us)
100 TABLE ACCESS BY INDEX ROWID BP_USER_PROFILE (cr=528 pr=0 pw=0 time=93724 us)
102 BITMAP CONVERSION TO ROWIDS (cr=490 pr=0 pw=0 time=93380 us)
1 BITMAP OR (cr=490 pr=0 pw=0 time=93369 us)
1 BITMAP CONVERSION FROM ROWIDS (cr=93 pr=0 pw=0 time=11663 us)
22722 INDEX RANGE SCAN BP_USER_PROFILE_ID_USER_STATUS (cr=93 pr=0 pw=0 time=78 us)(object id 87755)
1 BITMAP AND (cr=397 pr=0 pw=0 time=80340 us)
1 BITMAP CONVERSION FROM ROWIDS (cr=11 pr=0 pw=0 time=1118 us)
1911 INDEX RANGE SCAN BP_USER_PROFILE_ID_USER_STATUS (cr=11 pr=0 pw=0 time=15 us)(object id 87755)
3 BITMAP CONVERSION FROM ROWIDS (cr=386 pr=0 pw=0 time=104382 us)
181849 INDEX RANGE SCAN BP_USR_PROF_IDCATG (cr=386 pr=0 pw=0 time=24 us)(object id 87758)
100 INDEX UNIQUE SCAN BP_USR_PROF_PK_ID_USER (cr=213 pr=0 pw=0 time=1194 us)(object id 87754)
Edited by: user12956550 on Apr 8, 2010 11:03 AM

Hi,
is your delete correct?
delete from toolserver.bp_user_profile where id_user in (select id_user from (SELECT * FROM toolserver.bp_user_profile WHERE
id_home_category=:"SYS_B_0" AND DT_USER_LAST_UPDATED <:"SYS_B_1" AND ID_USER_STATUS_ACTIVE =:"SYS_B_2"
OR ID_USER_STATUS_ACTIVE =:"SYS_B_3") where rownum<=:"SYS_B_4")There is a suspected OR in the where clause, I expect you have to check both statusses with the date and home category, so I think your query should be (add parenthesisses around the two statusses):
delete from toolserver.bp_user_profile where id_user in (select id_user from (SELECT * FROM toolserver.bp_user_profile WHERE
id_home_category=:"SYS_B_0" AND DT_USER_LAST_UPDATED <:"SYS_B_1"
AND
( -- added
ID_USER_STATUS_ACTIVE =:"SYS_B_2"
OR ID_USER_STATUS_ACTIVE =:"SYS_B_3"
) -- added
) where rownum<=:"SYS_B_4")Further is the content the same, if these are different, you could also have differences in execution time.
Herald ten Dam
Superconsult.nl

Similar Messages

  • Query performance slow in one instance in RAC

    Hi
    We have 3 node RAC. When we test onw query it slow by 40% in one instance and always physical reads are hapenning in that instance.
    Below are the details. All the parameters are same. Users compains some times the query is slow.
    Thanks in Advance.
    From Instance 1 - 9 Sec
    =============================================================
    Statistics
              0  recursive calls
              1  db block gets
          67209  consistent gets
              0  physical reads
              0  redo size
          23465  bytes sent via SQL*Net to client
          10356  bytes received via SQL*Net from client
             28  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
             13  rows processed
    From Instance 2 - 13 Sec
    =============================================================
    Statistics
              0  recursive calls
              1  db block gets
          67215  consistent gets
          67193  physical reads    <<------------------------ Only in one instance
              0  redo size
          23465  bytes sent via SQL*Net to client
          10356  bytes received via SQL*Net from client
             28  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
             13  rows processed
    From Instance 3 - 9 Sec
    =============================================================
    Statistics
              0  recursive calls
              1  db block gets
          67209  consistent gets
              0  physical reads
              0  redo size
          23465  bytes sent via SQL*Net to client
          10356  bytes received via SQL*Net from client
             28  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
             13  rows processed

    You can also check global cache statistics. Run this before and after your query :
    select name, value from v$mystat s, v$statname n where s.statistic#=n.statistic# and name like '%blocks received';

  • Query running slow in one node

    Hi All,
    We are running 4-node Oracle 10g RAC (linux 64-bit). The query is running fast in one node, but the same query is running very slow in the other node. And sometimes, we see pin S wait on X wait event in top 5 events.
    Has anyone faced this kind of situation before ?
    Thanks,
    Kumar

    Hi,
    Execute your query on node where query is running very slow. Get SID and execute query above to see what is event of waiting.
    exec dbms_application_info.set_client_info('@sw2')
    -- file sw2.sql
    col event  format     a25  heading "Wait Event" trunc
    col state  format     a15  heading "Wait State" trunc
    col siw    format   99999  heading "Waited So|Far (ms)"
    col wt     format 9999999  heading "Time Waited|(ms)"
    select event,
           state,
           seconds_in_wait siw,
           wait_time wt
    from   v$session_wait
    where  sid = &sid
    order by event;
    exec dbms_application_info.set_client_info('@sw1');
    -- file  sw1.sql
    set linesize 30000
    set pagesize 200
    col sid      format    9999  heading "SID"
    col username format     a10  heading "USERNAME"
    col osuser   format     a20  heading "OSUSER"
    col event    format     a25  heading "Wait Event" trunc
    col state    format     a15  heading "Wait State" trunc
    col siw      format   99999  heading "Waited So|Far (ms)"
    col wt       format 9999999  heading "Time Waited|(ms)"
    col sw1      format 9999999  heading "File"
    col sw2      format 9999999  heading "Block"
    col Objeto   format a50
    select sw.event,
           sw.p1,
           sw.p2,
           sw.p3,
           sw.state,
           s.sid,
           S.osuser,
           s.username,
           nvl(s.program, s.module),
           sw.seconds_in_wait siw,
           sw.wait_time wt
      from gv$session_wait sw,
           gv$session s
    WHERE sw.sid = s.sid
       and sw.EVENT NOT LIKE 'SQL%'
       and username is not NULL
       and s.inst_id = sw.inst_id
       and sw.event not like 'PX%'
    order by 1, 6, 7;Regards,
    Levi Pereira

  • Select * query is slow on one particular table

    Hi ,
    I am using forms and reports of AppServer 10g,one particular form accesing one table ...The select * from statement on that table is slow.Any amendmends to be taken care of at the tablespace level??
    Help needed urgent...
    Regards,
    Ashlee

    Hi,
    This is a general type of question. please be specific. Golden Thumb rule is that don't use '*", instead use the column names. Analyze the table and take a execution plan and check for index usage .
    Please give the problem statement also so that we can help you.

  • Query to list the synonyms in one schema to different schema

    Hi
    How can i check the list of synonyms in one schema pointing to different schemas?
    Also query to list the table , foreign key constraint and reference table..
    Thanks

    Manikandan wrote:
    Hi
    How can i check the list of synonyms in one schema pointing to different schemas?
    Also query to list the table , foreign key constraint and reference table..
    Thanks
    1) DBA_SYNONYMS or ALL_SYNONYMS
    2) You can check DBA_CONSTRAINTS and DBA_CONS_COLUMNS.
    Aman....

  • Query slow in  user schema but fast in sys schema

    Hi,
    DB :10.2.
    OS :Aix
    Tool : Toad
    We executed a query which fast(20 seconds) in sys schema.
    But it's taking slow in user schema(it is taken 10 minutes).
    Yesterday we gathered dictionary stats also.
    Any suggestions.
    Thanks & Regards,
    VN

    You're querying a bunch of USER_<<x>> data dictionary views. Since those views show the objects owned by the current user, the script you generate will be completely different depending on the identity of the current user and the set of objects owned by the current user. If you create a new user and run this script as the new user, it will be even faster because USER_TABLES, USER_SEGMENTS, USER_INDEXES, etc. will all be empty.
    I don't understand why you would issue a MOVE on a table without specifying a new tablespace-- that seems like a pointless exercise. And I would seriously question the architect that wants to use ANALYZE to gather statistics rather than using DBMS_STATS.
    Justin

  • While deleting sms in a row one one ios 7 hang up and restart. This is happening in my iphone 4. Ps help. Not happy with update, it is extremely slow. Would request apple to provide an option of restoring it back to ios 6

    While deleting sms in a row one one ios 7 hang up and restart. This is happening in my iphone 4. Ps help. Not happy with update, it is extremely slow. Would request apple to provide an option of restoring it back to ios 6

    I'm having same problem with my iPhone 4.  Even after restoring twice.   Simple tasks casue the phone to lock up and restart, which, thanks to iOS 7 takes much longer than with iOS 6. 
    I love my phone, but it is almost unsuable after update.

  • Query with same explain-plan but slower in one env

    Hi there
    I have a stored procedure which is executed from a web application. It contains a query (insert-select-from statement). When this stored procedure is called by the web application in PROD, it takes 13sec but it takes 19sec in TEST env. I checked the explain plan for this insert statement in both instances and it is same (see below). Actually, the cost is lower in TEST env.
    ENV: Oracle 10gR2 EE, on ASM - RHEL 64bit
    The TEST server is on a better/faster hardware and will become the new PROD in near future (faster and 16 CPUs  vs 8 in PROD, high performance SAN, 132GB RAM vs 96GB in PROD, etc). The TEST database has exact same init parameter and version/patch level as current PROD. So the application is being tested against it at the moment.
    Here are the explain-plans from both environments:
    From PROD Server
    Plan
    INSERT STATEMENT ALL_ROWS Cost: 143 Bytes: 696 Cardinality: 3
    18 SORT ORDER BY Cost: 143 Bytes: 696 Cardinality: 3
    17 HASH UNIQUE Cost: 142 Bytes: 696 Cardinality: 3
    16 WINDOW SORT Cost: 143 Bytes: 696 Cardinality: 3
    15 HASH JOIN Cost: 141 Bytes: 696 Cardinality: 3
    13 HASH JOIN Cost: 128 Bytes: 519 Cardinality: 3
    11 TABLE ACCESS BY INDEX ROWID TABLE MKTG.SATDATAIMPORT Cost: 125 Bytes: 1,728 Cardinality: 12
    10 NESTED LOOPS Cost: 125 Bytes: 1,992 Cardinality: 12
    3 HASH JOIN Cost: 5 Bytes: 22 Cardinality: 1
    1 TABLE ACCESS FULL TABLE MKTG.TMPG_CLICKS_HDGS Cost: 2 Bytes: 12 Cardinality: 1
    2 TABLE ACCESS FULL TABLE MKTG.TMPG_CLICKS_DIRS Cost: 2 Bytes: 10 Cardinality: 1
    9 BITMAP CONVERSION TO ROWIDS
    8 BITMAP AND
    5 BITMAP CONVERSION FROM ROWIDS
    4 INDEX RANGE SCAN INDEX MKTG.SATDATAIMPORT_HEADINGNO Cost: 19 Cardinality: 4,920
    7 BITMAP CONVERSION FROM ROWIDS
    6 INDEX RANGE SCAN INDEX MKTG.SATDATAIMPORT_DIRNO Cost: 89 Cardinality: 4,920
    12 TABLE ACCESS FULL TABLE MKTG.MONTHS12 Cost: 2 Bytes: 84 Cardinality: 12
    14 TABLE ACCESS FULL TABLE MKTG.REF_WEST_CATEGORY Cost: 12 Bytes: 191,809 Cardinality: 3,251
    From TEST Server
    Plan
    INSERT STATEMENT ALL_ROWS Cost: 107 Bytes: 232 Cardinality: 1
    18 SORT ORDER BY Cost: 107 Bytes: 232 Cardinality: 1
    17 HASH UNIQUE Cost: 106 Bytes: 232 Cardinality: 1
    16 WINDOW SORT Cost: 107 Bytes: 232 Cardinality: 1
    15 HASH JOIN Cost: 105 Bytes: 232 Cardinality: 1
    13 HASH JOIN Cost: 93 Bytes: 173 Cardinality: 1
    11 TABLE ACCESS BY INDEX ROWID TABLE MKTG.SATDATAIMPORT Cost: 89 Bytes: 864 Cardinality: 6
    10 NESTED LOOPS Cost: 89 Bytes: 996 Cardinality: 6
    3 HASH JOIN Cost: 7 Bytes: 22 Cardinality: 1
    1 TABLE ACCESS FULL TABLE MKTG.TMPG_CLICKS_HDGS Cost: 3 Bytes: 12 Cardinality: 1
    2 TABLE ACCESS FULL TABLE MKTG.TMPG_CLICKS_DIRS Cost: 3 Bytes: 10 Cardinality: 1
    9 BITMAP CONVERSION TO ROWIDS
    8 BITMAP AND
    5 BITMAP CONVERSION FROM ROWIDS
    4 INDEX RANGE SCAN INDEX MKTG.SATDATAIMPORT_HEADINGNO Cost: 9 Cardinality: 2,977
    7 BITMAP CONVERSION FROM ROWIDS
    6 INDEX RANGE SCAN INDEX MKTG.SATDATAIMPORT_DIRNO Cost: 59 Cardinality: 2,977
    12 TABLE ACCESS FULL TABLE MKTG.MONTHS12 Cost: 3 Bytes: 84 Cardinality: 12
    14 TABLE ACCESS FULL TABLE MKTG.REF_WEST_CATEGORY Cost: 12 Bytes: 191,868 Cardinality: 3,252
    What else can I check to find out why the query is slower in TEST env?
    Please advise.
    Best regards

    Here is some more info. The query is below:
    select distinct dr.line_num 
                     ,row_number() over (partition by di.HEADINGNO,di.DIRECTORYNO order by reportyear,to_number(di.monthno)) monthposition
                     ,di.SATID,di.REPORTYEAR,di.MONTHNO,di.MONTHEN,di.MONTHFR,di.HEADINGNO,hn.NAME_EN,hn.NAME_FR,di.DIRECTORYNO
                     ,di.SUPERDIRECTORYNO,di.PRINTDIRCODE,di.DIRECTORYNAME,round(to_number(di.IMPTTOTAL)) imptotal
                     ,round(to_number(di.IMPBEST)) impbest ,round(to_number(di.IMPTAVERAGE)) imptaverage
                     ,round(to_number(di.CLICKTOTAL)) clicktotal,round(to_number(di.CLICKBEST)) clickbest
                     ,round(to_number(di.CLICKAVERAGE)) clickaverage
                     ,round(avg(to_number(impttotal)) over(partition by di.HEADINGNO,di.DIRECTORYNO)) avgimp
               from satdataimport di,tmpg_clicks_hdgs hd,tmpg_clicks_dirs dr, months12 m12, ref_west_category hn
               where di.headingno   = hd.id
                 and di.directoryno = dr.id
                 and dr.line_num=hd.line_num
                 and di.reportyear  = m12.year
                 and di.monthno     = m12.month
                 and hn.CATEGORY_CODE = di.headingno
               order by di.headingno, di.directoryno,di.reportyear,to_number(di.monthno)
    The largest table is "satdataimport" in the query has "12274818" rows. Rest of the tables are very small containing few rows to less than 4000 rows.
    I have refreshed the statistics of the larger table but this did not help either. Even a simple query like "select count(*) from satdataimport" is taking 15sec in TEST while it takes 4Sec in PROD when I run it from TOAD.
    The other strange thing is that when I run this stored procedure from TOAD, it takes 200 milli sec to complete. There is a logging table to which the stored procedure records the elapsed time taken by this INSERT statement.
    Since this query is in a stored procedure being called from the web app, the QA team wants quicker response. Current PROD is faster.
    The tables have same indexes, etc and contain identical data as that in PROD (were refreshed from PROD yesterday).
    What else can I check?
    Best regards

  • Create a user that can only access to one schema - please help!!

    Hi all,
    I want to create one user in a Oracle DB that can only access to one schema. I did the following:
    CREATE USER "TEST" PROFILE "DEFAULT"
    IDENTIFIED BY "test" DEFAULT TABLESPACE "USERS"
    TEMPORARY TABLESPACE "TEMP"
    ACCOUNT UNLOCK;
    GRANT SELECT ON "TESTDTA"."F0007" TO "TEST"
    GRANT "CONNECT" TO "TEST";
    I have done a test and the user TEST can access all schemas, when I only gave explicit permissions to the schema TESTDTA.
    Any suggestion/clarification???
    Many thanks in advance.
    Víctor.

    Hello Andreas and Pavan,
    I have launched the query:
    select * from dba_tab_privs
    where grantee = 'PUBLIC'
    and owner = 'PRODDTA'
    and table_name= 'F0009';
    And the result:
    GRANTEE OWNER TABLE_NAME GRANTOR PRIVILEGE GRA HIE
    PUBLIC PRODDTA F0009 PRODDTA ALTER NO NO
    PUBLIC PRODDTA F0009 PRODDTA DELETE NO NO
    PUBLIC PRODDTA F0009 PRODDTA INDEX NO NO
    PUBLIC PRODDTA F0009 PRODDTA INSERT NO NO
    PUBLIC PRODDTA F0009 PRODDTA SELECT NO NO
    PUBLIC PRODDTA F0009 PRODDTA UPDATE NO NO
    PUBLIC PRODDTA F0009 PRODDTA REFERENCES NO NO
    PUBLIC PRODDTA F0009 PRODDTA ON COMMIT REFRESH NO NO
    PUBLIC PRODDTA F0009 PRODDTA QUERY REWRITE NO NO
    PUBLIC PRODDTA F0009 PRODDTA DEBUG NO NO
    PUBLIC PRODDTA F0009 PRODDTA FLASHBACK NO NO
    11 rows selected.
    Then I supose that I have to change the value on column GARANTEE. How can I do that?
    Thanks a lot for your help!!
    Víctor.

  • Delete query is taking too much time...

    Hi All,
    Below delete query is taking at least 1hrs. !!!!
    DELETE aux_current_link aux
    WHERE EXISTS (
    SELECT *
    FROM link_trans_cons link2
    WHERE aux.tr_leu_id = link2.tr_leu_id
    AND aux.kind_of_link = link2.kind_of_link
    AND link2.TYPE = 'H');
    table aux_current_link has record - 284279 and has 6 normal index.
    pls help me.
    Subir

    Not even close to enough information.
    Look here to see if you can tune the operation.
    When your query takes too long ...
    But for a delete you need to understand that the indexes need to be maintained, you have 6 of them, that requires effort. ALSO, foreign keys need to be checked to make sure you don't violate any enabled foreign keys (so maybe you need an index on a table where a column from this table you deleting from is being referenced).
    If you are deleting a HIGH percentage of the table you may be better off doing a create table as select ....query to keep all rows from your table....then drop your current table, rename the new one you made, and add all the indexes to it.
    Otherwise, once you've tuned the operation (query), assuming it can be tuned, it's going to take as long as it needs to take.....
    Message was edited by:
    Tubby

  • Delete query taking too much time

    Hi All,
    my delete query is taking too much time. around 1hr 30 min for 1.5 lac records.
    Though I have dropped mv log on the table & disabled all the triggers on it.
    Moreover deletion is based on primary key .
    delete from table_name where primary_key in (values)
    above is dummy format of my query.
    can anyone please tell me what could be other reason that query is performing that slow.
    Is there anything to check in DB other than triggers,mv log,constraints in order to improve the performance?
    Please reply asap.

    Delete is the most time consuming operation, as the whole record data has to be stored at the undo segments. On the other hand, there is a part of the query used to select records to delete that probably is adding an extra overhead to the process, the in (values) clause. It would be nice on your side to post another dummy from this (values) clause. I could figure out this is a subquery, and in order for you to obtain this list you have to run a inefficient query.
    You can gather the execution plan so you can see where the most heavy part of th query is. This way a better tuning approach and a more accurate diagnostic can be issued.
    ~ Madrid.

  • Why is the query so slow?

    Hi,
    I've got a query running fast (3 sec.)
    If I try to execute it on test enviroment, it takes about 2 minutes (!)
    I see in both enviroments the explain plan is the same and so are the indexes used. I've also tried to rebuild the indexes and the tables that looked quite fragmented in test, but the result is always the same. Could it be that our test enviroment is slower and with lower performances? What else could I check? (Oracle Vers. is 8.1.7)
    Thanks!

    812809 wrote:
    steps to follow:
    1.whether the candidate columns has index or notSometimes and index can cause a query to slow down rather than speed up, especially if a person has created too many indexes on a table and the optimiser can't figure out the best one to use.
    2.go for explain plan and look the query not to fall under the category of Full Table ScanFull table scans are not always a bad thing. Sometimes they are faster than using the index. It depends.

  • Query Performance - Query very slow to run

    I have built a query to show payroll costings per month per employee by cost centres for the current fiscal year. The cost centres are selected with a hierarchy variable - it's quite a latrge hierarchy. The problem is the query takes ages to run - nearly ten minutes. It's built on a DSO so I cant aggregate it. Is there anything I can do to improve performance.

    Hi Joel,
    Walkthrough Checklist for Query Performance:
    1. If exclusions exist, make sure they exist in the global filter area. Try to remove exclusions by subtracting out inclusions.
    2. Use Constant Selection to ignore filters in order to move more filters to the global filter area. (Use ABAPer to test and validate that this ensures better code)
    3. Within structures, make sure the filter order exists with the highest level filter first.
    4. Check code for all exit variables used in a report.
    5. Move Time restrictions to a global filter whenever possible.
    6. Within structures, use user exit variables to calculate things like QTD, YTD. This should generate better code than using overlapping restrictions to achieve the same thing. (Use ABAPer to test and validate that this ensures better code).
    7. When queries are written on multiproviders, restrict to InfoProvider in global filter whenever possible. MultiProvider (MultiCube) queries require additional database table joins to read data compared to those queries against standard InfoCubes (InfoProviders), and you should therefore hardcode the infoprovider in the global filter whenever possible to eliminate this problem.
    8. Move all global calculated and restricted key figures to local as to analyze any filters that can be removed and moved to the global definition in a query. Then you can change the calculated key figure and go back to utilizing the global calculated key figure if desired
    9. If Alternative UOM solution is used, turn off query cache.
    10. Set read mode of query based on static or dynamic. Reading data during navigation minimizes the impact on the R/3 database and application server resources because only data that the user requires will be retrieved. For queries involving large hierarchies with many nodes, it would be wise to select Read data during navigation and when expanding the hierarchy option to avoid reading data for the hierarchy nodes that are not expanded. Reserve the Read all data mode for special queriesu2014for instance, when a majority of the users need a given query to slice and dice against all dimensions, or when the data is needed for data mining. This mode places heavy demand on database and memory resources and might impact other SAP BW processes and tasks.
    11. Turn off formatting and results rows to minimize Frontend time whenever possible.
    12. Check for nested hierarchies. Always a bad idea.
    13. If "Display as hierarchy" is being used, look for other options to remove it to increase performance.
    14. Use Constant Selection instead of SUMCT and SUMGT within formulas.
    15. Do review of order of restrictions in formulas. Do as many restrictions as you can before calculations. Try to avoid calculations before restrictions.
    16. Check Sequential vs Parallel read on Multiproviders.
    17. Turn off warning messages on queries.
    18. Check to see if performance improves by removing text display (Use ABAPer to test and validate that this ensures better code).
    19. Check to see where currency conversions are happening if they are used.
    20. Check aggregation and exception aggregation on calculated key figures. Before aggregation is generally slower and should not be used unless explicitly needed.
    21. Avoid Cell Editor use if at all possible.
    22. Make sure queries are regenerated in production using RSRT after changes to statistics, consistency changes, or aggregates.
    23. Within the free characteristics, filter on the least granular objects first and make sure those come first in the order.
    24. Leverage characteristics or navigational attributes rather than hierarchies. Using a hierarchy requires reading temporary hierarchy tables and creates additional overhead compared to characteristics and navigational attributes. Therefore, characteristics or navigational attributes result in significantly better query performance than hierarchies, especially as the size of the hierarchy (e.g., the number of nodes and levels) and the complexity of the selection criteria increase.
    25. If hierarchies are used, minimize the number of nodes to include in the query results. Including all nodes in the query results (even the ones that are not needed or blank) slows down the query processing. The u201Cnot assignedu201D nodes in the hierarchy should be filtered out, and you should use a variable to reduce the number of hierarchy nodes selected.
    Regards
    Vivek Tripathi

  • How restore the deleted Query in SAP BI

    Hi Experts,
    I deleted one Bex query unexpectedly, in that i haa lot of definations, Now i want restore the that query is there any possibulity to restore deleted query 
    Thanks,
    Chandra

    Hi Chandra
    Request your BASIS team to restore the system from its last backup.  Suppose. you have deleted the query at around 2 PM, then ask basis guys to restore the system upto a time before 2 PM, lets say 1:30 PM.
    Regards
    Anindya

  • Deletion Query takes too long

    I have two tables with exactly the same structure. The table 1 gets data and one procedure reads that data and inserts them into another table (table2) for processing them. I have a delete query which is taking too long to execute.
    The query is as follows
    delete
    from events.temp_act a
    where a.chess_ts < (select max(chess_ts) from events.temp_act b
    where a.db_type = b.db_type
    and a.order_no = b.order_no
    and a.acv_no = b.acv_no
    There is a composite index in this table which is (db_type,order_no,acv_no)
    In my procedure, I drop and create the index for faster processing and also analyze the index.
    The above deletion query approximately deletes half the number of total records.
    There is no primary key in the table for the reason that there can be no unique record identifier.
    The query takes nearly 2 hours for deleting about 1100000 records.
    Is there a way to make this query run faster?

    What is the explain plan for this statement? Is the index even being used?
    Is the table analyzed as well as the index?
    Dropping/re-creating the index - not likely to help. I would leave this out.
    Have you tried other variations, like:
    delete
      from events.temp_act
    where (db_type, order_no, acv_vo, chess_ts)
           not in (select db_type, order_no, acv_vo, max(chess_ts)
                     from events.temp_act b
                    group by db_type, order_no, acv_vo);

Maybe you are looking for

  • From Blackberry to iphone 3gs

    I need some help. I am going from a Blackberry Curve 8300 to an iphone and I can't wait to get/use the iphone. I need to tranfer all my contacts to the iphone. What is the best way to do this? I don't have Outlook. My Blackberry currently backs up to

  • Where can i get objective-c training from apple in india?

    I am from India and I would like to get training in Objective-C from apple itself. Is there an option to get it in India? I am new to experience Apple Hardware & Software. I have knowledge of C & Java Programming languages. I am in college now in und

  • MRP Not Running on Subcontracting Material

    Hi All, I have done the following :- Created a SUBCON Component with all the correct views, procurement type 30 etc. Created a RAW Material again with all the correct views. Created a BOM for the Above. Created Subcont PIR for SUBCON Material Created

  • Embedding iChat into Web Page

    Hello, Is there any way to embed the ichat 'buddy list' into a web page? Gary

  • Mac Multimedia Transfer app not working with N95 8...

    I'm using the latest 1.2 version of the Multimedia Transfer app, but it does not recognize the phone via bluetooth nor USB. When trying to setup a device in the Multimedia Transfer app I see my phone listed in the device list, but it's grayed-out and