Set up a query (written Re)

Hi Experts,

I am facing a problem in executing the query that take a long time. And I'm new to setting up a query, kindly help me in this query to reduce the time of execution below.

After reading the stories, I am unable to find how to get the execution of the query, but not sure about re writing the query plan. This is the execution plan.

Please help me by rewriting the query and guide me some ground rules for rewriting where needed.

203 rows selected.

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=5745 Card=1 Bytes=
          222)


   1    0   SORT (GROUP BY NOSORT) (Cost=5570 Card=1 Bytes=12)
   2    1     TABLE ACCESS (FULL) OF 'FAMIS_REQ' (TABLE) (Cost=5570 Ca
          rd=1 Bytes=12)


   3    0   SORT (GROUP BY NOSORT) (Cost=5563 Card=1 Bytes=8)
   4    3     TABLE ACCESS (FULL) OF 'FAMIS_REQ' (TABLE) (Cost=5563 Ca
          rd=1 Bytes=8)


   5    0   NESTED LOOPS (OUTER) (Cost=5745 Card=1 Bytes=222)
   6    5     FILTER
   7    6       NESTED LOOPS (OUTER) (Cost=5743 Card=1 Bytes=198)
   8    7         NESTED LOOPS (OUTER) (Cost=5742 Card=1 Bytes=163)
   9    8           HASH JOIN (Cost=5739 Card=1 Bytes=140)
  10    9             NESTED LOOPS
  11   10               NESTED LOOPS (Cost=5567 Card=1 Bytes=98)
  12   11                 TABLE ACCESS (FULL) OF 'FAMIS_REQ' (TABLE) (
          Cost=5565 Card=1 Bytes=90)


  13   11                 INDEX (RANGE SCAN) OF 'FAMIS_REQUESTOR1' (IN
          DEX) (Cost=1 Card=1)


  14   10               TABLE ACCESS (BY INDEX ROWID) OF 'FAMIS_REQUES
          TOR' (TABLE) (Cost=2 Card=1 Bytes=8)


  15    9             TABLE ACCESS (FULL) OF 'FAM_PERSON' (TABLE) (Cos
          t=172 Card=1074 Bytes=45108)


  16    8           TABLE ACCESS (BY INDEX ROWID) OF 'LEASE_CONTACT' (
          TABLE) (Cost=3 Card=1 Bytes=23)


  17   16             INDEX (RANGE SCAN) OF 'FK_LEASECONTACT_CONTACT'
          (INDEX) (Cost=1 Card=1)


  18    7         TABLE ACCESS (BY INDEX ROWID) OF 'LEASE' (TABLE) (Co
          st=1 Card=1 Bytes=35)


  19   18           INDEX (UNIQUE SCAN) OF 'PK_LEASE' (INDEX (UNIQUE))
           (Cost=0 Card=1)


  20    5     TABLE ACCESS (BY INDEX ROWID) OF 'FAMIS_LEASE_LOCATION'
          (TABLE) (Cost=2 Card=1 Bytes=24)


  21   20       INDEX (RANGE SCAN) OF 'FAMIS_LEASE_LOC_LEASE_FK' (INDE
          X) (Cost=1 Card=1)










Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
    8484854  consistent gets
          0  physical reads
          0  redo size
      34190  bytes sent via SQL*Net to client
       9592  bytes received via SQL*Net from client
         15  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
        203  rows processed


SQL>

Apologies for any inconvenience in the reading of the application. This is the query.

SELECT a.req_number, a.req_status, a.wo_number, a.wo_status, a.description,
          a.requestor, a.req_date, a.enter_date, a.pl_number, a.site,
          a.building, a.room, a.attribute2, b.emp_id, c.custom09, c.custom13,
          c.custom11, c.custom16 + 1 AS family_no, c.active_flag, e.leaseid,
          e.commdate, e.enddate, e.functional_status, f.site_code,
          CASE
             WHEN c.custom09 = 'Married'
                THEN 10
             ELSE 0
          END AS married,
          CASE
             WHEN (CASE
                      WHEN (c.custom16 + 1) > 4
                         THEN 10
                      ELSE (c.custom16 + 1) * 2
                   END
                  ) IS NULL
                THEN 0
             ELSE (CASE
                      WHEN (c.custom16 + 1) > 4
                         THEN 10
                      ELSE (c.custom16 + 1) * 2
                   END)
          END AS family,
          CASE
             WHEN c.custom11 = 'Canadian Management'
                THEN 8
             ELSE 0
          END AS job,
          CASE
             WHEN (  CASE
                        WHEN MONTHS_BETWEEN (SYSDATE,
                                             TO_DATE (c.custom13,
                                                      'MM/DD/YYYY')
                                            ) > 36
                           THEN 6
                        ELSE 0
                     END
                   + CASE
                        WHEN MONTHS_BETWEEN (SYSDATE,
                                             TO_DATE (c.custom13,
                                                      'MM/DD/YYYY')
                                            ) > 36
                           THEN   (  MONTHS_BETWEEN (SYSDATE,
                                                     TO_DATE (c.custom13,
                                                              'MM/DD/YYYY'
                                                             )
                                                    )
                                   - 36
                                  )
                                / 24
                        ELSE   MONTHS_BETWEEN (SYSDATE,
                                               TO_DATE (c.custom13,
                                                        'MM/DD/YYYY'
                                                       )
                                              )
                             / 24
                     END
                  ) IS NULL
                THEN 0
             ELSE (  CASE
                        WHEN MONTHS_BETWEEN (SYSDATE,
                                             TO_DATE (c.custom13,
                                                      'MM/DD/YYYY')
                                            ) > 36
                           THEN 6
                        ELSE 0
                     END
                   + CASE
                        WHEN MONTHS_BETWEEN (SYSDATE,
                                             TO_DATE (c.custom13,
                                                      'MM/DD/YYYY')
                                            ) > 36
                           THEN   (  MONTHS_BETWEEN (SYSDATE,
                                                     TO_DATE (c.custom13,
                                                              'MM/DD/YYYY'
                                                             )
                                                    )
                                   - 36
                                  )
                                / 24
                        ELSE   MONTHS_BETWEEN (SYSDATE,
                                               TO_DATE (c.custom13,
                                                        'MM/DD/YYYY'
                                                       )
                                              )
                             / 24
                     END
                  )
          END AS hire,
          CASE
             WHEN MONTHS_BETWEEN (SYSDATE, a.req_date) * 4 > 10
                THEN 10
             ELSE MONTHS_BETWEEN (SYSDATE, a.req_date) * 4
          END AS entered,
            CASE
               WHEN c.custom09 = 'Married'
                  THEN 10
               ELSE 0
            END
          + CASE
               WHEN (CASE
                        WHEN (c.custom16 + 1) > 4
                           THEN 10
                        ELSE (c.custom16 + 1) * 2
                     END
                    ) IS NULL
                  THEN 0
               ELSE (CASE
                        WHEN (c.custom16 + 1) > 4
                           THEN 10
                        ELSE (c.custom16 + 1) * 2
                     END
                    )
            END
          + CASE
               WHEN c.custom11 = 'Canadian Management'
                  THEN 8
               ELSE 0
            END
          + CASE
               WHEN (  CASE
                          WHEN MONTHS_BETWEEN (SYSDATE,
                                               TO_DATE (c.custom13,
                                                        'MM/DD/YYYY'
                                                       )
                                              ) > 36
                             THEN 6
                          ELSE 0
                       END
                     + CASE
                          WHEN MONTHS_BETWEEN (SYSDATE,
                                               TO_DATE (c.custom13,
                                                        'MM/DD/YYYY'
                                                       )
                                              ) > 36
                             THEN   (  MONTHS_BETWEEN (SYSDATE,
                                                       TO_DATE (c.custom13,
                                                                'MM/DD/YYYY'
                                                               )
                                                      )
                                     - 36
                                    )
                                  / 24
                          ELSE   MONTHS_BETWEEN (SYSDATE,
                                                 TO_DATE (c.custom13,
                                                          'MM/DD/YYYY'
                                                         )
                                                )
                               / 24
                       END
                    ) IS NULL
                  THEN 0
               ELSE (  CASE
                          WHEN MONTHS_BETWEEN (SYSDATE,
                                               TO_DATE (c.custom13,
                                                        'MM/DD/YYYY'
                                                       )
                                              ) > 36
                             THEN 6
                          ELSE 0
                       END
                     + CASE
                          WHEN MONTHS_BETWEEN (SYSDATE,
                                               TO_DATE (c.custom13,
                                                        'MM/DD/YYYY'
                                                       )
                                              ) > 36
                             THEN   (  MONTHS_BETWEEN (SYSDATE,
                                                       TO_DATE (c.custom13,
                                                                'MM/DD/YYYY'
                                                               )
                                                      )
                                     - 36
                                    )
                                  / 24
                          ELSE   MONTHS_BETWEEN (SYSDATE,
                                                 TO_DATE (c.custom13,
                                                          'MM/DD/YYYY'
                                                         )
                                                )
                               / 24
                       END
                    )
            END
          + CASE
               WHEN MONTHS_BETWEEN (SYSDATE, a.req_date) * 4 > 10
                  THEN 10
               ELSE MONTHS_BETWEEN (SYSDATE, a.req_date) * 4
            END
          + CASE
               WHEN a.attribute2 IS NULL
                  THEN '0'
               ELSE a.attribute2
            END AS total,
          CASE
             WHEN f.site_code IN ('AJ1', 'AJ2', 'AJ3', 'RG1')
                THEN f.building_code
             ELSE f.space_code
          END AS SPACE,
          CASE
             WHEN a.site IN ('AJ1', 'AJ2', 'AJ3', 'RG1')
                THEN a.building
             ELSE a.room
          END AS space_req,
          CASE
             WHEN a.pl_number = '002002001'
                THEN 'Villa to Villa'
             ELSE (CASE
                      WHEN a.pl_number = '002002002'
                         THEN 'Apartment to Villa'
                      ELSE (CASE
                               WHEN a.pl_number = '002002003'
                                  THEN 'Apartment to Apartment'
                               ELSE 'Villa to Apartment'
                            END
                           )
                   END
                  )
          END AS TYPE,
          (SELECT   MAX (g.req_date)
               FROM famis_req g
              WHERE g.req_date < a.req_date
                AND g.requestor_id = a.requestor_id
                AND g.pl_number IN
                         ('002002001', '002002002', '002002003', '002002004')
                AND g.wo_status = 'CLOSED'
           GROUP BY g.requestor_id) AS last_move,
          (SELECT   COUNT (g.req_number)
               FROM famis_req g
              WHERE g.req_date <> a.req_date
                AND g.requestor_id = a.requestor_id
                AND g.pl_number IN
                         ('002002001', '002002002', '002002003', '002002004')
                AND g.req_status NOT IN ('REJECTED', 'CANCELED')
           GROUP BY g.requestor_id) AS requests
     FROM famis_req a JOIN famis_requestor b ON a.requestor_id =
                                                                b.requestor_id
          JOIN fam_person c ON b.emp_id = c.person_code
          LEFT JOIN lease_contact d ON c.person_code = d.contact_id
          LEFT JOIN lease e ON d.leaseid = e.leaseid
          LEFT JOIN famis_lease_location f ON e.leaseid = f.lease_code
    WHERE site <> 'CNAQ1'
      AND pl_number IN ('002002001', '002002002', '002002003', '002002004')
      AND (a.enter_date < e.enddate OR e.enddate IS NULL)
      AND (e.functional_status = 'OCCUPIED' OR e.functional_status IS NULL)

