{"id":1231,"date":"2007-03-10T12:00:00","date_gmt":"2007-03-10T12:00:00","guid":{"rendered":"http:\/\/orcldoug.com\/blog\/?p=1231"},"modified":"2007-03-10T12:00:00","modified_gmt":"2007-03-10T12:00:00","slug":"how-can-i-tell-the-actual-dop-used-for-my-parallel-query","status":"publish","type":"post","link":"http:\/\/orcldoug.com\/blog\/2007\/03\/10\/how-can-i-tell-the-actual-dop-used-for-my-parallel-query\/","title":{"rendered":"How can I tell the actual DOP used for my Parallel Query?"},"content":{"rendered":"<p>At the end of my presentation this week, when I asked for questions, a lady from the middle of the hall piped up to ask something along the lines of.<\/p>\n<p>&#8220;<i>How can I tell the actual DOP used for my Parallel Query?<\/i>&#8221; (or words to that effect)<\/p>\n<p>It was in the context of me saying that you need to know the number of process&#8217; trace files that have been consolidated by trcsess. <\/p>\n<p>A gentleman who I remember from last year&#8217;s Symposium also came along to my presentation this year and repeated a similar question later. Before we go any further, all of this is Oracle 10.2.0.2 but should apply equally well to other versions as far as I know.<\/p>\n<p>My personal approach when writing papers and running tests has always been to use the V$PQ_TQSTAT dictionary view after my query has run because that contains reasonably detailed information about the Data Flow Operations, rows processed etc. However, that&#8217;s not particularly useful for the type of &#8216;<i>was my query down-graded<\/i>?&#8217; question that most are interested in during the day to day running of their applications (or maybe it is &#8211; we&#8217;ll see later).<\/p>\n<p>At work, I&#8217;ve tended to use the &#8216;Parallel operations downgraded &#8230;&#8217; statistics in V$SYSSTAT in a Statspack report as Jeff Moss does in the first part of <a href=\"http:\/\/oramossoracle.blogspot.com\/2006\/07\/parallel-downgrades-to-serial-after.html\">this blog<\/a>. This works well as a system wide check and possibly during a batch run when the number of concurrent jobs is smaller and it&#8217;s easier to identify a particular problem. <\/p>\n<p>However, if you have multiple users or applications running parallel queries throughout the day (or even in that batch schedule), it could be very useful to have a post-run log of the actual DOP used, if you could instrument your code accordingly. A few people standing in the same group suggested using the DEGREE and REQ_DEGREE columns of V$PX_SESSION. Jeff has an interesting twist on this approach in the second half of the afore-mentioned blog as he captured the contents of this view in a table. However, even though this could indicate specific sessions (via the QCSID column that you could use to tie the rows to a specific Query Coordinator), I don&#8217;t think it meets the original requirement for a simple reason. You must catch the information while the query is running or it will disappear. To illustrate :-<\/p>\n<pre>$ sqlplus testuser\/testuser<br\/><br\/>SQL*Plus: Release 10.2.0.2.0 - Production on Fri Mar 9 23:33:49 2007<br\/><br\/>Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.<br\/><br\/><br\/>Connected to:<br\/>Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production<br\/>With the Partitioning, OLAP and Data Mining options<br\/><br\/>SQL&gt; select \/*+ parallel(test_tab1) *\/<br\/>  2     mod(pk_id, 2), count(*)<br\/>  3  from test_tab1<br\/>  4  group by mod(pk_id, 2);<br\/><br\/>MOD(PK_ID,2)   COUNT(*)<br\/>------------ ----------<br\/>           1   32768000<br\/>           0   32768000<br\/><br\/>SQL&gt; select * from v$px_session;<br\/><br\/>no rows selected<\/pre>\n<p><\/p>\n<p>The important thing to note here is that I ran the second statement immediately after the first. (If I run the same check in a seperate session whilst the main PX query is running, I can see the information I&#8217;m looking for but, once the main PX query completes, the relevant information disappears)<\/p>\n<p>Now, lest you think that maybe the query didn&#8217;t run in parallel for some reason, I&#8217;ll immediately run another query &#8211; against V$PQ_TQSTAT. (One that Jonathan Lewis &#8216;loaned me&#8217; a while back &#8211; I&#8217;ll give it back soon.)<\/p>\n<pre>SQL&gt; SELECT dfo_number, tq_id, server_type, process, num_rows, bytes<br\/>  2  FROM v$pq_tqstat<br\/>  3  ORDER BY dfo_number DESC, tq_id, server_type DESC , process<br\/>  4  \/<br\/><br\/>DFO_NUMBER      TQ_ID SERVER_TYPE                    PROCESS    NUM_ROWS      BYTES<br\/>---------- ---------- ------------------------------ -------- ---------- ----------<br\/>         1          0 Producer                       P008              2        191<br\/>         1          0 Producer                       P009              2        191<br\/>         1          0 Producer                       P010              2        191<br\/>         1          0 Producer                       P011              2        191<br\/>         1          0 Producer                       P012              2        191<br\/>         1          0 Producer                       P013              2        191<br\/>         1          0 Producer                       P014              2        191<br\/>         1          0 Producer                       P015              2        191<br\/>         1          0 Consumer                       P000              0        160<br\/>         1          0 Consumer                       P001              0        160<br\/>         1          0 Consumer                       P002              8        288<br\/>         1          0 Consumer                       P003              0        160<br\/>         1          0 Consumer                       P004              0        160<br\/>         1          0 Consumer                       P005              8        280<br\/>         1          0 Consumer                       P006              0        160<br\/>         1          0 Consumer                       P007              0        160<br\/>         1          1 Producer                       P000              0         20<br\/>         1          1 Producer                       P001              0         20<br\/>         1          1 Producer                       P002              1         30<br\/>         1          1 Producer                       P003              0         20<br\/>         1          1 Producer                       P004              0         20<br\/>         1          1 Producer                       P005              1         29<br\/>         1          1 Producer                       P006              0         20           <br\/>         1          1 Producer                       P007              0         20<br\/>         1          1 Consumer                       QC                2        179<br\/><br\/>25 rows selected.<\/pre>\n<p>So there are two <i>sets <\/i>of slaves being used for this query, one set of which are acting as both consumers and producers, and I can see that a DOP of 8 is being used. You could capture this information in a different way for a possible application log entry.<\/p>\n<pre>SQL&gt; select count(distinct process)<br\/>  2  from v$pq_tqstat<br\/>  3  where process like 'P%';<p><br\/>COUNT(DISTINCTPROCESS)<br\/>----------------------<br\/>                    16<\/p><\/pre>\n<p>Rather than the actual DOP, this shows the number of slave processes used &#8211; DOP * 2 &#8211; (8 * 2 in this case), but you can manipulate that easily if you want. However, I might argue that the DOP isn&#8217;t so significant as the number of slaves used, particularly bearing in mind that the reduced DOP could be caused by a lack of available slaves. Whatever you choose, this is clearly a possibility although I have seen the odd case (and Jonathan L. has told me in the past that he&#8217;s seen more) where the contents of V$PQ_TQSTAT can be unreliable.<\/p>\n<p>Here&#8217;s another possible approach using the &#8216;Parallel operations &#8230;&#8217; statistics, but for this session. It lacks the detail of DOP used, but I think what many people will be interested in is &#8216;Was my DOP reduced&#8217; and this would help with that.<\/p>\n<pre>SQL&gt; l<br\/>  1  select n.name, s.value<br\/>  2  from v$mystat s, v$statname n<br\/>  3  where s.statistic# = n.statistic#<br\/>  4* and n.name like 'Parallel%'<br\/>SQL&gt; \/<br\/><br\/>NAME                                              VALUE<br\/>-------------------------------------------- ----------<br\/>Parallel operations not downgraded                    1<br\/>Parallel operations downgraded to serial              0<br\/>Parallel operations downgraded 75 to 99 pct           0<br\/>Parallel operations downgraded 50 to 75 pct           0<br\/>Parallel operations downgraded 25 to 50 pct           0<br\/>Parallel operations downgraded 1 to 25 pct            0<br\/><br\/>6 rows selected.<\/pre>\n<p>In due course, when he&#8217;s worked his way through his probably much bigger pile of questions from the two seminars he&#8217;s presented at this week, I expect Jonathan Lewis will pop his head around the metaphorical door and offer a definitive answer. I haven&#8217;t asked him about that, I just have a feeling he might;-)<\/p>\n<p>The gentleman who was asking me the question yesterday told me he&#8217;d be staying until Sunday so hopefully I&#8217;ll bump into him (and remember his name!!!) or he&#8217;ll read this blog and I certainly hope the original questioner (can&#8217;t help you with a name there either!) will see this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At the end of my presentation this week, when I asked for questions, a lady from the middle of the hall piped up to ask something along the lines of. &#8220;How can I tell the actual DOP used for my Parallel Query?&#8221; (or words to that effect) It was in the context of me saying&hellip; <a class=\"more-link\" href=\"http:\/\/orcldoug.com\/blog\/2007\/03\/10\/how-can-i-tell-the-actual-dop-used-for-my-parallel-query\/\">Continue reading <span class=\"screen-reader-text\">How can I tell the actual DOP used for my Parallel Query?<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1231","post","type-post","status-publish","format-standard","hentry","category-uncategorized","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":1319,"url":"http:\/\/orcldoug.com\/blog\/2007\/09\/23\/parallel-query-and-11g\/","url_meta":{"origin":1231,"position":0},"title":"Parallel Query and 11g","date":"September 23, 2007","format":false,"excerpt":"I've been playing around with 11g on and off this week, re-running some of the tests in this document (PDF file).The main edits required to the scripts were simple ones to correct the locations of trace files, for example (where $ORACLE_BASE is \/ora on the 10g system) rm \/ora\/admin\/TEST1020\/udump\/*.trc and\u2026","rel":"","context":"With 7 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":835,"url":"http:\/\/orcldoug.com\/blog\/2006\/03\/14\/px-and-the-magic-of-2\/","url_meta":{"origin":1231,"position":1},"title":"PX and &#8220;the Magic of 2&#8221;","date":"March 14, 2006","format":false,"excerpt":"Now that I've had time to sit back and relax and absorb things a little, I thought I should fix a couple of outright bugs in the recent PX paper (Later update - link to the paper) and revisit the conclusions before moving on to testing different aspects. First, the\u2026","rel":"","context":"With 2 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":902,"url":"http:\/\/orcldoug.com\/blog\/2005\/11\/18\/hotsos-symposium-2006\/","url_meta":{"origin":1231,"position":2},"title":"Hotsos Symposium 2006","date":"November 18, 2005","format":false,"excerpt":"My goodness, nearly a week without a blog posting and my review of Jonathan's book still hasn't appeared. It's been a crazy week at work and what little spare time I've had has been spent on getting my server installed. It looks like I won't be able to get wireless\u2026","rel":"","context":"With 6 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1363,"url":"http:\/\/orcldoug.com\/blog\/2007\/12\/04\/murali-vallath\/","url_meta":{"origin":1231,"position":3},"title":"Murali Vallath","date":"December 4, 2007","format":false,"excerpt":"When I blogged about Openworld, I decided not to mention one presentation at the time. I attended Murali Vallath's \"Oracle Parallel Query Feature in a RAC environment\" on Sunday afternoon. I almost didn't because I know the subject pretty well, but I thought I might learn something or see a\u2026","rel":"","context":"With 42 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1513,"url":"http:\/\/orcldoug.com\/blog\/2009\/07\/30\/awr-differences-report\/","url_meta":{"origin":1231,"position":4},"title":"AWR Differences Report","date":"July 30, 2009","format":false,"excerpt":"Some features in this post require a Diagnostics Pack license.This morning I had an opportunity to use one of my favourite AWR tools, the differences report. Our system has a fairly involved overnight batch schedule consisting of multiple concurrent job streams that starts at 02:00 and usually completes at about\u2026","rel":"","context":"With 12 comments","img":{"alt_text":"","src":"\/serendipity\/uploads\/awrdd2.png","width":350,"height":200},"classes":[]},{"id":1559,"url":"http:\/\/orcldoug.com\/blog\/2010\/02\/09\/advert-symposium-countdown\/","url_meta":{"origin":1231,"position":5},"title":"Advert: Symposium Countdown","date":"February 9, 2010","format":false,"excerpt":"I submitted my slides last Friday so the Hotsos Symposium countdown has really started now - I'll be presenting in just under 4 weeks time. I'm looking forward to it even more than I was for a couple of reasons.1) I noticed from Kerry Osborne's blog post that he's now\u2026","rel":"","context":"With 6 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/posts\/1231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/comments?post=1231"}],"version-history":[{"count":0,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/posts\/1231\/revisions"}],"wp:attachment":[{"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/media?parent=1231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/categories?post=1231"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/tags?post=1231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}