<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Native SQL query - Need help in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-query-need-help/m-p/4199720#M1003731</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Neethu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It gives you an overwiew of blocking Oracle sessions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. In general, the SQL checks Oracle sessions (SID's) that were requirering a DML lock ('TM') and now holding row locks (TX)  to prevent destructive interference of simultaneous conflicting DML or DDL operations. DML statements automatically acquire both table-level locks and row-level locks ('TX')  &lt;STRONG&gt;=&amp;gt; holders&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It joins these with the sessions that are waiting of releasing the lock by the holders  &lt;STRONG&gt;=&amp;gt; waiters.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. it retrieves the detail information wich  Oracle process , the object (table) , it's row , block  and file &lt;/P&gt;&lt;P&gt;are affected by the locks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Normally, the locks are only hold for a short period of time. If you have blocking sessions it may be of a log running task (i.e. mass data update of a table) ; but it could also be a application bug due to improper handling of concurrent updates of the same object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Tuning&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;V$tables are expensive to query: Why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v$ tables are generally Oracle memory structures.&lt;/P&gt;&lt;P&gt;v$ tables are not read consistent.&lt;/P&gt;&lt;P&gt;v$ tables require latches to access -- cannot modify and read memory at the same &lt;/P&gt;&lt;P&gt;time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;heavy access to v$ tables like this may cause some serious heavy duty contention.&lt;/P&gt;&lt;P&gt;Especially if you self join V$lock several times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the best would be to save the contents of V$LOCK in some table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Create table mylocks as select * from v$lock;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use that table for self-joining and joins to the other tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also CTAS the other v$ tables to bypass the performance bottleneck while retrieving &lt;/P&gt;&lt;P&gt;v$ directly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can empty or drop the created tables any time for new data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because you want to investigate only lock hold for a longert time  to copy the v$ memory structures into&lt;/P&gt;&lt;P&gt;physical tables is not a disadvantage. You certainly will wait longer on finishing your query &lt;/P&gt;&lt;P&gt;instead of copy them into the tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helped&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Jul 2008 07:53:08 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-15T07:53:08Z</dc:date>
    <item>
      <title>Native SQL query - Need help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-query-need-help/m-p/4199718#M1003729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have a native SQL query accessing Oracle database(given below). &lt;/P&gt;&lt;P&gt;Can anyone please let me know what this query is about and how can we fine tune the query? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT O.OBJECT_NAME ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               H.SID,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               HS.MACHINE,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               HS.PROCESS,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               W.SID,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               WS.MACHINE,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               WS.PROCESS,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               H.CTIME,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               W.CTIME,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               WS.ROW_WAIT_OBJ#,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               WS.ROW_WAIT_FILE#,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               WS.ROW_WAIT_BLOCK#,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               WS.ROW_WAIT_ROW#,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               HP.SPID,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;               WP.SPID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        FROM V$LOCK H, V$LOCK W, V$LOCK I, V$LOCK I2, ALL_OBJECTS O,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             V$SESSION HS, V$SESSION WS, V$PROCESS HP, V$PROCESS WP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        WHERE   H.ID1 = W.ID1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     H.SID &amp;lt;&amp;gt; W.SID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     H.TYPE IN ('TX','DL')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     H.REQUEST = 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     H.SID = I.SID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     I.TYPE = 'TM'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     I.ID1 = O.OBJECT_ID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     I.ID1 = I2.ID1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     W.SID = I2.SID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     I2.TYPE = 'TM'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     H.SID = HS.SID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     W.SID = WS.SID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     HS.PADDR = HP.ADDR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        AND     WS.PADDR = WP.ADDR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        INTO :EXCL_LOCK_WAITERS-OBJ_NAME   ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :EXCL_LOCK_WAITERS-HOLDER_SID ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :EXCL_LOCK_WAITERS-H_HOSTNAME ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;            :EXCL_LOCK_WAITERS-HOLDER_PID ,&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :HOLDER_PID ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :EXCL_LOCK_WAITERS-WAITER_SID ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :EXCL_LOCK_WAITERS-W_HOSTNAME ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;            :EXCL_LOCK_WAITERS-WAITER_PID ,&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :WAITER_PID ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :EXCL_LOCK_WAITERS-HELD_SINCE ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :EXCL_LOCK_WAITERS-WAITSSINCE,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :ROW_WAIT_OBJ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :ROW_WAIT_FILE,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :ROW_WAIT_BLOCK,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :ROW_WAIT_ROW,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :H_PROCESS,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             :W_PROCESS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ENDEXEC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Neethu Mohan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 06:12:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-query-need-help/m-p/4199718#M1003729</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T06:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL query - Need help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-query-need-help/m-p/4199719#M1003730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check the link for native SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;anirban&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 06:14:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-query-need-help/m-p/4199719#M1003730</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T06:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL query - Need help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-query-need-help/m-p/4199720#M1003731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Neethu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It gives you an overwiew of blocking Oracle sessions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. In general, the SQL checks Oracle sessions (SID's) that were requirering a DML lock ('TM') and now holding row locks (TX)  to prevent destructive interference of simultaneous conflicting DML or DDL operations. DML statements automatically acquire both table-level locks and row-level locks ('TX')  &lt;STRONG&gt;=&amp;gt; holders&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It joins these with the sessions that are waiting of releasing the lock by the holders  &lt;STRONG&gt;=&amp;gt; waiters.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. it retrieves the detail information wich  Oracle process , the object (table) , it's row , block  and file &lt;/P&gt;&lt;P&gt;are affected by the locks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Normally, the locks are only hold for a short period of time. If you have blocking sessions it may be of a log running task (i.e. mass data update of a table) ; but it could also be a application bug due to improper handling of concurrent updates of the same object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Tuning&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;V$tables are expensive to query: Why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v$ tables are generally Oracle memory structures.&lt;/P&gt;&lt;P&gt;v$ tables are not read consistent.&lt;/P&gt;&lt;P&gt;v$ tables require latches to access -- cannot modify and read memory at the same &lt;/P&gt;&lt;P&gt;time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;heavy access to v$ tables like this may cause some serious heavy duty contention.&lt;/P&gt;&lt;P&gt;Especially if you self join V$lock several times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the best would be to save the contents of V$LOCK in some table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Create table mylocks as select * from v$lock;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use that table for self-joining and joins to the other tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also CTAS the other v$ tables to bypass the performance bottleneck while retrieving &lt;/P&gt;&lt;P&gt;v$ directly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can empty or drop the created tables any time for new data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because you want to investigate only lock hold for a longert time  to copy the v$ memory structures into&lt;/P&gt;&lt;P&gt;physical tables is not a disadvantage. You certainly will wait longer on finishing your query &lt;/P&gt;&lt;P&gt;instead of copy them into the tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helped&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 07:53:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-query-need-help/m-p/4199720#M1003731</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T07:53:08Z</dc:date>
    </item>
  </channel>
</rss>

