Can we optimize the query  :  It is taking a lot of time

the following query is taking a lot of time ...
Can anyone suggest to make it run faster ???
table B has 12 million records
table a has 10000 records
CREATE TABLE less_time
     PARALLEL
     NOLOGGING
     AS
     SELECT a.user_id,a.mp_id, COUNT(product_id) product _count
     FROM table a,table b
     WHERE TRUNC(a.call_time) < TRUNC(SYSDATE) - 1
     AND a.history_id = b.call_id
     AND b.product_type = 1
     AND b..product_status= 50
     AND user_id IS NOT NULL
     GROUP BY user_id,mp_id;

analyze index indx_mtx compute statistics
thanks for explaining David ...
Actually I somewhat bettered it
i made a consolidated index on table b
like create index indx_ty on table b (call_id,mp_id,user_id,b.product_type,product_status)
now the explain plan shows that the query is much much faster also i did one trick in the query
SELECT a.user_id,a.mp_id, COUNT(product_id) product _count
i changed to SELECT a.user_id,a.mp_id, COUNT(1) product _count
to enable it to do FFS
thanks anyways ....

Similar Messages

  • Concurrent request is taking a lots of time to run

    Hi,
    I have one query regarding ICM.
    one of the concurrent request is taking a lots of time to run. How can I solve the issue.
    Is there any steps to diagnose this issue?
    Please reply.
    Regards,
    Manish

    Hi,
    How we can find that particular request are taking long time?See your other thread.
    Concurrent request taking long time
    Concurrent request taking long time
    what is "gather statistrics schema" concurent program and what it does?See (Note: 419728.1 - How To Gather Statistics On Oracle Applications 11.5.10(and above) - Concurrent Process,Temp Tables, Manually).
    Regards,
    Hussein

  • Help needed to optimize the query

    Help needed to optimize the query:
    The requirement is to select the record with max eff_date from HIST_TBL and that max eff_date should be > = '01-Jan-2007'.
    This is having high cost and taking around 15mins to execute.
    Can anyone help to fine-tune this??
       SELECT c.H_SEC,
                    c.S_PAID,
                    c.H_PAID,
                    table_c.EFF_DATE
       FROM    MTCH_TBL c
                    LEFT OUTER JOIN
                       (SELECT b.SEC_ALIAS,
                               b.EFF_DATE,
                               b.INSTANCE
                          FROM HIST_TBL b
                         WHERE b.EFF_DATE =
                                  (SELECT MAX (b2.EFF_DATE)
                                     FROM HIST_TBL b2
                                    WHERE b.SEC_ALIAS = b2.SEC_ALIAS
                                          AND b.INSTANCE =
                                                 b2.INSTANCE
                                          AND b2.EFF_DATE >= '01-Jan-2007')
                               OR b.EFF_DATE IS NULL) table_c
                    ON  table_c.SEC_ALIAS=c.H_SEC
                       AND table_c.INSTANCE = 100;

    To start with, I would avoid scanning HIST_TBL twice.
    Try this
    select c.h_sec
         , c.s_paid
         , c.h_paid
         , table_c.eff_date
      from mtch_tbl c
      left
      join (
              select sec_alias
                   , eff_date
                   , instance
                from (
                        select sec_alias
                             , eff_date
                             , instance
                             , max(eff_date) over(partition by sec_alias, instance) max_eff_date
                          from hist_tbl b
                         where eff_date >= to_date('01-jan-2007', 'dd-mon-yyyy')
                            or eff_date is null
               where eff_date = max_eff_date
                  or eff_date is null
           ) table_c
        on table_c.sec_alias = c.h_sec
       and table_c.instance  = 100;

  • Can users see the query plan of a SQL query in Oracle?

    Hi,
    I wonder for a given sql query, after the system optimization, can I see the query plan in oracle? If yes, how to do that? thank you.
    Xing

    You can use explain plan in SQLPlus
    SQL>  explain plan for select * from user_tables;
    Explained.
    Elapsed: 00:00:01.63
    SQL> select * from table(dbms_xplan.display());
    PLAN_TABLE_OUTPUT
    Plan hash value: 806004009
    | Id  | Operation                       | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                |          |  2014 |  1123K|   507   (6)| 00:00:07 |
    |*  1 |  HASH JOIN RIGHT OUTER          |          |  2014 |  1123K|   507   (6)| 00:00:07 |
    |   2 |   TABLE ACCESS FULL             | SEG$     |  4809 |   206K|    34   (3)| 00:00:01 |
    |*  3 |   HASH JOIN RIGHT OUTER         |          |  1697 |   873K|   472   (6)| 00:00:06 |
    |   4 |    TABLE ACCESS FULL            | USER$    |    74 |  1036 |     3   (0)| 00:00:01 |
    |*  5 |    HASH JOIN OUTER              |          |  1697 |   850K|   468   (6)| 00:00:06 |
    |   6 |     NESTED LOOPS OUTER          |          |  1697 |   836K|   315   (6)| 00:00:04 |
    |*  7 |      HASH JOIN                  |          |  1697 |   787K|   226   (8)| 00:00:03 |
    |   8 |       TABLE ACCESS FULL         | TS$      |    13 |   221 |     5   (0)| 00:00:01 |
    |   9 |       NESTED LOOPS              |          |  1697 |   759K|   221   (8)| 00:00:03 |
    |  10 |        MERGE JOIN CARTESIAN     |          |  1697 |   599K|   162  (10)| 00:00:02 |
    |* 11 |         HASH JOIN               |          |     1 |   326 |     1 (100)| 00:00:01 |
    |* 12 |          FIXED TABLE FULL       | X$KSPPI  |     1 |    55 |     0   (0)| 00:00:01 |
    |  13 |          FIXED TABLE FULL       | X$KSPPCV |   100 | 27100 |     0   (0)| 00:00:01 |
    |  14 |         BUFFER SORT             |          |  1697 | 61092 |   162  (10)| 00:00:02 |
    |* 15 |          TABLE ACCESS FULL      | OBJ$     |  1697 | 61092 |   161  (10)| 00:00:02 |
    |* 16 |        TABLE ACCESS CLUSTER     | TAB$     |     1 |    96 |     1   (0)| 00:00:01 |
    |* 17 |         INDEX UNIQUE SCAN       | I_OBJ#   |     1 |       |     0   (0)| 00:00:01 |
    |  18 |      TABLE ACCESS BY INDEX ROWID| OBJ$     |     1 |    30 |     1   (0)| 00:00:01 |
    |* 19 |       INDEX UNIQUE SCAN         | I_OBJ1   |     1 |       |     0   (0)| 00:00:01 |
    |  20 |     TABLE ACCESS FULL           | OBJ$     | 52728 |   411K|   151   (4)| 00:00:02 |
    Predicate Information (identified by operation id):
       1 - access("T"."FILE#"="S"."FILE#"(+) AND "T"."BLOCK#"="S"."BLOCK#"(+) AND
                  "T"."TS#"="S"."TS#"(+))
       3 - access("CX"."OWNER#"="CU"."USER#"(+))
       5 - access("T"."DATAOBJ#"="CX"."OBJ#"(+))
       7 - access("T"."TS#"="TS"."TS#")
      11 - access("KSPPI"."INDX"="KSPPCV"."INDX")
      12 - filter("KSPPI"."KSPPINM"='_dml_monitoring_enabled')
      15 - filter("O"."OWNER#"=USERENV('SCHEMAID') AND BITAND("O"."FLAGS",128)=0)
      16 - filter(BITAND("T"."PROPERTY",1)=0)
      17 - access("O"."OBJ#"="T"."OBJ#")
      19 - access("T"."BOBJ#"="CO"."OBJ#"(+))
    42 rows selected.
    Elapsed: 00:00:03.61
    SQL> If your plan table does not exist, execute the script $ORACLE_HOME/RDBMS/ADMIN/utlxplan.sql to create the table.

  • Can anyone tell me how can i optimize this query...

    Can anyone tell me how can i optimize this query ??? :
    Select Distinct eopersona.numident From rscompeten , rscompet , rscv , eopersona , rscurso , rseduca , rsexplab , rsinteres
    Where ( ( (LOWER (rscompeten.nombre LIKE '%caracas%') AND ( rscompeten.id = rscompet.idcompeten ) AND ( rscv.id = rscompet.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscurso.nombre) LIKE '%caracas%') AND ( rscv.id = rscurso.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscurso.lugar) LIKE '%caracas%') AND ( rscv.id = rscurso.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rseduca.univinst) LIKE '%caracas%)' AND ( rscv.id = rseduca.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rsexplab.nombempre) LIKE '%caracas%' AND ( rscv.id = rsexplab.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rsinteres.descrip) LIKE '%caracas%' AND ( rscv.id = rsinteres.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscv.cargoasp) LIKE '%caracas%' AND ( eopersona.id = rscv.idpersona ) )
    OR ( LOWER (eopersona.ciudad) LIKE '%caracas%' AND ( eopersona.id = rscv.idpersona )
    PLEASE IF YOU FIND SOMETHING WRONG.. PLEASE HELP ME.. this query takes me aproximatelly 10 minutes and the database is really small ( with only 200 records on each table )

    You are querying eight tables, however in any of your OR predicates you're only restricting 3 or 4 of those tables. That means that the remaining 4 or 5 tables are generating cartesian products. (n.b. the cartesian product of 5 tables with 200 rows each results in g 200^5 = 320,000,000,000 rows) Then you casually hide this behind "distinct".
    A simple restatement of your requirements looks like this:
    Select eopersona.numident
      From rscompeten,
           rscompet,
           rscv,
           eopersona
    Where LOWER (rscompeten.nombre) LIKE '%caracas%'
       AND rscompeten.id = rscompet.idcompeten
       AND rscv.id = rscompet.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    Select eopersona.numident
      From rscurso ,
           rscv,
           eopersona
    Where LOWER (rscurso.nombre) LIKE '%caracas%'
       AND rscv.id = rscurso.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    Select eopersona.numident
      From rscurso ,
           rscv,
           eopersona
    Where LOWER (rscurso.lugar) LIKE '%caracas%'
       AND rscv.id = rscurso.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    ...From there you can eliminate redundancies as desired, but I imagine that the above will perform admirably with the data volumes you describe.

  • In ST03 , how can i see the Query name, user id,how many times executed the

    HI Experts,
    In ST03 , how can i see the Query name, user id,how many times executed the query.
    these details how do i get from the above transaction.
    EX:-if there is one report name X,I want to know how many users had executed X report today,weekly,monthly.
    ex:-query userid total number of execution
    sales order 0000555 5 times
    custmer 05855 2 times
    fast reply will be appreciated,

    Hi,
    Look here:
    http://help.sap.com/saphelp_nw04/helpdata/en/3b/54df4204892a78e10000000a155106/frameset.htm
    Also check these:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/2d/b8be3befaefc75e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/25/ece73a39e74d27e10000000a114084/frameset.htm
    Hope this helps..
    Bye
    Dinesh

  • In ST03 , how can i see the Query name, user id,how many times .

    HI Experts,
    In ST03 , how can i see the Query name, user id,how many times executed the query.
    these details how do i get from the above transaction.
    Points will be awarded.
    BR
    sivs

    Hi Siva,
    Reporting statistics data is only written to the database table if BW statistics have been manually activated for the corresponding InfoProvider first. If this has not been done, it is therefore not possible to display any reporting statistics in transaction ST03.
    Therefore activate the reporting statistics for all relevant InfoProviders. To do this, set the OLAP flag in the BW Administrator Workbench (transaction RSA1) in the area Tools ® BW Statistics for InfoProvider.
                    Check here...........
    http://help.sap.com/saphelp_nw04/helpdata/en/ca/86df4254d81e1fe10000000a155106/content.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c8c4d794-0501-0010-a693-918a17e663cc
    Hope this will help you shiva.........
    Regrads,
    Vijay

  • While Rollup is goingon Can we execute the query

    Hello All
    We have a cube and aggregates built on this cube and daily in my Process chain we have step Rollup.
    Now while Rollup is goingon Can we execute the query which is builut on the same cube? Will the cube will be locked?
    Can we excute query while load is goingon to this cube?
    Regards
    Balji

    Hi Balaji,
    You can execute a query when the roll up is going on. The new data is available to the report only when the rollup is complete, but this will not create locks.
    Hope this helps...

  • Consistent gets are reduced by 50% but the query is still taking the same t

    Hi ,
    I am tuning a query in DWH env using a WITH clause .Doing that my consistent gets are reduced by 50% but the elapsed time in increased.
    In that one 40000 rows are coming from WITH clause and joined with a table having 250000000 rows joined through Hash join.
    can anybody help me out in this issue.
    Thanx
    Nitin

    NitinMishra wrote:
    Hi ,
    I am tuning a query in DWH env using a WITH clause .Doing that my consistent gets are reduced by 50% but the elapsed time in increased.Unusual! Normally time goes, down when system resources do - but not always as you are seeing :(. Last time I saw something like this the reads had gone down but the CPU usage had gone up. You can get CPU usage from V$SQL.
    Can you post the query, the execution plan, and statistics - both before and after the tuning?

  • How can we optimize the LIKE '%...%' to make it work more efficiently

    how can we optimize the LIKE '%...%' to make it work more efficiently

    SQL> create table test as select * from V$SQL
    Table created.
    SQL> create index test_txt_idx on test(sql_fulltext) indextype is ctxsys.context
    Index created.
    SQL> select substr(sql_fulltext,1,30) sql_fulltext from test where contains(sql_fulltext, 'dataobj#') > 0
    SQL_FULLTEXT                                               
    select obj#, dataobj#, part#,                              
    select /*+ index_ss(obj$ i_obj                             
    select /*+ index_ss(obj$ i_obj                             
    select /*+ index_ss(obj$ i_obj                             
    select /*+ index_ss(obj$ i_obj                             
    select /*+ index_ss(obj$ i_obj                             
    delete from sys.cache_stats_1$                             
    select substr(sql_fulltext,1,3                             
    insert into wrh$_seg_stat   (s                             
    insert into obj$(owner#,name,n                             
    update /*+ index_ss(obj$ i_obj                             
    update /*+ index_ss(obj$ i_obj                             
    select i.obj#,i.ts#,i.file#,i.                             
    select i.obj#,i.ts#,i.file#,i.                             
    select i.obj#,i.ts#,i.file#,i.                             
    update wrh$_seg_stat_obj sso                               
    select obj#, dataobj#, part#,                              
    select obj#, dataobj#, part#,                              
    insert into tabpart$ (obj#, da                             
    update ind$ set ts#=:2,file#=:                             
    update ind$ set ts#=:2,file#=:                             
    insert into tab$(obj#,ts#,file                             
    select i.obj#,i.ts#,i.file#,i.                             
    select i.obj#,i.ts#,i.file#,i.                             
    select i.obj#,i.ts#,i.file#,i.                             
    select i.obj#,i.ts#,i.file#,i.                             
    select i.obj#,i.ts#,i.file#,i.                             
    select i.obj#,i.ts#,i.file#,i.                             
    select i.obj#,i.ts#,i.file#,i.                             
    update tabpart$ set dataobj# =                             
    insert into ind$(bo#,obj#,ts#,                             
    update tab$ set ts#=:2,file#=:                             
    update tab$ set ts#=:2,file#=:                             
    update /*+ index_ss(obj$ i_obj                             
    insert into indpart$ (obj#, da                             
    35 rows selected.
    SQL> drop table test
    Table dropped.What are you doing differently?

  • Is there a limit for the apps that i purchased or i can purchase as much i want? and how can i know the capacity it's taking? Thank you

    Is there a limit for the apps that i purchased or i can purchase as much i want? and how can i know the capacity it's taking? Thank you

    Yes you can buy whatever you want if your credit card is in good standing.
    Before you buy, read the size of the download in iTunes/App/iBook Store.
    Rule of thumb, you need to reserve about 10% of your total space.

  • After I edited the SQL in a dataset, I can't use the query builder in any datasets that I create.

    Is there a way to reset BI Publisher Enterprise 11 so that I can use the query builder again instead of having to write out all of the SQL? I know that I can't use the query builder for the dataset that I edited the sql in but I would like to use the query builder for new datasets.
    Thanks,

    Hi J_Constantine,
    Welcome to the Apple Support Communities!
    I understand that your iPad is restarting and not responding sporadically. You have already attempted some great troubleshooting steps and I think you are on the right track. Holding the home button is one step that you take while placing your device in recovery mode to restore. This is the method that I would suggest to restore. For complete information on how to place your device into recovery mode, please reference the attached article. 
    If you can't update or restore your iPhone, iPad, or iPod touch - Apple Support
    Best regards,
    Joe

  • Can anyone share the query for inventory aging report

    Is there any standard reports for inventory aging in oracle ebs 12.1.3 ....... If not can anyone share the query for inventory aging report

    Hi,
    It may not be so simple as you are trying to reproduce the historical value.  I believe you have to create a temporary table first.  Or you may use Command feather to get the required data in advance.
    Thanks,
    Gordon

  • Simple select query is taking a lot of time

    hi gems...
    my table has 7267563 rows...and i am doing a simple select * from table;
    but it is taking a lot of time nearly 25minutes but not completed...
    when i did select count(1) from table then it gave the result instantly also select * from table where rownum < 10 is also fine...even when i am selecting all the records using rownum i.e. select * from table where rownum < 7267563 is also giving result instantly...
    but the entire table is not getting result i.e. select * from table...also there is no lock in the table(though i know that select is nothing to do with lock)..
    what may be the issue..please suggest...thanks in advance...
    Edited by: user12780416 on Dec 12, 2011 11:08 PM

    Hi;
    Please see below thread
    query takes too long ...
    help in solving long run query
    HOW TO: Post a SQL statement tuning request - template posting
    Hope it helps
    Regard
    Helios

  • My Ideapad N581 is taking a lot of time to start up ....Can experts help?

    My laptop is taking a lot of time to start up.It just shows the Lenovo screen and stops there.What could be the problem?
    Thanksin advance.

    hi mamuninayak,
    The system might be experiencing a boot or a POST issue.
    - Remove all USB devices.
    - Remove the AC adapter and battery then held down the power button for 15 sec.
               Reconnect just the AC and try.
    -See if BIOS can be reset.
             Start hiting F2 when while powering the system on.
                     If succesfull in booting into BIOS. Hit F9 the F10
    Try Removing the Harddrive and turn the system on, See if there will be any changes.
    Hope this helps
    Cheers!
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

Maybe you are looking for