Tuning based on joins

Hi,
I am having the joins like the following, it takes more time to give the result,
if i rearrange this joins will it give good performance for my query.
FROM EMP40_DETLICANT A INNER JOIN WF_RESOURCE_ENTITLE_MST B
     ON A.DETLICANT_ID = B.DETLICANT_ID INNER JOIN WF_PROCESS_TXN D
     ON A.DETLICANT_ID = D.DETLICANT_ID AND B.STAGE_ID = D.STAGE_ID LEFT JOIN DE_DETLICANT C
     ON A.DETLICANT_ID = C.DETLICANT_ID LEFT JOIN EMP10_DETLICATION E ON A.DETLICATION_ID=E.DETLICATION_ID
     LEFT JOIN EMP30_DETPRODUCTS DETPRODS ON DETPRODS.DETLICATION_ID=E.DETLICATION_ID
     AND DETPRODS.DETLICANT_ID = B.DETLICANT_ID LEFT JOIN EMP20_DETIMAGES F ON A.DETLICATION_ID=F.DETLICATION_ID
     AND TRIM(F.IMAGE_CLASSIFICATION_TYPE) = 'NA' INNER JOIN PA_PARAM_MST G ON G.CRITERIA4 = D.STAGE_STATUS) B)
     WHERE RNUM BETWEEN 1 AND 100;
Please advice
siva

