{"id":1616,"date":"2010-11-03T12:00:00","date_gmt":"2010-11-03T12:00:00","guid":{"rendered":"http:\/\/orcldoug.com\/blog\/?p=1616"},"modified":"2010-11-03T12:00:00","modified_gmt":"2010-11-03T12:00:00","slug":"poor-performance-when-gathering-partitions-stats-in-11g","status":"publish","type":"post","link":"http:\/\/orcldoug.com\/blog\/2010\/11\/03\/poor-performance-when-gathering-partitions-stats-in-11g\/","title":{"rendered":"Poor performance when gathering partitions stats in 11g"},"content":{"rendered":"<p>\nBeing busy at work is both a blessing and a curse to blogging activity. On the one hand, the more that&#8217;s going on, the more technical issues there are likely to be to blog about. On the other, when the pace is frantic and problems are coming thick and fast, taking good notes isn&#8217;t a priority (although it&#8217;s probably even more important). So this blog post has been stuck in the same place for weeks because when the problem occurred, I didn&#8217;t take enough notes and I have struggled to recreate it in my own environment. It was sucking up so much time that I almost decided not to post it but I&#8217;ll post what few details I remember in case it helps some desperate Google-scavenger one day.<\/p>\n<p>We were migrating one of our main databases to version 11.2.0.1 and restructuring a large partitioned table at the same time. However, when we started trying to gather opitimiser statistics on the partitions of the table, performance was atrocious. Our approach was to gather the statistics at the Partition level, one partition at a time so that when all partitions had stats, they would be aggregated up to the table level as approximated global stats. At this point you might wonder why we didn&#8217;t just use 11g new features and gather stats at the default granularity and sample size. We did try that several times, but gave up after several hours of running. The intention of the project was to simply port the existing system to 11.2.0.1 with the minimum number of changes and look at exploiting new features later. As usual, that was largely driven by our deadlines &#128577;<\/p>\n<p>Although I don&#8217;t have the exact timings to hand, I recall it was taking about 3 minutes to gather stats on each partition where we&#8217;d normally expect it to take a few seconds. We spent days trying to work out what was going on and the two main symptoms were <\/p>\n<p>Many executions of the following statement.<\/p>\n<pre>SELECT \/*+ rule *\/ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#, sample_size,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MINIMUM, maximum, distcnt, lowval, hival, density, col#, spare1, spare2, avgcln\nFROM hist_head$\nWHERE obj# = :1 AND intcol# = :2\n<\/pre>\n<p>and DML row locks on WRI$_OPTSTAT_HISTHEAD_HISTORY.<\/p>\n<p>As we became more desperate to solve the problem and the deadline approached, I fell back on an old, basic but often successful technique. Compare what was different on the new database to the old one and noticed that the new database was missing Global Stats on the table. That made sense, though, because our <em>intention<\/em> was to use Aggregated Global Stats and as we hadn&#8217;t gathered stats on all of the partitions, Global Stats shouldn&#8217;t exist at that stage. But it still bugged me because that was the only difference I could see (apart from one database being on 10.2.0.3 and the other on 11.2.0.1 of course).<\/p>\n<p>Rooting around Metalink, I also came upon bug number 282598.1 which was inappropriate because it was for a completely different version, had been fixed and the problem description was different, but it looked like it was in the same area of functionality so it was perhaps another little pointer to what might be going on.\u00a0 <\/p>\n<p> To cut a long story short (one that included a brief email exchange with <a href=\"http:\/\/structureddata.org\">Greg Rahn<\/a>), eventually I suggested we gather Global Stats just to reassure myself that wasn&#8217;t the problem. As soon as we did, the partition stats gathering performance went back to what we&#8217;d expect. Obviously we needed to regather Global Stats once all the Partition stats were in place and then we&#8217;d have to implement something to keep the Global Stats up to date.<\/p>\n<p>As I suggested at the start, that&#8217;s not as much detail as I&#8217;d expect to include normally but hopefully it&#8217;s another example of why you avoid gathering Global Stats and using default Oracle functionality at your peril.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Being busy at work is both a blessing and a curse to blogging activity. On the one hand, the more that&#8217;s going on, the more technical issues there are likely to be to blog about. On the other, when the pace is frantic and problems are coming thick and fast, taking good notes isn&#8217;t a&hellip; <a class=\"more-link\" href=\"http:\/\/orcldoug.com\/blog\/2010\/11\/03\/poor-performance-when-gathering-partitions-stats-in-11g\/\">Continue reading <span class=\"screen-reader-text\">Poor performance when gathering partitions stats in 11g<\/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-1616","post","type-post","status-publish","format-standard","hentry","category-uncategorized","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":1098,"url":"http:\/\/orcldoug.com\/blog\/2006\/10\/04\/the-very-last-final-dbf-blog-really\/","url_meta":{"origin":1616,"position":0},"title":"The Very Last, Final DBF Blog, really &#8230;","date":"October 4, 2006","format":false,"excerpt":"It's been back to work with a vengeance this week, but quite enjoyable as I've been spending time explaining to one of the vendors on a super-expensive project that RAC won't deliver what they're looking for. However, I feel there's some unfinished business before I get back to the occasional\u2026","rel":"","context":"With 8 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1071,"url":"http:\/\/orcldoug.com\/blog\/2006\/08\/30\/the-devaluation-of-training\/","url_meta":{"origin":1616,"position":1},"title":"The Devaluation of Training","date":"August 30, 2006","format":false,"excerpt":"Howard Rogers has an interesting post on his blog at the moment that is particularly timely from my perspective and that I agree with whole-heartedly. Companies seem increasingly loathe to commit adequate funds and, probably more significantly, staff time to training (although that could be my imagination).Having said that, a\u2026","rel":"","context":"With 20 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1216,"url":"http:\/\/orcldoug.com\/blog\/2007\/02\/27\/pythian-goodies-px\/","url_meta":{"origin":1616,"position":2},"title":"Pythian Goodies &#8211; PX","date":"February 27, 2007","format":false,"excerpt":"When I was in Ottawa, Christo Kutrovsky asked me to talk about Parallel Execution for the series of Pythian Goodies he's organising. After I'd done it, I insisted that he let me see the video before it was published on the web so that I could make sure that I\u2026","rel":"","context":"With 12 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":911,"url":"http:\/\/orcldoug.com\/blog\/2005\/11\/06\/a-better-index-hint\/","url_meta":{"origin":1616,"position":3},"title":"A better INDEX hint","date":"November 6, 2005","format":false,"excerpt":"One of my old Sun colleagues, Jari Kuhanen, mentioned to me that he hoped to see more tips from the UKOUG conference appearing on blogs. Sadly, the few notes I made might as well be in Greek for all the sense they make to me when I read them, but\u2026","rel":"","context":"With 2 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1335,"url":"http:\/\/orcldoug.com\/blog\/2007\/11\/01\/rac-and-aix\/","url_meta":{"origin":1616,"position":4},"title":"RAC and AIX","date":"November 1, 2007","format":false,"excerpt":"One of the interesting aspects of working at my current site is that the DBAs don't install Oracle. Yes, I know, and I'm not going to elaborate on that statement other than to say it's a little frustrating and software management has become a much more interesting experience than I\u2026","rel":"","context":"With 2 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1423,"url":"http:\/\/orcldoug.com\/blog\/2008\/08\/03\/dude-its-a-blog\/","url_meta":{"origin":1616,"position":5},"title":"dude &#8211; it&#8217;s a blog","date":"August 3, 2008","format":false,"excerpt":"Well, I'm back from two weeks holiday away from the net and a pile of blog comments and emails to catch up on. I'll leave those for tomorrow. A quickie for now, though. I see that Kurt van Meerbeeck (yeah, OK, Kurt the DUDE guy) has finally started a blog.\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/posts\/1616","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=1616"}],"version-history":[{"count":0,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/posts\/1616\/revisions"}],"wp:attachment":[{"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/media?parent=1616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/categories?post=1616"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/tags?post=1616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}