Thank you.

It is difficult to read anything not formatted output of the explain plan.

In any case, there is a hughe number of becomes coherent.

I'm just guessing that the reason might be the two groups of subqueries.

You can try to replace them with

1 Inline views or subquery (with article) plants which are connected to the result set

or

2 analysis functions

Here is an example of the latter approach. You can try if this changes something (after make sure you that they lead to correct results).

, max (case when a.wo_status = 'CLOSED' then a.req_date any other purpose) over (partition by a.requestor_id of a.req_date order

range between unbounded preceding and interval "0.1"(seconde précédant) as last_move "."

, count (case when not in a.req_status ('DENIED', 'CANCELLED') then a.req_number any other purpose))

a.requestor_id partition)

-count (case when not in a.req_status ('DENIED', 'CANCELLED') then a.req_number any other purpose))

partition a.requestor_id, a.req_date) as applications

Note that I assume that req_date is of date data type. If it is of type timestamp, the interval should be adapted.

Tags: Database

Similar Questions

  • How does whitespace or null values or characters set effect set in the query?

    Hi all

    I have a question about client side Oracle database tools. I have Oracle 11g installed on the server and I use PL/SQL developer tool to retrieve information from the server and then I copy paste this query in PL SQL Developer my company built in box of function of the application that executes the same query as client tools and the results.

    When I write the request by spaces of the Tools client-side IE the PL/SQL developer tool and copy paste at my request of builtin company gives slow down me execution, but if I remove the white of the query space by copying the application of PL/SQL developer(client side tool) to Notepad first and then copy back at my request and gives me a faster execution.

    For example:

    Original Request: with whitespace

    Select

    *

    Of

    Double

    Ask without spaces faster tracks:

    Select * twice;

    I want to the reason behind this slow execution and also if you could explain in detail would be great that I am no expert oracle.

    Also, I wanted to know that character set parameters from the client side tools slow running query? As I copy the request of PL/SQL developer tool

    Thank you

    HP

    HP, I have has been suggest you determine if the difference in performance is due to how the application prepares and processes SQL or if the difference is in Oracle.  If you can duplicate the issue in Oracle using SQLPLus then you can use the Oracle tools such as autotrace, SQL, trace etc... to determine how Oracle handles each request.  On the other hand if the time of execution in SQLPLus is the same then you know that the problem lies in the application.  Depending on whether you have access to the source you can or will not be able to track down the issue and resolve it.  Otherwise always paste the capture into the plan text and edit it to remove the unnecessary lines before copying them the text into your application tool.

    - -

    HTH - Mark D Powell.

  • Unable to loop result set of a query in Site Studio component

    Hi all

    I write a custom component to display the records in the custom table.

    I created a (docservice) service called 'GET_DATA_VIEW' and selected scriptable. In action, I've assigned a "Quser" query and the query "select type query cache. I gave the name of result as GET_USER set.

    Now, the "Quser" query is a simple select statement as follows:

    Select * from temp_user where dName =?.

    Added dName as a parameter.

    The studio site page when I run the service and the result set, the loop it does not work. The code is as below:

    <!-$dName = 'test'->
    <!-$ executeService ("GET_DATA_VIEW")->
    <! - $loop GET_USER - >
    <!-$dName->: <!-$dDepartment->
    <!-$endloop->

    It does not, so that if I create a page template in the component that works.

    Help, please.

    Leo30 wrote: my query is "select country countryname".

    Where COUNTRYNAME is a column in the country table.

    When trying to loop through the result set, it does not print the result as below:




    >

    Leo30 wrote: but when I print it gives me the correct number of rows in the table.

    Hoping that the "USER_LIST" is a typo. The result set name is 'COUNTRY_LIST '.

    In any case, assuming that the fault of typo, it is likely that you have the incorrect column name or the name of the column is in the wrong case. The names are case-sensitive, and you can not return the column name, you expect from the result set.

    Try to use this code to print the actual column names and values of the result set.






    =


  • How to set Options for querying a DB of EnterpriseManager/AdminCons adapter

    Hi all

    We all know after dragging an adapeter DB we can manually configure Options survey in developer J

    However,.

    My query is how set options to vote of a DB of EnterpriseManager/AdminCons adapter so that we dun hav to modify our code and redeploy if no change is required.
    My DB adapter is deployed to EM. (Server SOA).

    Polling options like:

    In the polling interval, list select the frequency of polling for new records or events.

    In the lines of database through XML Document field, specify the number of lines per XML document when sending events to Oracle BPEL PM or mediator. It is the lot of adjustment between the database adapter and its consumers: Oracle BPEL PM or mediator.

    In lines of database per Transaction field, select unlimited, or enter a value to indicate the number of rows in the table to process a single transaction.

    When querying the database for events, you can order the rows returned by the column selected by using the Order By list. The best practice is to choose < order No. >, as order regardless of message is not guaranteed without additional configuration.

    Hello

    Inside of your composite (in Employment), you can see there is a call from table "Services and references" category.
    Under him, find the name of your JCA adapter, where you define the modalities of the election since the database. Click on it and go to the property tab.
    You will find all the settings that you have defined and much more.
    After you have finished updating, click on apply (this will automatically query the data).

    Arik

  • SQL query takes too long to run (1 h 25 min)... pls help how to set up the query.

    Hello

    Could someone please help how to tune the query as its takes a long time to retrieve the results.

    Select

    col1,

    col2,

    col3,

    COL4,

    col5,

    col6,

    col7,

    COL8,

    col9,

    col10,

    Col11,

    col12,

    Sum (volume1),

    Sum (volume2),

    Sum (volume3),

    Sum (volume4),

    Sum (volume5),

    Sum (volume6),

    Sum (volume7),

    Sum (volume8),

    Sum (volume9),

    Sum (volume10),

    Sum (volume11),

    Sum (volume12),

    Sum (volume13),

    Sum (volume14),

    Sum (volume15),

    Sum (volume16),

    Sum (volume17),

    Sum (Volume18),

    Sum (volume19),

    Sum (volume20),

    Sum (rate1),

    Sum (rate2),

    Sum (rate3),

    Sum (rate4),

    Sum (rate5),

    Sum (rate6),

    Sum (rate7),

    Sum (rate8),

    Sum (rate9),

    Sum (rate10),

    Sum (rate11),

    Sum (rate12),

    Sum (rate13),

    Sum (rate14),

    Sum (rate15),

    Sum (rate16),

    Sum (rate17),

    Sum (rate18)

    Sum (rate19),

    Sum (rate20)

    Of

    Table 1 - 13, 25, 99, 400 records

    Table2 - 13, 45, 1000 records

    Table 3 - 4, 50, 000 records

    Table 4 - 1,00,000 records

    table5 - 30 000 records

    where tabl1.col1 = table2.col2,

    Table1.Col1 = table3.col1.

    table2.col2 = table3.col2...

    Group

    Sum (volume1),

    Sum (volume2),

    Sum (volume3),

    Sum (volume4),

    Sum (volume5),

    Sum (volume6),

    Sum (volume7),

    Sum (volume8),

    Sum (volume9),

    Sum (volume10),

    Sum (volume11),

    Sum (volume12),

    Sum (volume13),

    Sum (volume14),

    Sum (volume15),

    Sum (volume16),

    Sum (volume17),

    Sum (Volume18),

    Sum (volume19),

    Sum (volume20),

    Sum (rate1),

    Sum (rate2),

    Sum (rate3),

    Sum (rate4),

    Sum (rate5),

    Sum (rate6),

    Sum (rate7),

    Sum (rate8),

    Sum (rate9),

    Sum (rate10),

    Sum (rate11),

    Sum (rate12),

    Sum (rate13),

    Sum (rate14),

    Sum (rate15),

    Sum (rate16),

    Sum (rate17),

    Sum (rate18)

    Sum (rate19),

    Sum (rate20)

    Thank you

    Prasad.

    > Could someone please help how to tune the query as its takes a long time to retrieve the results.

    The query you posted is obviously fake.

    If you ask to give us a request that you do not post and we cannot see.

    For real?

  • How to set up a query.

    Hi all

    I'm using Oracle 11 g R2 and I on one of my query performance problems.

    I have the following query that takes about 3 seconds (which is fine for me) where I spend as a parameter for example TOTO and AUNTIE but it takes several minutes when I go to settings, other things (see the execution below plan).

    I thought then it was question of data (data bank) so I created a histogram on the colunm DVC_EVT_TYPE_CD but it did not help: exec dbms_stats.gather_table_stats ('CISADM', 'D1_DVC_EVT', method_opt = > 'for all columns size skewonly').

    All tips to improve the second query (which takes more than a minute) would be appreciated.

    Thank you.

    1st REQUEST :

    SELECT / * + TEST_GSM * / ERO. DVC_EVT_ID, D1_DVC_EVT E.DVC_EVT_DTTM

    E, D1_DVC_EVT_REL_OBJ RTO WHERE RTO. MAINT_OBJ_CD = "D1-DEVICE" AND

    ERO. PK_VALUE1 = '227517483687' AND ERO. DVC_EVT_ID = E.DVC_EVT_ID AND

    E.DVC_EVT_TYPE_CD IN (' END-GSMLOWLEVEL-EXCP-SEV-1', ')

    "STR-GSMLOWLEVEL-EXCP-SEV-1") AND ROWNUM < = ORDER BY E.DVC_EVT_DTTM 51.

    DESC;

    Hash value of plan: 3392374516

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name | Begins | E - lines. E - bytes | Cost (% CPU). Pstart. Pstop | A - lines.   A - time | Pads | Bed |  OMem |  1Mem | Used Mem.

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |            |      1.        |       |    58 (100) |    |          |     51. 00:00:03.27 |     764.    501.       |       |          |

    |   1.  SORT ORDER BY |            |      1.     51.  4590 |    58 (2) |    |          |     51. 00:00:03.27 |     764.    501.  4096 |  4096 | 4096 (0) |

    |*  2 |   COUNT STOPKEY |            |      1.        |       |            |    |          |     51. 00:00:03.27 |     764.    501.       |       |          |

    |   3.    NESTED LOOPS |            |      1.        |       |            |    |          |     51. 00:00:03.27 |     764.    501.       |       |          |

    |   4.     NESTED LOOPS |            |      1.     52.  4680 |    57 (0) |    |          |    248. 00:00:01.55 |     504.    273.       |       |          |

    |*  5 |      INDEX RANGE SCAN | TEST1 |      1.   7107 |   284K |     4 (0) |    |          |    248. 00:00:00.03 |       6.      6.       |       |          |

    |   6.      RANGE OF PARTITION ITERATOR.            |    248.      1.       |     1 (0) |   KEY |   KEY |    248. 00:00:01.52 |     498.    267.       |       |          |

    |*  7 |       INDEX UNIQUE SCAN | D1T400P0 |    248.      1.       |     1 (0) |   KEY |   KEY |    248. 00:00:01.51 |     498.    267.       |       |          |

    |*  8 |     TABLE ACCESS BY INDEX ROWID | D1_DVC_EVT |    248.      1.    49.     2 (0) | ROWID | ROWID |     51. 00:00:01.71 |     260.    228.       |       |          |

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    2 - filter(ROWNUM<=51)

    5 - access("ERO".") MAINT_OBJ_CD '= 'D1-DEVICE' AND 'ERO'." PK_VALUE1 "=" 127785269680")

    7 - access("ERO".") DVC_EVT_ID '=' E '. ("' DVC_EVT_ID")

    8 filter (("E". "DVC_EVT_TYPE_CD"= "END-GSMLOWLEVEL-EXCP-SEV-1" OR "E" " DVC_EVT_TYPE_CD "=" STR-GSMLOWLEVEL-EXCP-SEV-1'))

    2ND REQUEST:

    SELECT / * + TEST_MAINS * / ERO. DVC_EVT_ID, E.DVC_EVT_DTTM OF

    D1_DVC_EVT E, D1_DVC_EVT_REL_OBJ RTO WHERE RTO. MAINT_OBJ_CD =

    "D1-DEVICE" AND ERO. PK_VALUE1 = '227517483687' AND ERO. DVC_EVT_ID =

    E.DVC_EVT_ID AND E.DVC_EVT_TYPE_CD IN (' END-POWER-EXCP-SEV-1', ')

    "STR-POWER-EXCP-SEV-1") AND ROWNUM < = 51 ORDER BY E.DVC_EVT_DTTM DESC;

    Hash value of plan: 3392374516

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name | Begins | E - lines. E - bytes | Cost (% CPU). Pstart. Pstop | A - lines.   A - time | Pads | Bed |  OMem |  1Mem | Used Mem.

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |            |      1.        |       |    58 (100) |    |          |     51. 00:01:04.70 |   26738 |  13604.       |       |          |

    |   1.  SORT ORDER BY |            |      1.     51.  4590 |    58 (2) |    |          |     51. 00:01:04.70 |   26738 |  13604.  4096 |  4096 | 4096 (0) |

    |*  2 |   COUNT STOPKEY |            |      1.        |       |            |    |          |     51. 00:01:04.70 |   26738 |  13604.       |       |          |

    |   3.    NESTED LOOPS |            |      1.        |       |            |    |          |     51. 00:01:04.69 |   26738 |  13604.       |       |          |

    |   4.     NESTED LOOPS |            |      1.     52.  4680 |    57 (0) |    |          |   8820 | 00:00:13.50 |   17714.   7245 |       |       |          |

    |*  5 |      INDEX RANGE SCAN | TEST1 |      1.   7107 |   284K |     4 (0) |    |          |   8820 | 00:00:00.21 |      68.     66.       |       |          |

    |   6.      RANGE OF PARTITION ITERATOR.            |   8820 |      1.       |     1 (0) |   KEY |   KEY |   8820 | 00:00:13.18 |   17646 |   7179.       |       |          |

    |*  7 |       INDEX UNIQUE SCAN | D1T400P0 |   8820 |      1.       |     1 (0) |   KEY |   KEY |   8820 | 00:00:12.97 |   17646 |   7179.       |       |          |

    |*  8 |     TABLE ACCESS BY INDEX ROWID | D1_DVC_EVT |   8820 |      1.    49.     2 (0) | ROWID | ROWID |     51. 00:00:51.11 |    9024 |   6359.       |       |          |

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    2 - filter(ROWNUM<=51)

    5 - access("ERO".") MAINT_OBJ_CD '= 'D1-DEVICE' AND 'ERO'." PK_VALUE1 "=" 227517483687")

    7 - access("ERO".") DVC_EVT_ID '=' E '. ("' DVC_EVT_ID")

    8 filter (("E". "DVC_EVT_TYPE_CD"= "END-POWER-EXCP-SEV-1" OR "E" " DVC_EVT_TYPE_CD "=" STR-POWER-EXCP-SEV-1'))

    Hello

    of course, the order is important. If you have created an index on (DVC_EVT_TYPE_CD, DVC_EVT_ID) in that order, then it would have been impossible for Oracle choose this index (because of the GOLD on the main column).

    Best regards

    Nikolai

  • How to set up a query - 'A-lines' and 'E' are different.

    Hi all

    I use 11 g R2 and I'm trying to resolve a query. On the execution below plan, my E-lines and my A are different. As you can see, there is little the same line 22 to 43, but starting from line 21 to 1 E-lines are false. For example, on the content (RowSource) 12, E-lines is (1 * 179) and lines A is 8631.

    All statistics have been generated and are up to date. Do you know what could be the problem?
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                     | Name                      | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  | Writes |  OMem |  1Mem |  O/1/M   | Max-Tmp |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                              |                           |      1 |        |     50 |00:05:55.08 |     203K|  69975 |   1094 |       |       |          |         |
    |   1 |  SORT ORDER BY                                |                           |      1 |    179 |     50 |00:05:55.08 |     203K|  69975 |   1094 |  8307K|  1133K|          |         |
    |   2 |   HASH UNIQUE                                 |                           |      1 |    179 |   8631 |00:05:54.56 |     203K|  69317 |    180 |  4474K|  1861K|          |   16384 |
    |   3 |    NESTED LOOPS                               |                           |      1 |        |   8631 |00:05:54.04 |     203K|  69137 |      0 |       |       |          |         |
    |   4 |     NESTED LOOPS                              |                           |      1 |    179 |   8631 |00:05:23.24 |     194K|  63768 |      0 |       |       |          |         |
    |   5 |      NESTED LOOPS                             |                           |      1 |    179 |   8631 |00:05:13.51 |     177K|  61396 |      0 |       |       |          |         |
    |   6 |       NESTED LOOPS                            |                           |      1 |    179 |   8631 |00:04:03.74 |     151K|  52928 |      0 |       |       |          |         |
    |   7 |        NESTED LOOPS                           |                           |      1 |    179 |   8631 |00:03:32.15 |     125K|  46425 |      0 |       |       |          |         |
    |*  8 |         HASH JOIN                             |                           |      1 |    179 |   8631 |00:02:59.42 |   99470 |  40095 |      0 |  4379K|  1869K|     1/0/0|         |
    |*  9 |          HASH JOIN                            |                           |      1 |    179 |   8631 |00:02:59.15 |   98919 |  40067 |      0 |   909K|   909K|     1/0/0|         |
    |  10 |           TABLE ACCESS FULL                   | DIM_PERFORMANCE           |      1 |      5 |      5 |00:00:00.01 |       2 |      0 |      0 |       |       |          |         |
    |  11 |           NESTED LOOPS OUTER                  |                           |      1 |    179 |   8631 |00:02:59.06 |   98917 |  40067 |      0 |       |       |          |         |
    |  12 |            NESTED LOOPS                       |                           |      1 |    179 |   8631 |00:02:58.87 |   98917 |  40067 |      0 |       |       |          |         |
    |* 13 |             HASH JOIN                         |                           |      1 |    191 |   8758 |00:00:25.47 |   18101 |   2398 |      0 |  1000K|  1000K|     1/0/0|         |
    |  14 |              TABLE ACCESS FULL                | DIM_TYP_FLUIDE            |      1 |      3 |      3 |00:00:00.01 |       2 |      0 |      0 |       |       |          |         |
    |* 15 |              HASH JOIN                        |                           |      1 |    191 |   8758 |00:00:25.32 |   18099 |   2398 |      0 |   955K|   955K|     1/0/0|         |
    |  16 |               TABLE ACCESS FULL               | DIM_TYP_PDC               |      1 |      3 |      3 |00:00:00.01 |       2 |      0 |      0 |       |       |          |         |
    |  17 |               NESTED LOOPS                    |                           |      1 |        |   8758 |00:00:25.19 |   18097 |   2398 |      0 |       |       |          |         |
    |  18 |                NESTED LOOPS                   |                           |      1 |    191 |   8758 |00:00:06.46 |    9339 |    315 |      0 |       |       |          |         |
    |* 19 |                 HASH JOIN                     |                           |      1 |    191 |   8758 |00:00:00.67 |     565 |      0 |      0 |   880K|   880K|     1/0/0|         |
    |  20 |                  TABLE ACCESS FULL            | DIM_OFFRE                 |      1 |     22 |     22 |00:00:00.01 |       2 |      0 |      0 |       |       |          |         |
    |* 21 |                  HASH JOIN                    |                           |      1 |    191 |   8758 |00:00:00.53 |     563 |      0 |      0 |   779K|   779K|     1/0/0|         |
    |  22 |                   NESTED LOOPS                |                           |      1 |        |      1 |00:00:00.01 |       5 |      0 |      0 |       |       |          |         |
    |  23 |                    NESTED LOOPS               |                           |      1 |      1 |      1 |00:00:00.01 |       4 |      0 |      0 |       |       |          |         |
    |* 24 |                     TABLE ACCESS FULL         | DIM_CONTRAT               |      1 |      1 |      1 |00:00:00.01 |       3 |      0 |      0 |       |       |          |         |
    |* 25 |                     INDEX UNIQUE SCAN         | PK_CONTRACTANT_KEY        |      1 |      1 |      1 |00:00:00.01 |       1 |      0 |      0 |       |       |          |         |
    |* 26 |                    TABLE ACCESS BY INDEX ROWID| DIM_CONTRACTANT           |      1 |      1 |      1 |00:00:00.01 |       1 |      0 |      0 |       |       |          |         |
    |  27 |                   TABLE ACCESS FULL           | REL_SERVICE_POINT_CONTRAT |      1 |  54923 |  54923 |00:00:00.14 |     558 |      0 |      0 |       |       |          |         |
    |* 28 |                 INDEX UNIQUE SCAN             | PK_SP_KEY                 |   8758 |      1 |   8758 |00:00:05.66 |    8774 |    315 |      0 |       |       |          |         |
    |  29 |                TABLE ACCESS BY INDEX ROWID    | DIM_SERVICE_POINT         |   8758 |      1 |   8758 |00:00:18.58 |    8758 |   2083 |      0 |       |       |          |         |
    |  30 |             PARTITION RANGE SINGLE            |                           |   8758 |      1 |   8631 |00:02:33.32 |   80816 |  37669 |      0 |       |       |          |         |
    |* 31 |              TABLE ACCESS BY LOCAL INDEX ROWID| FAC_DAILY_TRANS_PERFORM   |   8758 |      1 |   8631 |00:02:33.18 |   80816 |  37669 |      0 |       |       |          |         |
    |* 32 |               INDEX RANGE SCAN                | IDX3_FAC_DAY_TRAN_PERF    |   8758 |      6 |    103K|00:00:16.05 |   17929 |   4751 |      0 |       |       |          |         |
    |  33 |            TABLE ACCESS BY INDEX ROWID        | DIM_DIAGNOSYS             |   8631 |      1 |      0 |00:00:00.12 |       0 |      0 |      0 |       |       |          |         |
    |* 34 |             INDEX UNIQUE SCAN                 | PK_DIAGNOSYS_KEY          |   8631 |      1 |      0 |00:00:00.05 |       0 |      0 |      0 |       |       |          |         |
    |  35 |          TABLE ACCESS FULL                    | DIM_DATE                  |      1 |  21914 |  21914 |00:00:00.05 |     551 |     28 |      0 |       |       |          |         |
    |  36 |         TABLE ACCESS BY INDEX ROWID           | DIM_RADIO_MODULE          |   8631 |      1 |   8631 |00:00:32.65 |   25895 |   6330 |      0 |       |       |          |         |
    |* 37 |          INDEX UNIQUE SCAN                    | PK_RADMODKEY              |   8631 |      1 |   8631 |00:00:08.38 |   17264 |   2122 |      0 |       |       |          |         |
    |  38 |        TABLE ACCESS BY INDEX ROWID            | DIM_METER_MODULE          |   8631 |      1 |   8631 |00:00:31.51 |   25895 |   6503 |      0 |       |       |          |         |
    |* 39 |         INDEX UNIQUE SCAN                     | PK_METMODKEY              |   8631 |      1 |   8631 |00:00:10.17 |   17264 |   2212 |      0 |       |       |          |         |
    |  40 |       TABLE ACCESS BY INDEX ROWID             | DIM_CUSTOMER              |   8631 |      1 |   8631 |00:01:09.66 |   25895 |   8468 |      0 |       |       |          |         |
    |* 41 |        INDEX UNIQUE SCAN                      | PK_CUSTOMER               |   8631 |      1 |   8631 |00:00:12.03 |   17264 |   2328 |      0 |       |       |          |         |
    |* 42 |      INDEX UNIQUE SCAN                        | PK_METER                  |   8631 |      1 |   8631 |00:00:09.63 |   17264 |   2372 |      0 |       |       |          |         |
    |  43 |     TABLE ACCESS BY INDEX ROWID               | DIM_METER                 |   8631 |      1 |   8631 |00:00:30.71 |    8631 |   5369 |      0 |       |       |          |         |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       8 - access("T786"."DATE_KEY"="T1830"."DATE_KEY")
       9 - access("T786"."PERFORMANCE_KEY"="T2158"."PERFORMANCE_KEY")
      13 - access("T160"."FLUIDE_KEY"="T210"."FLUIDE_KEY")
      15 - access("T160"."TYP_PDC_KEY"="T217"."TYP_PDC_KEY")
      19 - access("T122"."OFFRE_KEY"="T298"."OFFRE_KEY")
      21 - access("T24"."CONTRAT_KEY"="T298"."CONTRAT_KEY" AND "T17"."CONTRACTANT_KEY"="T298"."CONTRACTANT_KEY")
      24 - filter("T24"."NOM_CONTRAT"='COMMUNAY ET REGION (SIE)')
      25 - access("T17"."CONTRACTANT_KEY"="T24"."CONTRACTANT_KEY")
      26 - filter("T17"."NOM_CONTRACTANT"='ER Rhône Alpes Auvergne')
      28 - access("T160"."SERVICE_POINT_KEY"="T298"."SERVICE_POINT_KEY")
      31 - filter("T786"."REPORTING_DATE"=TO_DATE(' 2013-02-09 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      32 - access("T160"."SERVICE_POINT_KEY"="T786"."SERVICE_POINT_KEY")
      34 - access("T786"."DIAGNOSYS_KEY"="T2186"."DIAGNOSYS_KEY")
      37 - access("T786"."RADIO_MODULE_KEY"="T949"."RADIO_MODULE_KEY")
      39 - access("T786"."METER_MODULE_KEY"="T1191"."METER_MODULE_KEY")
      41 - access("T786"."CUSTOMER_KEY"="T2098"."CUSTOMER_KEY")
      42 - access("T786"."METER_KEY"="T1011"."METER_KEY")
     
    Also, line 31, my score is used with a local index and E-lines and A-lines are correct, but the index takes 02:33 minutes to get a 8758 ranks who seems to be excessive. EC which could I check/do to reduce it?
    |  30 |             PARTITION RANGE SINGLE            |                           |   8758 |      1 |   8631 |00:02:33.32 |   80816 |  37669 |      0 |       |       |          |         |
    |* 31 |              TABLE ACCESS BY LOCAL INDEX ROWID| FAC_DAILY_TRANS_PERFORM   |   8758 |      1 |   8631 |00:02:33.18 |   80816 |  37669 |      0 |       |       |          |         |
    Thank you very much!

    Hello

    (1) for a significant query, it is rare that the optimizer obtains all right cardinalities
    (2) but normally, it is not really necessary, in most cases just to be in the right ballpark (1-2 orders of magnitude)
    (3) as others already said, the optimizer in your case does that 1 error - in step 1, when evaluating a cardinality of a hash of several columns, the steps join upward simply reproduce this error over and over
    (4) rethink the cardinality of the join is always difficult, and especially when it comes to columns multiple joins because you have several possibilities made a mistake in the selectivity of unique columns, but also because there is a chance that there is a correlation between the columns attached; also, the optimizer uses many settings, called 'mental health controls', which does not make things more simple
    (5) you can try to create statistics on a column in the joined columns group for a more accurate forecast of join cardinality
    (6) there again, get all the cardinalities right does not guarantee that you will get a good plan - for example, you may be limited by the lack of an appropriate index
    (7) sometimes, and more feedback of cardinality (or even instead) it is better to tackle the problem from a different angle: see what operations are ineffective (e.g. rejection lines after spending a lot of e/s on their acquisition), see http://savvinov.com/2013/01/28/efficiency-based-sql-tuning/
    (8) in your case, you have noticed that you: step

    |* 31 |              TABLE ACCESS BY LOCAL INDEX ROWID| FAC_DAILY_TRANS_PERFORM   |   8758 |      1 |   8631 |00:02:33.18 |   80816 |  37669 |      0 |       |       |          |  
    

    is the biggest problem for this plan, even if the cardinality estimate of it's very precise
    (9) you can fix the problem by extending the IDX3_FAC_DAY_TRAN_PERF index to the REPORTING_DATE column: If you do this, then you won't need to 63 k logical reads to return lines k 103 just to reject 90% of them - you will reject them at an earlier stage (INDEX RANGE SCAN) and only need to at most 8 k readings to acquire the filtered lines by table rowid

    Best regards
    Nikolai

  • Variable set to NULL Query

    I'm working on a procedure that is using the workflow Oracle EBS application for approval.

    It has been customized by a contractor in the past, but we need to make some changes to it.

    I declared a new variable of number:
    l_req_doc_id               NUMBER :=0;
    The value of the variable l_req_doc_id is set via this SQL:
          SELECT DISTINCT requisition_header_id
                   INTO l_req_doc_id
                   FROM po.po_requisition_lines_all prla
                      , ap.ap_suppliers pv
                      , ap.ap_supplier_sites_all pvsa
                      , po.po_line_locations_all plla                   
                      , po.po_lines_all pla                                          
                  WHERE prla.vendor_id = pv.vendor_id
                    AND prla.vendor_site_id = pvsa.vendor_site_id
                    AND pv.vendor_id = pvsa.vendor_id
                    AND prla.line_location_id = plla.line_location_id   
                    AND plla.po_line_id = pla.po_line_id                
                    AND pla.po_header_id = l_document_id;
    We hit a scenario where some applications are triggered when the value of vendor_site_id on the command line is NULL.

    When this happens, the SQL above will return no rows.

    I wanted to check here if, after his return any rows, SQL will change the value of l_req_doc_id from zero to NULL or would remain at zero when the SQL returns no rows?

    I know it's a silly question, and I could just write some debug statements in the code that works. Unfortunately the complexity of the code, that debugging statements don't always trigger in the way that I expect.

    Any advice much appreciated.

    Thank you

    20100511 wrote:
    I know it's a silly question, and I could just write some debug statements in the code that works. Unfortunately the complexity of the code, that debugging statements don't always trigger in the way that I expect.

    It is pure laziness on your part.
    You could easily create a sample test case to understand behaviour like this

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2      l_num number := 0;
      3  begin
      4      dbms_output.Put_line('Before Select '||l_num);
      5      select 1 into l_num from dual where  1 = 2;
      6  exception
      7      when no_data_found then
      8        dbms_output.Put_line('After Select '||l_num);
      9* end;
     10  /
    Before Select 0
    After Select 0
    
    PL/SQL procedure successfully completed.
    
  • [10 g/8i] Need help with setting up a query

    I have a query that takes about 5 minutes to run, and if there is a way to make it faster, I would like to know. It is not a huge problem, but I get to sleep while waiting for it to end. =)

    Here are the results of the explain plan command and the extra stuff generated by autotrace...
    SQL> show parameter optimizer
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.1
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    SQL> 
    SQL> show parameter db_file_multi
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_file_multiblock_read_count        integer     128
    SQL> 
    SQL> show parameter db_block_size
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_block_size                        integer     8192
    SQL> 
    SQL> show parameter cursor_sharing
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    cursor_sharing                       string      EXACT
    SQL> 
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL> 
    SQL> select
      2           sname
      3         , pname
      4         , pval1
      5         , pval2
      6  from
      7         sys.aux_stats$;
    
    SNAME                PNAME                      PVAL1 PVAL2
    -------------------- -------------------- ----------- --------------------
    SYSSTATS_INFO        STATUS                           COMPLETED
    SYSSTATS_INFO        DSTART                           02-07-2006 22:54
    SYSSTATS_INFO        DSTOP                            02-07-2006 22:54
    SYSSTATS_INFO        FLAGS                      1.000
    SYSSTATS_MAIN        CPUSPEEDNW               500.790
    SYSSTATS_MAIN        IOSEEKTIM                 10.000
    SYSSTATS_MAIN        IOTFRSPEED             4,096.000
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    
    13 rows selected.
    
    Elapsed: 00:00:00.03
    SQL> explain plan into plan_table for
      2  SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
      3       ,     b.parent_part
      4       ,     b.child_part
      5       ,     eval_number ('1' || SYS_CONNECT_BY_PATH (b.qty_per, '*'))     AS qty
      6       FROM     (
      7            SELECT     doc_nbr          AS parent_part
      8            ,     comp_part     AS child_part
      9            ,     line_nbr
     10            ,     qty_per
     11            FROM     bill@DB8I
     12            WHERE     lst_code     IN ('G','M')
     13            AND     begn_eff     <= SYSDATE
     14            AND     end_eff          > SYSDATE
     15            AND      component_type     = 'R'
     16            AND     doc_type     = 'BILL'
     17            AND     status          = 'RL'
     18            ) b
     19       ,     part@DB8I p
     20       ,     dual
     21       WHERE     b.child_part     = p.part_nbr
     22       START WITH     b.parent_part          = 'MYPARTNBR'
     23       CONNECT BY     b.parent_part          = PRIOR b.child_part
     24       AND          PRIOR p.part_type     = 'M'
     25  ;
    
    Explained.
    
    Elapsed: 00:00:00.23
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 2565617462
    
    --------------------------------------------------------------------------------------------------
    | Id  | Operation                 | Name | Rows  | Bytes | Cost (%CPU)| Time     | Inst   |IN-OUT|
    --------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT          |      |     1 |   299 |   519  (14)| 00:00:07 |        |      |
    |*  1 |  CONNECT BY WITH FILTERING|      |       |       |            |          |        |      |
    |*  2 |   FILTER                  |      |       |       |            |          |        |      |
    |   3 |    COUNT                  |      |       |       |            |          |        |      |
    |   4 |     NESTED LOOPS          |      |     1 |   299 |   519  (14)| 00:00:07 |        |      |
    |   5 |      NESTED LOOPS         |      |     1 |   217 |   517  (14)| 00:00:07 |        |      |
    |   6 |       FAST DUAL           |      |     1 |       |     2   (0)| 00:00:01 |        |      |
    |   7 |       REMOTE              | BILL |     1 |   217 |   515  (14)| 00:00:07 |  DB8I  | R->S |
    |   8 |      REMOTE               | PART |     1 |    82 |     2   (0)| 00:00:01 |  DB8I  | R->S |
    |*  9 |   HASH JOIN               |      |       |       |            |          |        |      |
    |  10 |    CONNECT BY PUMP        |      |       |       |            |          |        |      |
    |  11 |    COUNT                  |      |       |       |            |          |        |      |
    |  12 |     NESTED LOOPS          |      |     1 |   299 |   519  (14)| 00:00:07 |        |      |
    |  13 |      NESTED LOOPS         |      |     1 |   217 |   517  (14)| 00:00:07 |        |      |
    |  14 |       FAST DUAL           |      |     1 |       |     2   (0)| 00:00:01 |        |      |
    |  15 |       REMOTE              | BILL |     1 |   217 |   515  (14)| 00:00:07 |  DB8I  | R->S |
    |  16 |      REMOTE               | PART |     1 |    82 |     2   (0)| 00:00:01 |  DB8I  | R->S |
    |  17 |   COUNT                   |      |       |       |            |          |        |      |
    |  18 |    NESTED LOOPS           |      |     1 |   299 |   519  (14)| 00:00:07 |        |      |
    |  19 |     NESTED LOOPS          |      |     1 |   217 |   517  (14)| 00:00:07 |        |      |
    |  20 |      FAST DUAL            |      |     1 |       |     2   (0)| 00:00:01 |        |      |
    |  21 |      REMOTE               | BILL |     1 |   217 |   515  (14)| 00:00:07 |  DB8I  | R->S |
    |  22 |     REMOTE                | PART |     1 |    82 |     2   (0)| 00:00:01 |  DB8I  | R->S |
    --------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("DOC_NBR"='MYPARTNBR')
       2 - filter("DOC_NBR"='MYPARTNBR')
       9 - access("DOC_NBR"=NULL AND NULL='M')
    
    Remote SQL Information (identified by operation id):
    ----------------------------------------------------
    
       7 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
           R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
           "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
           "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
       8 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
           'DB8I ' )
    
      15 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
            R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
            "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
            "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
      16 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
            'DB8I ' )
    
      21 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
            R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
            "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
            "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
      22 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
            'DB8I ' )
    
    
    ...
    ...
    ...
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("DOC_NBR"='MYPARTNBR')
       2 - filter("DOC_NBR"='MYPARTNBR')
       9 - access("DOC_NBR"=NULL AND NULL='M')
    
    Remote SQL Information (identified by operation id):
    ----------------------------------------------------
    
       7 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
           R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
           "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
           "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
       8 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
           'DB8I ' )
    
      15 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
            R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
            "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
            "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
      16 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
            'DB8I ' )
    
      21 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
            R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
            "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
            "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
      22 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
            'DB8I ' )
    
    
    
    Statistics
    ----------------------------------------------------------
            381  recursive calls
              1  db block gets
              0  consistent gets
              0  physical reads
            304  redo size
          15558  bytes sent via SQL*Net to client
            417  bytes received via SQL*Net from client
              5  SQL*Net roundtrips to/from client
              6  sorts (memory)
              0  sorts (disk)
            379  rows processed
    
    SQL> disconnect
    Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    I also have the tkprof output, but let's start with that. I have absolutely no idea where to even start looking for something to improve.

    Performance would be much better if the whole query would be executed on the remote side, but the query uses the local function eval_number as well as parts of the query are executed on the remote side and results are brought alongside local and then only filtering is performed. Try the following:

    SELECT  part_nbr,
            parent_part,
            child_part,
            eval_number ('1' || path) qty
      FROM  (
             SELECT  CONNECT_BY_ROOT b.parent_part part_nbr,
                     b.parent_part,
                     b.child_part,
                     SYS_CONNECT_BY_PATH(b.qty_per, '*') path
               FROM  (
                      SELECT  doc_nbr parent_part,
                              comp_part child_part,
                              line_nbr
                              qty_per
                        FROM  bill@DB8I
                        WHERE lst_code IN ('G','M')
                          AND begn_eff <= SYSDATE
                          AND end_eff  > SYSDATE
                          AND component_type = 'R'
                          AND doc_type = 'BILL'
                          AND status  = 'RL'
                     ) b,
                     part@DB8I p
               WHERE b.child_part = p.part_nbr
               START WITH b.parent_part  = 'MYPARTNBR'
               CONNECT BY b.parent_part  = PRIOR b.child_part
                   AND PRIOR p.part_type = 'M'
            )
    /
    

    SY.

  • How to set UP a QUERY (improvement)

    Hello everyone, I'm a few oracle classes I found a delicate question in one of the slides...

    ? Create a query to view the total number of employees, and of this total, the number of employees hired in 1995, 1996, 1997 and 1998. Create column headings appropriate?

    I fact as shown below...

    SELECT DISTINCT
    (select count (to_char (hire_date, "YYYY")) of employee where to_char (hire_date, "YYYY") AS '1995') such as '1995 ',.
    (select count (to_char (hire_date, "YYYY")) of employee where to_char (hire_date, "YYYY") AS "1996") as "1996", he said.
    (select count (to_char (hire_date, "YYYY")) of employee where to_char (hire_date, "YYYY") AS '1997') as '1997 ',.
    (SELECT COUNT (TO_CHAR (HIRE_DATE, "YYYY")) OF EMPLOYEE WHERE TO_CHAR (HIRE_DATE, "YYYY") AS "1998") AS "1998".
    employee where to_char (hire_date, "YYYY") IN ('1995', '1996', '1997', ' 1998') group to_char (hire_date, "YYYY");


    I know theres another way to do with DECODE or CASE, or any other means... but I tried a lot, and it's one that I found to do...
    Will you help me get a better selection please...
    THX
    select  count(*) total,
            count(case to_char(hire_date, 'YYYY') when '1995' then 1 end) as "1995",
            count(case to_char(hire_date, 'YYYY') when '1996' then 1 end) as "1996",
            count(case to_char(hire_date, 'YYYY') when '1997' then 1 end) as "1997",
            count(case to_char(hire_date, 'YYYY') when '1998' then 1 end) as "1997"
      from  employees
    /
    
         TOTAL       1995       1996       1997       1997
    ---------- ---------- ---------- ---------- ----------
           107          4         10         28         23
    
    SQL> 
    

    SY.

  • Setting up a query - difference between 'A-lines' and 'E '.

    Hi all

    I use 11g R2 and I'm trying to deal with a request for some time now, but still no luck. Watching my plan to explain, I have a difference between my E-lines and my A. I can't understand why. Almost all my E-lines are equal to 1. All my paintings are statistics updated with as histograms.

    What else can I check?

    Thank you very much.
    /* 65671b48 */
    select distinct T1830.CAL_DT as c1,
         T17.NOM_CONTRACTANT as c2,
         T24.NOM_CONTRAT as c3,
         T2098.NAME as c4,
         T210.NOM_FLUIDE as c5,
         T160.GEO_CODE as c6,
         T160.ADDRESS as c7,
         T160.COMMUNE as c8,
         T122.NOM_OFFRE as c9,
         T1011.SERIAL_NUMBER as c10,
         T1191.METER_MODULE_REF_NO as c11,
         T2098.CUSTOM_DATA as c12,
         T217.NOM_TYP_PDC as c13,
         T949.RADIO_MODULE_REF_NO as c14,
         T786.ASSOCIATE_DATE as c15,
         T786.INSTALLATION_DATE as c16,
         T786.NB_DAYS_10_WITHOUT as c17,
         ( TRUNC( TO_DATE('2013-02-21' , 'YYYY-MM-DD') ) - TRUNC(  cast(T786.INDEX_BEFORE_MIDNIGHT_DATE as TIMESTAMP ) ) ) as c18,
         ( TRUNC( TO_DATE('2013-02-21' , 'YYYY-MM-DD') ) - TRUNC(  cast(T786.QMIN_LAST_DATE as TIMESTAMP ) ) ) as c19,
         floor(T786.INDEX_COUNT_10 * 100 / (4 * 10)) as c20,
         floor(T786.INDEX_COUNT_30 * 100 / (4 * 30)) as c21,
         T786.NB_RECEIVERS_TRANS as c22,
         T2158.TXT_PERFORMANCE as c23,
         T2186.TXT_DIAGNOSYS as c24
    from 
         DIM_CUSTOMER T2098 /* D6 Customer */ ,
         DIM_PERFORMANCE T2158 /* D7 Performance */ ,
         (
              DIM_OFFRE T122 inner join (
                   DIM_CONTRAT T24 inner join (
                        DIM_CONTRACTANT T17 inner join (
                             (
                                  (
                                       (
                                            DIM_RADIO_MODULE T949 /* D1 Radio Module */  inner join (
                                                 DIM_METER_MODULE T1191 /* D2 Meter Module */  inner join (
                                                      DIM_SERVICE_POINT T160 inner join (
                                                           DIM_DATE T1830 /* D5 Date */  inner join (
                                                                DIM_METER T1011 /* D4 Meter */  inner join FAC_DAILY_TRANS_PERFORM T786 /* F1 Fac Daily Trans Perform */  On T786.METER_KEY = T1011.METER_KEY) On T786.DATE_KEY = T1830.DATE_KEY) On T160.SERVICE_POINT_KEY = T786.SERVICE_POINT_KEY) On T786.METER_MODULE_KEY = T1191.METER_MODULE_KEY) On T786.RADIO_MODULE_KEY = T949.RADIO_MODULE_KEY) inner join DIM_TYP_PDC T217 On T160.TYP_PDC_KEY = T217.TYP_PDC_KEY) inner join DIM_TYP_FLUIDE T210 On T160.FLUIDE_KEY = T210.FLUIDE_KEY) inner join REL_SERVICE_POINT_CONTRAT T298 On T160.SERVICE_POINT_KEY = T298.SERVICE_POINT_KEY) On T17.CONTRACTANT_KEY = T298.CONTRACTANT_KEY) On T17.CONTRACTANT_KEY = T24.CONTRACTANT_KEY and T24.CONTRAT_KEY = T298.CONTRAT_KEY) On T122.OFFRE_KEY = T298.OFFRE_KEY) left outer join 
              DIM_DIAGNOSYS T2186 /* D8 Diagnosys */  On T786.DIAGNOSYS_KEY = T2186.DIAGNOSYS_KEY
    where  ( T786.CUSTOMER_KEY = T2098.CUSTOMER_KEY and T17.NOM_CONTRACTANT = 'ER Rhône Alpes Auvergne' and T24.NOM_CONTRAT = 'CHAVANOZ' and T786.PERFORMANCE_KEY = T2158.PERFORMANCE_KEY and T1830.CAL_DT = TO_DATE('2013-02-09 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') ) 
    order by c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24
    
    
    Plan hash value: 3221242991
     
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                      | Name                      | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  | Writes |  OMem |  1Mem |  O/1/M   | Max-Tmp |
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                               |                           |      1 |        |    311 |00:01:56.92 |   30325 |  19042 |     31 |       |       |          |         |
    |   1 |  SORT ORDER BY                                 |                           |      1 |     90 |    311 |00:01:56.92 |   30325 |  19042 |     31 |   279K|   279K|          |   16384 |
    |   2 |   HASH UNIQUE                                  |                           |      1 |     90 |    311 |00:01:56.89 |   30318 |  19011 |      0 |   702K|   702K|     1/0/0|         |
    |   3 |    NESTED LOOPS                                |                           |      1 |        |    311 |00:01:56.88 |   30318 |  19011 |      0 |       |       |          |         |
    |   4 |     NESTED LOOPS                               |                           |      1 |     90 |    311 |00:01:54.84 |   30007 |  18700 |      0 |       |       |          |         |
    |   5 |      NESTED LOOPS                              |                           |      1 |     90 |    311 |00:01:52.84 |   29383 |  18396 |      0 |       |       |          |         |
    |   6 |       NESTED LOOPS                             |                           |      1 |     90 |    311 |00:01:47.87 |   28448 |  17783 |      0 |       |       |          |         |
    |   7 |        NESTED LOOPS                            |                           |      1 |     90 |    311 |00:01:43.29 |   27513 |  17181 |      0 |       |       |          |         |
    |*  8 |         HASH JOIN                              |                           |      1 |     90 |    311 |00:01:39.18 |   26571 |  16559 |      0 |   909K|   909K|     1/0/0|         |
    |   9 |          TABLE ACCESS FULL                     | DIM_PERFORMANCE           |      1 |      5 |      5 |00:00:00.01 |       6 |      6 |      0 |       |       |          |         |
    |  10 |          NESTED LOOPS OUTER                    |                           |      1 |     90 |    311 |00:01:39.16 |   26565 |  16553 |      0 |       |       |          |         |
    |  11 |           NESTED LOOPS                         |                           |      1 |     90 |    311 |00:01:39.16 |   26565 |  16553 |      0 |       |       |          |         |
    |* 12 |            HASH JOIN                           |                           |      1 |    140 |    311 |00:00:04.98 |    1541 |   1170 |      0 |  1000K|  1000K|     1/0/0|         |
    |  13 |             TABLE ACCESS FULL                  | DIM_TYP_FLUIDE            |      1 |      3 |      3 |00:00:00.01 |       6 |      6 |      0 |       |       |          |         |
    |* 14 |             HASH JOIN                          |                           |      1 |    140 |    311 |00:00:04.97 |    1535 |   1164 |      0 |   955K|   955K|     1/0/0|         |
    |  15 |              TABLE ACCESS FULL                 | DIM_TYP_PDC               |      1 |      3 |      3 |00:00:00.01 |       6 |      6 |      0 |       |       |          |         |
    |  16 |              NESTED LOOPS                      |                           |      1 |        |    311 |00:00:04.96 |    1529 |   1158 |      0 |       |       |          |         |
    |  17 |               NESTED LOOPS                     |                           |      1 |    140 |    311 |00:00:02.84 |    1218 |    853 |      0 |       |       |          |         |
    |* 18 |                HASH JOIN                       |                           |      1 |    140 |    311 |00:00:00.83 |     594 |    586 |      0 |   880K|   880K|     1/0/0|         |
    |  19 |                 TABLE ACCESS FULL              | DIM_OFFRE                 |      1 |     22 |     22 |00:00:00.02 |       6 |      6 |      0 |       |       |          |         |
    |* 20 |                 HASH JOIN                      |                           |      1 |    140 |    311 |00:00:00.81 |     588 |    580 |      0 |   769K|   769K|     1/0/0|         |
    |  21 |                  NESTED LOOPS                  |                           |      1 |        |      1 |00:00:00.02 |      11 |     11 |      0 |       |       |          |         |
    |  22 |                   NESTED LOOPS                 |                           |      1 |      1 |      1 |00:00:00.02 |      10 |     10 |      0 |       |       |          |         |
    |  23 |                    NESTED LOOPS                |                           |      1 |      1 |      1 |00:00:00.02 |       9 |      9 |      0 |       |       |          |         |
    |  24 |                     TABLE ACCESS BY INDEX ROWID| DIM_DATE                  |      1 |      1 |      1 |00:00:00.01 |       3 |      3 |      0 |       |       |          |         |
    |* 25 |                      INDEX UNIQUE SCAN         | AK_DATE                   |      1 |      1 |      1 |00:00:00.01 |       2 |      2 |      0 |       |       |          |         |
    |* 26 |                     TABLE ACCESS FULL          | DIM_CONTRAT               |      1 |      1 |      1 |00:00:00.01 |       6 |      6 |      0 |       |       |          |         |
    |* 27 |                    INDEX UNIQUE SCAN           | PK_CONTRACTANT_KEY        |      1 |      1 |      1 |00:00:00.01 |       1 |      1 |      0 |       |       |          |         |
    |* 28 |                   TABLE ACCESS BY INDEX ROWID  | DIM_CONTRACTANT           |      1 |      1 |      1 |00:00:00.01 |       1 |      1 |      0 |       |       |          |         |
    |  29 |                  TABLE ACCESS FULL             | REL_SERVICE_POINT_CONTRAT |      1 |  55048 |  55048 |00:00:00.48 |     577 |    569 |      0 |       |       |          |         |
    |* 30 |                INDEX UNIQUE SCAN               | PK_SP_KEY                 |    311 |      1 |    311 |00:00:02.01 |     624 |    267 |      0 |       |       |          |         |
    |  31 |               TABLE ACCESS BY INDEX ROWID      | DIM_SERVICE_POINT         |    311 |      1 |    311 |00:00:02.11 |     311 |    305 |      0 |       |       |          |         |
    |  32 |            TABLE ACCESS BY GLOBAL INDEX ROWID  | FAC_DAILY_TRANS_PERFORM   |    311 |      1 |    311 |00:01:34.17 |   25024 |  15383 |      0 |       |       |          |         |
    |* 33 |             INDEX RANGE SCAN                   | FAC_DAY_TRAN_PERF_ID      |    311 |      1 |    311 |00:00:44.35 |   14525 |   7680 |      0 |       |       |          |         |
    |  34 |           TABLE ACCESS BY INDEX ROWID          | DIM_DIAGNOSYS             |    311 |      1 |      0 |00:00:00.01 |       0 |      0 |      0 |       |       |          |         |
    |* 35 |            INDEX UNIQUE SCAN                   | PK_DIAGNOSYS_KEY          |    311 |      1 |      0 |00:00:00.01 |       0 |      0 |      0 |       |       |          |         |
    |  36 |         TABLE ACCESS BY INDEX ROWID            | DIM_RADIO_MODULE          |    311 |      1 |    311 |00:00:04.11 |     942 |    622 |      0 |       |       |          |         |
    |* 37 |          INDEX UNIQUE SCAN                     | PK_RADMODKEY              |    311 |      1 |    311 |00:00:01.93 |     624 |    304 |      0 |       |       |          |         |
    |  38 |        TABLE ACCESS BY INDEX ROWID             | DIM_METER_MODULE          |    311 |      1 |    311 |00:00:04.58 |     935 |    602 |      0 |       |       |          |         |
    |* 39 |         INDEX UNIQUE SCAN                      | PK_METMODKEY              |    311 |      1 |    311 |00:00:02.00 |     624 |    301 |      0 |       |       |          |         |
    |  40 |       TABLE ACCESS BY INDEX ROWID              | DIM_METER                 |    311 |      1 |    311 |00:00:04.96 |     935 |    613 |      0 |       |       |          |         |
    |* 41 |        INDEX UNIQUE SCAN                       | PK_METER                  |    311 |      1 |    311 |00:00:02.42 |     624 |    304 |      0 |       |       |          |         |
    |* 42 |      INDEX UNIQUE SCAN                         | PK_CUSTOMER               |    311 |      1 |    311 |00:00:01.99 |     624 |    304 |      0 |       |       |          |         |
    |  43 |     TABLE ACCESS BY INDEX ROWID                | DIM_CUSTOMER              |    311 |      1 |    311 |00:00:02.04 |     311 |    311 |      0 |       |       |          |         |
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       8 - access("T786"."PERFORMANCE_KEY"="T2158"."PERFORMANCE_KEY")
      12 - access("T160"."FLUIDE_KEY"="T210"."FLUIDE_KEY")
      14 - access("T160"."TYP_PDC_KEY"="T217"."TYP_PDC_KEY")
      18 - access("T122"."OFFRE_KEY"="T298"."OFFRE_KEY")
      20 - access("T24"."CONTRAT_KEY"="T298"."CONTRAT_KEY" AND "T17"."CONTRACTANT_KEY"="T298"."CONTRACTANT_KEY")
      25 - access("T1830"."CAL_DT"=TO_DATE(' 2013-02-09 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      26 - filter("T24"."NOM_CONTRAT"='CHAVANOZ')
      27 - access("T17"."CONTRACTANT_KEY"="T24"."CONTRACTANT_KEY")
      28 - filter("T17"."NOM_CONTRACTANT"='ER Rhône Alpes Auvergne')
      30 - access("T160"."SERVICE_POINT_KEY"="T298"."SERVICE_POINT_KEY")
      33 - access("T786"."DATE_KEY"="T1830"."DATE_KEY" AND "T160"."SERVICE_POINT_KEY"="T786"."SERVICE_POINT_KEY")
      35 - access("T786"."DIAGNOSYS_KEY"="T2186"."DIAGNOSYS_KEY")
      37 - access("T786"."RADIO_MODULE_KEY"="T949"."RADIO_MODULE_KEY")
      39 - access("T786"."METER_MODULE_KEY"="T1191"."METER_MODULE_KEY")
      41 - access("T786"."METER_KEY"="T1011"."METER_KEY")
      42 - access("T786"."CUSTOMER_KEY"="T2098"."CUSTOMER_KEY")

    Chiwatel wrote:

    I use 11g R2 and I'm trying to deal with a request for some time now, but still no luck. Watching my plan to explain, I have a difference between my E-lines and my A. I can't understand why. Almost all my E-lines are equal to 1. All my paintings are statistics updated with as histograms.

    A lines gives you the total number of rows that were sent by content (RowSource). E - lines you gives the expected number of rows with content (RowSource) expect to spend on EVERY TIME it is called. This means that you should compare A-lines with begins * E-lines.

    In the example you showed, a lot of your miniatures of E-lines are 1 because the operation is a unique index analysis, or access to the table as a result of a unique index analysis.

    Concerning
    Jonathan Lewis

  • Sort on dynamic query problem!

    Hello

    I have a dynamic query written in pl/sql, when I check "Sort" for each field in the report attribute, error message resurrected as "ORA-01785: ORDER BY item must include the number of an expression in the SELECT list.
    If I do not check sort, it works very well. In my applications, I need all the fields sorted by user, how do I solve this problem?

    My query as below:

    declare
    Ask varchar2 (2000): = "select";
    s_class varchar2 (1000);
    cursor c1 is select * from demo_preference;
    Start
    for c1_val looping c1
    If c1_val.login is not null then
    query: query = | » ' || 'login ' | ',';
    end if;
    If c1_val.id is not null then
    query: query = | » ' || 'id ' | ',';
    end if;
    .......
    end loop;
    query: = SUBSTR (query, 1, length (query)-1);

    s_class: = ' (NVL (: P2_class, "%" |)) ''null%'') = ''%'' || "zero percent" OR
    EXISTS (SELECT 1 FROM apex_collections WHERE collection_name = "P2CLASSCOL" AND class = c001))';

    query: query = | » ' || ' from ming.reg_report_view1 where '.
    || ' ' || s_class;
    Return (Query);
    end;

    Maybe the internal column used when you clicked the sort is not indicated in the report. Try to use aliases when you build the query string, it might help apex internally to identify a column even if its order is changed to another user. After all, the order of the columns in the code is dynamic and I assume that even the number of displayed columns can vary that could sort on a column that is identified by a number not valid.

    How about somewhere, displaying the report query so that you know what is the exact query processing, it could give you the best information on the problem.

    If the problem persists, use a collection that is extracted these record using the same query string, then replace the report to view the collection and then set the sort column on. This way Summit could get confused about which columns are being sorted and it would just sort on a c001... C050 column as if it were a string (Yes problems with the number of sort columns when you do this).

  • report Classic select value of the element to set another point/region on the same page

    1.I have classic in the area of form, reportthe user must select online (single or multiple) box/radio classic report these lines to set another region (query are same with selected element only). but when we save the values selected as a delimited values (1:2:3:5) in an item (P9_TO_MOVE_ITEM).

    How can get the report? I mean the where condition. If any other way to do it?

    workspace: ram_r & d

    username/password: aramani/apex

    application: https://apex.oracle.com/pls/apex/f?p=29288:9

    Hi, thanks. its working fine.

    1. add values as shuttle (P9_TO_MOVE_ITEM) items in the form box, that will store in 1:2:3:4 of database column values

    Then add the new report with the following classic area.

    WITH delimited AS (SELECT  REPLACE(:P9_TO_MOVE_ITEM,':', ':') vals FROM DUAL)
    SELECT *
      FROM emp, delimited
    WHERE INSTR (':' || delimited.vals || ':', ':' || deptno || ':') > 0;
    
  • How to exclude records from the outer query

    My apologies if this was requested. I find no answer. I don't know what terminology should be for that matter.

    In simple terms, I want to use the custom in where clause to select records. Problem is function will fail if applied to old records, as there was no relevant data. I have logic to exclude old records, but the problem is that this process running function before old records are excluded. I tried an inside view to exclude records before their passage in the outer query, but this does not resolve the situation.

    Below shows high level required

    Select x

    tab

    where (condition to exclude the old records)

    and function (tab.y) = value

    If I rewrite as below, still have the problem. Was hoping to exclude former records apply before function.

    Select inn.x

    Of

    (select x,

    There

    tab

    where (condition to exclude the old records)) inn

    where function (inn.y) = value

    Thank you

    Hello

    Including ROWNUM in the result set of the query-void will force the subquery to do first:

    Select inn.x

    Of

    (select x,

    There,

    ROWNUM AS r

    tab

    where (condition to exclude the old records)

    ) inn

    where the function (inn.y) = some_value

    Since ROWNUM depends on the WHERE clause of the query-sup, the query cannot be rewritten to the main to do first query WHERE clause.

  • Hotkey of the worksheet area of writing in the result set

    Y at - it a keyboard shortcut to switch between writing in the SQL worksheet and navigate (or copy,...) in the result set of a query run?

    That would make my job easier everyday!

    @Chris

    ALT + PagegDown in version 4.0

    No no not a nav of Ko to this v3.2 and earlier versions, has been saved as a bug.

Maybe you are looking for