And here is more readable (for me ;) ) version of your query.
SELECT *
FROM (
     SELECT B.*, ROWNUM RNUM
      FROM (
          SELECT DISTINCT B.DETLICANT_ID, A.DETLICATION_ID, A.FIRST_NAME, A.SURNAME,
               (SELECT STAGE_NAME
                 FROM WF_STAGE_MST
                 WHERE STAGE_ID = B.STAGE_ID
                  AND RECORD_STATUS='O') AS STAGE_NAME,
               B.WF_REFERENCE_NO, D.EXT_CALL_ID EXTERNALCALLTXNID, B.STAGE_ID,
               B.PATH_ID, B.TRANSITION_NO, C.IR_DETLICATION_ID, D.TRANSITION_STATE,
               D.FUNC_GROUP, E.PRIORITY_FLAG, G.CRITERIA2 STAGESTATUSDESCRIPTION,                E.DET_SOURCE_CODE, DETPRODS.PRODUCT_TYPE, F.IMAGE_ID,
               TO_CHAR(IN_TIME,'DD-MM-YYYY HH24:MM') IN_TIME,
               (SELECT
                 NVL(LTRIM(SUBSTR((SYSDATE - IN_TIME),8,3),0),0)||'D : '||
                 NVL(LTRIM(SUBSTR((SYSDATE - IN_TIME),12,2),0),0)||'H : '||
                 NVL(LTRIM(SUBSTR((SYSDATE - IN_TIME),15,2),0),0)||'M'
               FROM DUAL) AS AGE,
               D.RESOURCE_ID, D.RESOURCE_ID_OUT RESOURCEIDOUT, B.ASSIGNED_TO AS ASSIGNEDTO,
               (SELECT TO_TIMESTAMP(SYSDATE,'DD-MON-YY HH.MI.SS.FF9 AM') - IN_TIME FROM DUAL) AS DATEAGE,
                    A.DETLICANT_TYPE AS DETLICANT_TYPE, IN_TIME IN_TIME_FOR_SORTING,
                    (CASE
                         WHEN 1164474214516 < B.ET_NORMAL THEN 'N'
                         WHEN 1164474214516 < B.ET_WARNING THEN 'W'
                         ELSE 'E' END
                    ) AS SLA_STATUS
                FROM EMP40_DETLICANT A INNER JOIN WF_RESOURCE_ENTITLE_MST B ON A.DETLICANT_ID = B.DETLICANT_ID
                    INNER JOIN WF_PROCESS_TXN D ON A.DETLICANT_ID = D.DETLICANT_ID AND B.STAGE_ID = D.STAGE_ID                          LEFT JOIN DE_DETLICANT C  ON A.DETLICANT_ID = C.DETLICANT_ID
                    LEFT JOIN EMP10_DETLICATION E ON A.DETLICATION_ID = E.DETLICATION_ID
                    LEFT JOIN EMP30_DETPRODUCTS DETPRODS ON DETPRODS.DETLICATION_ID = E.DETLICATION_ID
                         AND DETPRODS.DETLICANT_ID = B.DETLICANT_ID
                    LEFT JOIN EMP20_DETIMAGES F ON A.DETLICATION_ID=F.DETLICATION_ID
                         AND TRIM(F.IMAGE_CLASSIFICATION_TYPE) = 'NA'
                    INNER JOIN PA_PARAM_MST G ON G.CRITERIA4 = D.STAGE_STATUS
               ) B
WHERE RNUM BETWEEN 1 AND 100;Peter D.

Similar Messages

  • Creating a simple ALV report based on join condition

    Dear All
    SAP Version: ECC6 EHP7
    I wan to create simple ALV report based on join condition. can anyone provide me the complete steps to create this report.
    Regards,

    Hi Syed,
    Please check the link,
    ALV report - Joining 2 tables
    Regards,
    Prakash.

  • Partition based on join in data warehouse env.

    Hi,
    I am working on DW environment and am quite new to it.
    The scenario is like there are 2 fact tables and one dimension table.
    Now I need to partition both the fact tables based on the dates in Dim table. My problem is there is no date mentioned in fact table other then Surogate keys in fact tables.
    Is it possible to partition the table by using join condition between fact table and Dim table and if yes how?
    The structure of tables are as follows.
    Please help!
    Daily sales fact table
    planned shipment date sk     NUMBER     PK1, FK1
    source system identifier     VARCHAR2(50)     PK2
    sales type indicators sk     NUMBER     PK3, FK3
    ship-to-customer sk     NUMBER     PK4, FK4
    product sk     NUMBER     PK5, FK5
    ship-from-location sk     NUMBER     PK6, FK6
    quantity in primary units     NUMBER(14,3)     
    quantity in 9LE     NUMBER(14,3)     
    Daily Sales Order Fact
    sales invoiced date sk     NUMBER     PK1, FK1
    source system identifier     VARCHAR2(50)     PK2
    sales type indicators sk     NUMBER     PK3, FK3
    ship-to-customer sk     NUMBER     PK4, FK4
    product sk     NUMBER     PK5, FK5
    ship-from-location sk     NUMBER     PK6, FK6
    quantity in primary units     NUMBER(14,3)     
    quantity in 9LE     NUMBER(14,3)     
    Sales order month Dim
    sales order month sk     NUMBER     PK1
    sales order month full name     VARCHAR2(50)     
    sales order month number     NUMBER(2)     
    sales order month calendar year     NUMBER(4)     
    sales order month financial year     NUMBER(4)     
    sales order month start date     DATE     AK1
    sales order month end date     DATE     
    sales order month end date sk     NUMBER     
    days in sales order month     NUMBER(2)     
    event number     NUMBER(12)     
    last update date     DATE     
    Thanks in advance.

    If you take care that the synthetic key values for you date are assigned in ascending order with the date value then you can range equi-partition by range on both of them without too much trouble.
    Personally I don't use synthetic values as PK's on dates, partly for this very reason.

  • Select query based on joining of tables from different database is taking too long

    Hi Team,
    Select query on table with millions of records is taking very long time. It took 50mins, the below query is joining on multiple table from two databases DB1.dbo.Table1 contains 100 million records and also Table3 and Table4 (of different database) might
    contain close to 1million records.
    Select T1.*
    From DB1.dbo.Table1 T1
    Join DB1.dbo.Table2 T2 on RTRIM(T1.Col3) = RTRIM(T2.Col3)
    Join Table4 CA on RTRIM(T1.Col1) + T2.Col2 = CA.Col1
    Join Table3 U on CA.Col2 = U.Col2 AND RTRIM(T2.Col2) = U.Col3
    Where U.Col4 NOT IN ('A1', 'A2', 'A3', 'A4', 'A5', 'A6','A7','A8','A9')
    And (T1.flg IS NULL OR T1.flg = 'N')
    And LTRIM(RTRIM(T2.Col2)) NOT IN ('B1','B2')
    How can i improve the performance of this query. Actual thing is update the data in Db1.dbo.table1 based on the conditions but if the select is taking close to 1hr then update will take hours together. Indexes already implemented on all the tables.
    Thanks,
    Eshwar.
    Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users.

    Thanks.
    Join Table4 CA on RTRIM(T1.Col1) + T2.Col2 = CA.Col1
    This join is not working with spaces if Rtrim is not used.
    Thanks! Eshwar.
    Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users.

  • Performance Tuning - remove hash join

    Hi Every one,
    Can some one help in tuning below query, i have hash join taking around 84%, 
    SELECT
    PlanId
    ,ReplacementPlanId
    FROM
    ( SELECT
    pl.PlanId
    ,xpl.PlanId ReplacementPlanId
    ,ROW_NUMBER() OVER(PARTITION BY pl.PlanId ORDER BY xpl.PlanId) RN
    FROM [dbo].[Plan] pl
    JOIN [dbo].[Plan] xpl
    ON pl.PPlanId = xpl.PPlanId
    AND pl.Name = xpl.Name
    WHERE
    pl.SDate > (CONVERT(CHAR(10),DATEADD(M,-12,GETDATE()),120)) AND
    xpl.Live = 1
    AND pl.TypeId = 7
    AND xpl.TypeId = 7
    ) p
    WHERE RN = 1
    Thanks in advance

    Can you show an execution plan of the query? Is that possible to rewrite the query as 
    Sorry cannot test it right now
    SELECT
    PlanId
    ,ReplacementPlanId
    FROM
    (SELECT PlanId,Name,SDate,TypeId FROM [dbo].[Plan]) pl
    CROSS APPLY 
     SELECT TOP (1) TypeId ,Live FROM [Plan] xpl
     WHERE  pl.PPlanId = xpl.PPlanId
    AND pl.Name = xpl.Name
    ) AS Der
    WHERE pl.SDate > (CONVERT(CHAR(10),DATEADD(M,-12,GETDATE()),120)) AND  
    Der.Live = 1
    AND pl.TypeId = 7
    AND Der.TypeId = 7
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Update row in a table based on join on multiple rows in another table

    I am using SQL Server 2005. I have the following update query which is not working as desired.
    UPDATE DocPlant
    SET DocHistory = DocHistory + CONVERT(VARCHAR(20), PA.ActionDate, 100) + ' - ' + PA.ActionLog + '. '
    FROM PlantDoc PD INNER JOIN PlantAction PA on PD.DocID = PA.DocID AND PD.PlantID = PA.PlantID 
    For each DocID and PlantID in PlantDoc table there are multiple rows in PlantAction table. I would like to concatenate ActionDate and ActionLog information into DocHistory column of DocPlant table. But the above update query is considering only one row from
    PlantAction table even though there are multiple rows that match with DocID and PlantID.
    DocHistory column is of type NVARCHAR(MAX).
    How do I fix my query to achieve what I want ? Thanks for the help.

    UPDATE DocPlant
    SET DocHistory = DocHistory + CONVERT(VARCHAR(20), PA.ActionDate, 100) + ' - ' + PA.ActionLog + '. '
    FROM PlantDoc PD INNER JOIN PlantAction PA on PD.DocID = PA.DocID AND PD.PlantID = PA.PlantID 
    We do not use the old Sybase UPDATE..FROM.. syntax. Google it and learn how it does not work. We do not use the old Sybase CONVERT() string function. You are still writing 1950's COBOL with string dates instead of temeproal data types. 
    You also did not post DDL, so we have to guess about everything. Does your boss make you work without DDL? How do you do it? 
    >> For each DocID and PlantID in PlantDoc table there are multiple rows in PlantAction [singular name?] table. I would like to concatenate ActionDate and ActionLog information into DocHistory column of DocPlant table. <<
    Why? What does this new data element mean? This is like dividing Thursday by Red and expecting a reasonable answer. Now, non-SQL programmers who are still writing COBOL will violate the tiered architecture rule about doing display formatting in the database.
    If you will follow forum rules, we can help you. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Query tuning - update with join statement

    Hi,
    I have 2 tables (table1 and table 2) with following condition:
    TABLE 1 - Need to selection a column say staus ! = 'C'
    join emp_id and project_id of TABLE1 and TABLE2
    From join I am selecting minimun and maximum of TABLE2.salary and updating TABLE3 respective column.
    Now as per requirement I have to update required column on TABLE2.EMP_ID = TABLE3.EMP_ID
    Following is the query I have written,
    update TABLE3 T3
    set (T3.MIN_salary, T3.MAX_salary) = (
    select min(c.salary), max(c.salary)
    from TABLE2 t2, TABLE1 t1
    where t2.emp_id = t1.emp_id
    and t2.project_id = t1.project_id
    and t1.status != 'C'
    and t2.emp_id = t3.emp_id)
    The above query takes 7 min to update some 8 lakhs records. Can you please suggest some other optimized method to do so?
    Thanks in advance
    Sandeep

    Hi SBH
    Required info for "Please provide oracle version, indexes on the 3 tables and also stats info for the table from user_tables"
    1) Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit
    2) Index is not there on TABLE3 (It is temporary table)
    Composite index on TABLE 1 - column1, column2 - Index name say table1index1
    Composite index on TABLE 2 - column1, column2 - Index name say table2index1
    TABLE_NAME     NUM_ROWS     BLOCKS     DEGREE     INSTANCES     SAMPLE_SIZE     PARTITIONED
    FXO_CFW     11767341     144930     1     1     11767341     NO
    FXO_RSL_STBL               1     1          NO
    FXO_TRN     4917778     230196     1     1     4917778     NO
    execution plan is:
    Execution Plan
    Plan hash value: 3131833900
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | UPDATE STATEMENT | | 789K| 23M| 2397 (3)| 00:00:29 |
    | 1 | UPDATE | TABLE3 | | | |
    | 2 | TABLE ACCESS FULL | TABLE3 | 789K| 23M| 2397 (3)| 00:00:29 |
    | 3 | SORT AGGREGATE | | 1 | 28 | | |
    | 4 | TABLE ACCESS BY INDEX ROWID | TABLE2 | 1 | 17 | 3 (0)| 00:00:01 |
    | 5 | NESTED LOOPS | | 1 | 28 | 12 (0)| 00:00:01 |
    |* 6 | TABLE ACCESS BY INDEX ROWID| TABLE1 | 1 | 11 | 9 (0)| 00:00:01 |
    |* 7 | INDEX RANGE SCAN | IDX_TABLE1INDEX1 | 6 | | 3 (0)| 00:00:01 |
    |* 8 | INDEX RANGE SCAN | IDX_TABLE2INDEX1 | 1 | | 2 (0)| 00:00:01 |
    Thanks for quick response,
    Sandeep

  • Creating Records Based on Joining record

    Hi Experts,
    I have an requirement
    Pernr | Begda| Endda| Wage1|Wage2|Join Date
    1

    >
    IFF wrote:
    > Hi Experts,
    >
    > I have an requirement
    >
    >
    > Pernr | Begda| Endda| Wage1|Wage2|Join Date
    > 1
    @ Fun
    It seems like the question bot encountered an "Program Terminated Dump" while posting the question. See log for further details

  • Ref cursor based on join or nested select is empty

    Hi ,
    We have a Stored procedure which returns 27 ref cursors.
    We are populating this data into a suitable data set using OracleDataAdapter (.fill).
    Refcursors that the data they hold is from a join or nested select are result empty.
    The other refcursors are fine.
    If running the stored procedure in the database (from another SP for instance) all refcursors are full of data.
    Can someone direct me for a solution or even working work around ?
    Thanks

    Hi Again ,
    No, The cursors are not any of group by with some aggregations of any sort. Just plain and simple joins or nested queries (Select... from ... where ... in (select ...). Some of the data is taken from temporary tables.
    For the last question i am using the production ODP with the last oraMTS.
    This problem is really stopping us from going to production in early march ....
    A possible work around we thought about (but cost dearly ...) is to fill the data from the tables into a temporary one and then base the cursor on a query on this table. This workaround can last only a few weeks at the customer.
    Regards

  • Column data restriction based on join condition

    All,
    SELECT e.ename,
      d.dname,
      e.job,
      e.comm, e.sal
    FROM emp e,
      dept d
    WHERE e.deptno=d.deptno
    AND e.empno   =7788
    AND e.comm   IS NOT NULL;
    In this query, if the comm for the empno=7788 is not null, then i am able to retrive the record, If comm is not null, display the entire record along with comm details, if it is null, display the entire record without comm value(may be as null).
    If commission is not null, then display the entire record, if it is null, then for e.comm, e.sal I want to display null values.
    PS: I am in a situtation like this kind of. Kindly give me some idea.
    Thanks

    Thank you Frank and Sorry for not so clear in explanation.
    SQL> desc demois_wo_routing
    Name                                      Null?    Type
    ORG_ID                                             NUMBER
    ASSIGNED_TO                                        VARCHAR2(10)
    COMMENTS                                           VARCHAR2(55)
    DUE_DATE                                           DATE
    ENTER_DATE                                NOT NULL DATE               -- is the APPROVED_DATE
    ENTER_USER                                         VARCHAR2(30)       -- is the APPROVER_NAME
    PRIORITY                                           NUMBER
    START_DATE                                         DATE
    STATUS                                    NOT NULL VARCHAR2(10)
    WO_NUMBER                                 NOT NULL VARCHAR2(10)
    SQL> desc demois_sr_routing
    Name                                      Null?    Type
    ORG_ID                                             NUMBER
    ASSIGNED_TO                                        VARCHAR2(10)
    COMMENTS                                           VARCHAR2(55)
    DUE_DATE                                           DATE
    ENTER_DATE                                NOT NULL DATE
    ENTER_USER                                         VARCHAR2(30)
    PRIORITY                                           NUMBER
    REQ_NUMBER                                NOT NULL VARCHAR2(10)
    START_DATE                                         DATE
    STATUS                                    NOT NULL VARCHAR2(10)
    SQL> select enter_user,wo_number,enter_Date,status from demois_wo_routing where wo_number='WO000853';
    ENTER_USER                     WO_NUMBER  ENTER_DAT STATUS
    E60075334                      WO000853   14-MAY-13 APPROVED
    C10000001                      WO000853   09-APR-13 OPEN
    C10000001                      WO000853   09-APR-13 ASSIGNED
    E60075373                      WO000853   09-APR-13 PND APPRVL
    SQL> select enter_user,req_number,enter_date,status from demois_sr_routing where req_number=(select req_number from demois_req where wo_number='WO000853');
    ENTER_USER                     REQ_NUMBER ENTER_DAT STATUS
    E60075373                      SR000818   09-APR-13 SCHEDULED
    E60075334                      SR000818   14-MAY-13 SCHEDULED
    C10000001                      SR000818   09-APR-13 SCHEDULED
    C10000001                      SR000818   09-APR-13 SCHEDULED
    SQL> SELECT fm.first_name || ' ' || fm.last_name AS approver_name,
      2         fpc.communication_value AS approver_cell
      3    FROM demo_person fm, demo_person_communication fpc
      4   WHERE fm.person_code = 'E60075334'   --ENTER_USER from FSR/ FWR table
      5     AND fm.person_id = fpc.person_id
      6     AND fpc.communication_type = 'Telephone';
    APPROVER_NAME
    APPROVER_CELL
    Nicy Varghese
    44952937
    SQL> SELECT fm.first_name || ' ' || fm.last_name AS approver_name,
      2         fpc.communication_value AS approver_cell
      3    FROM demo_person fm, demo_person_communication fpc
      4   WHERE fm.person_code =
      5                         (SELECT enter_user
      6                            FROM demois_wo_routing
      7                           WHERE wo_number = 'WO000853' AND status = 'APPROVED')
      8     AND fm.person_id = fpc.person_id
      9     AND fpc.communication_type = 'Telephone';
    APPROVER_NAME
    APPROVER_CELL
    Nicy Varghese
    44952937
    ACTUAL QUERY :---- If i run the below query i will definitely get a record of WO_NUMBER along with the other details.
    SELECT   w.wo_number,
             DECODE (NVL (p.print_wo_barcode_flag, 'N'),
                     'Y', '*' || w.wo_number || '*',
                     NULL
                    ) barcode_wo_number,
             INITCAP (w.maint_type) maint_type, INITCAP (w.wo_status) wo_state,
             w.priority, w.modify_date, w.start_date, w.due_date,
             INITCAP (w.description) description, w.method, w.crew,
             INITCAP (w.craft) craft, w.assigned_to, w.est_hours,
             DECODE (w.req_type,
                     'S', 'Service',
                     'P', 'PM',
                     'W', 'Project',
                     'T', 'Standing WO'
                    ) req_type,
             w.req_number, INITCAP (w.requestor) requestor, w.telephone,
             w.mail_code, w.department, w.cp_number, w.site, w.building,
             NVL (w.phase, 0) phase, w.FLOOR, w.room, w.equipment,
             INITCAP (w.close_comments) close_comments, w.alt_requestor,
             w.alt_telephone, w.alt_department, w.alt_mail_code, w.schedule_user,
             DECODE (w.equipment,
                     NULL, NULL,
                     '*' || w.equipment || '*'
                    ) equip_barcode,
             INITCAP (e.NAME) employee_name, w.schedule_date, w.pl_number,
             INITCAP (q.nomenclature) nomenclature, INITCAP (q.mfr) mfr,
             INITCAP (w.nonavailable_time) nonavailable_time, w.enter_user,
             a.asset_class_code, INITCAP (a.description) asset_class_description
        FROM demois_emp e,
             demois_equip q,
             demois_req w,
             demois_fmm_config p,
             demois_asset_class a
       WHERE w.wo_number IS NOT NULL
         AND NVL (w.asset_type, 'N') = 'N'
         AND w.equipment = q.equipment(+)
         AND w.assigned_to = e.employee(+)
         AND (w.assigned_to = :p_assigned_to OR :p_assigned_to IS NULL)
         AND (   (:p_marked_to_print = 'Y' AND w.print_ticket = 'Y')
              OR (:p_wo_number IS NOT NULL)
         AND (w.site = :p_site OR :p_site IS NULL)
         AND (w.crew = :p_crew OR :p_crew IS NULL)
         AND (w.craft = :p_craft OR :p_craft IS NULL)
         AND (w.maint_type = :p_maint_type OR :p_maint_type IS NULL)
         AND (w.req_type LIKE NVL (:p_req_type, '%'))
         AND (w.wo_number LIKE NVL (:p_wo_number, '%'))
         AND q.asset_class_id = a.asset_class_id(+)
    ORDER BY wo_number;
    The above is the sample data for my logic. The last one is the original query which am modifying with the tables listed above. The last query will return a record based on WO_NUMBER. Now i have to passing the WO_NUMBER to FWR table checking whether it is in APPROVED status or not. If not need to in FSR table with the associated SR ( req_number) for that WO_NUMBER.
    If there is a record in 'APPROVED' state, need to display the approver name from FP and FPC tables by passing value of the ENTER_USER from FSR /  FWR. Till now it is fine , if the STATUS is 'APPROVED'.
    The problem here is, there may a situation where the WO_NUMBER ( or respective SR number) will not be in 'APPROVED' status in both the tables. In this case also i need to get the record as usual like if i run the last query (ACTUAL QUERY).
    There is no direct relation between the FSR and FWR tables here. Only DEMOIS_REQ table has REQ_NUMBER (SR000818) and WO_NUMBER ( WO000853 ).
    Again sorry, If i am not clear enough.
    Thanks in advance.

  • SQL QUERY TUNING(PARTITONS AND JOIN)

    Hello
    My below query is taking very long time to execute ..here is the query and explain plan
    EXPLAIN PLAN FOR select w.ref_no,a.*
    from table1 a left outer join table2 w
    on(a.emp_id=w.emp_id)
    where a.joining_date=20090205 ;
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Pstart| Pstop |
    | 0 | SELECT STATEMENT | | 2415K| 504M| | 226K (2)| | |
    |* 1 | HASH JOIN OUTER | | 2415K| 504M| 488M| 226K (2)| | |
    |* 2 | TABLE ACCESS BY INDEX ROWID| table1 | 2415K| 460M| | 77975 (1)| | |
    |* 3 | INDEX RANGE SCAN | table1_joining_ DATE | 2441K| | | 6463 (2)| | |
    | 4 | PARTITION RANGE ALL | | 39M | 718M| | 64745 (2)| 1 | 4 |
    | 5 | TABLE ACCESS FULL | table2 | 39M | 718M| | 64745 (2)| 1 | 4 |
    table 2 has 40 million rows
    Table2 structure
    emp_id
    ref_no
    Project_id
    Partitoned on Project_id, Project_id is nowhere used on the above query
    Table1 Structure
    emp_id
    joining_date
    other columns
    Is indexed on joining_date, not partitioned
    Please advise

    The CBO has estimated that you have 2415K table1 rows where joining_date = 20090205. (By the way: is this really a number?!)
    Is this estimate accurate?
    Please add some more information:
    - Which version do you use
    - How long is "very long time"?
    - How many does your query return
    - information as described in this thread: When your query takes too long ...
    Regards,
    Rob.

  • Tuning Large Spatial Join in Oracle 9i

    I have a large (million+ rows) table of line segments (2 point lines) and I want to generate a table of all intersections. I have created the geometry column and populated the values and indexed it with a spatial index.
    I even looked in the metadata to get the index table name (not same name as index itself)and computed statistics on the spatial index table.
    1. Was this really necessary?
    I do a join on the table as follows:
    Select a.LineID, b.LineID from Lines a, Lines b
    where
    mdsys.sdo_relate(a.LineSegment, b.LineSegment,
    'mask=anyinteract querytype=JOIN
    idxtab2=Line_SPATIAL_IDX') = 'TRUE';
    Everything I try results in nested full table scans.
    I have tried index table name in place of index name.
    2. Which should I really use?
    3. QueryType=Join is rarely used but this is what I need, right?
    4. Does the optimizer/explain plan accurately represent spatial operations?
    5. SDO_Join is not available in 9i and Oracle10 is not an option for me, so any idea's how to do this efficently, or at least any methods to optimize the SQL?
    I removed the Insert command and SDO_Intersection function so that I could tune the Select.
    (I know i will need to filter each lines intersection with itself, but I am not even to that point yet, this runs for days).
    Thanks,

    I have the horsepower to do a full scan once and I was hoping that the spatial index would be of some use to avoid nested scans (a million scans of a million rows).
    Anyone have insight on why SDO_RELATE would not use the spatial index? Index type make a difference?
    It is Geodetic data, so I used the tree index, maybe tiling would be better sdo_relate join?
    I am watching from Enterprise Console session screen. Does this show an accurate plan on SQL that uses Spatial Operators?
    Also since I am joining a table to itself, on the same column no less, is this outside the capability of sdo_relate? It won't let me put a 2nd spatial index on that column. Should it? Am I doing it wrong?
    Any help is appreciated. Thanks.

  • Bind varibles,reports,dblink and view based on joins

    Created a report in portal with sql code (<oracle> tag) which fetches data from remoted db on 7.3.4.5 thru db link..
    But when i run report it says 0 rows found..seems bind varibles r not getting bounded..
    Db link is active.
    Same query works fine in sql plus .But does not work in portal or TOAD.
    Any qlue..
    sarvesh

    Hi,
    Did you try creating any other components or a view using the same query and DBLink and see any results ??
    what version of portal are you using .
    Thanks,
    Anu

  • Leave based on joining date

    hi all
    my client requirement is"  confirmed employee who have completed 1 year of service r eligible for Privilege leave.of 12 days per calender year.  and employee can accumulate up to 30 days of privilege"
    for which i have  defined base entitlement with constant 12
    and related to period i have given calender year. and in selection rule  accural period tab calender year. given.  in accural entitlement  - no prorata i have mentioned, transfer time calender year has given and total entitlement 30 i have given.
    i want to know if this process is ok for the requirement or not. i don't understant how system will  know the completion of 1 year of employee.
    do i need to write pcr .

    Dear Ankitha,
    Firstly, u need to maintain Date of Completion of 1 year in IT41, the same should be used in Deduction Interval FROM, and to would be Calender Year End.
    this will do this, though is updated in infotype, this cannot be used till the date of completion of 1 year.
    Secondly, cumulation upto 30 days would be "Z" you need to add this in program RPTQTA00.
    Regards
    ...Sadhu

  • Emp join Mid of the month  -Tax caluculation

    Hi
    Employee joined in October /18 /2011.Salary calculation on payroll days based  on October 17 days working +4 paid holiday =21. 
    so based employee joining  date    working days is 10 .
         Monthly 
    Basic     45,834.00
    HRA             18,334.00
    Spl             12,313.00
    TA                  800.00
    MA               1,250.00
    Gross     78,531.00
    10days salary
    Basic   21,825.71
    HRA      8,730.48
    SPL      5,863.33
    TA           380.95
    MA          595.24
    Gross    37,395.71
    October (10days)5months(nov, dec, jan, feb,mar)=3739678531*5 = 430051
    Annual total salary = 430051(it's client calculation )
    But in SAP system taking October full month Like =78531*6=471186
    How to config to get proper calculation, do i need to change any processing class .
    Kindly suggest me  ,
    Thanks
    Nandu

    Hi,
    Kindly read caution in that info and i think you revert to settings 0 as earlier.Now try to run nov in simulation,the system will take actual from oct salary and nov + remaining months salary based on Nov salary.
    Though the tax may seem more in oct due to this calculation the system shall in nov adjust tax accordingly.test it thoroughly and then convince the client that tax will never be more than what is actually received even at the end of march the  system takes actual upto Feb and only considers march salary only adding to the pay results already populated in RT.
    Check for 1 employee upto march and compare with what client does the calculation it will be same for tax.
    Salil

Maybe you are looking for