Poor performance when gathering partitions sta ...

Doug's Oracle Blog

  • Home
  • Papers
  • Books
  • C.V.
  • Fun
  • Oracle Blog
  • Personal Blog

Nov 3: Poor performance when gathering partitions stats in 11g

Being busy at work is both a blessing and a curse to blogging activity. On the one hand, the more that'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't a priority (although it'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'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'll post what few details I remember in case it helps some desperate Google-scavenger one day.

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'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 :-(

Although I don't have the exact timings to hand, I recall it was taking about 3 minutes to gather stats on each partition where we'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

Many executions of the following statement.

SELECT /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#, sample_size,
       MINIMUM, maximum, distcnt, lowval, hival, density, col#, spare1, spare2, avgcln
FROM hist_head$
WHERE obj# = :1 AND intcol# = :2

and DML row locks on WRI$_OPTSTAT_HISTHEAD_HISTORY.

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 intention was to use Aggregated Global Stats and as we hadn't gathered stats on all of the partitions, Global Stats shouldn'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).

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. 

To cut a long story short (one that included a brief email exchange with Greg Rahn), eventually I suggested we gather Global Stats just to reassure myself that wasn't the problem. As soon as we did, the partition stats gathering performance went back to what we'd expect. Obviously we needed to regather Global Stats once all the Partition stats were in place and then we'd have to implement something to keep the Global Stats up to date.

As I suggested at the start, that's not as much detail as I'd expect to include normally but hopefully it's another example of why you avoid gathering Global Stats and using default Oracle functionality at your peril.

Posted by Doug Burns Comments: (10) Trackback: (1)

Trackbacks
Trackback specific URI for this entry

PingBack
Weblog: jonathanlewis.wordpress.com
Tracked: Nov 12, 09:02

Comments
Display comments as (Linear | Threaded)

#1 - Coskan Gundogar said:
2010-11-04 09:04 - (Reply)

Doug,

Thanks for sharing the findings . One question Are you using incrementally updated global stats option for 11g. It is not clear from the blog post.

#2 - Doug Burns said:
2010-11-04 10:21 - (Reply)

No, we're not. That's what I meant by us not using any appropriate new features yet. But I have some posts coming up on that (one day) based on work at home.

#3 - Dominic Brooks said:
2010-11-04 12:03 - (Reply)

Instantly reminded me of one of Martin's posts ... where is it ... here it is ... about stats needing stats to gather stats:
http://mwidlake.wordpress.com/2010/02/16/stats-need-stats-to-gather-stats/

#4 - Doug Burns said:
2010-11-05 08:41 - (Reply)

Ah, thanks Dom! As soon as I read your comment I remembered Martin's post ;-)

#5 - Sokrates said:
2010-11-05 12:48 - (Reply)

"Rooting around Metalink, I also came upon bug number xyz 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. "

sounds like on an old, basic but often successful technique. :-)

BTW
incrementally updated statistics rock ! (11.2.0.2)

#6 - Doug Burns said:
2010-11-05 14:52 - (Reply)

:-)

incrementally updated statistics rock ! (11.2.0.2)

I hope so. Planning to use them on my new project

#7 - Grzegorz 2010-11-19 07:26 - (Reply)

Doug,
the problem is related to unpublished bug 5882954.
As a workaround You can try alter session set "_improved_row_length_enabled" = false; or systemwide :-).
Dont know about impact on other functionality :-) so dont try in production :-).
Regards.
Grzegorz

#8 - Doug Burns said:
2010-11-19 12:35 - (Reply)

That's very interesting Grzegorz, thanks. I'll check it out.

#9 - Paul B. 2011-08-04 15:01 - (Reply)

Thanks for helping another desperate Google-scavenger.

#10 - Doug Burns said:
2011-08-04 15:09 - (Reply)

You're welcome!


Add Comment

Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
BBCode format allowed
 
 

Statistics on Partitioned Tables

Contents

Part 1 - Default options - GLOBAL AND PARTITION
Part 2 - Estimated Global Stats
Part 3 - Stats Aggregation Problems I
Part 4 - Stats Aggregation Problems II
Part 5 - Minimal Stats Aggregation
Part 6a - COPY_TABLE_STATS - Intro
Part 6b - COPY_TABLE_STATS - Mistakes
Part 6c - COPY_TABLE_STATS - Bugs and Patches
Part 6d - COPY_TABLE_STATS - A Light-bulb Moment
Part 6e - COPY_TABLE_STATS - Bug 10268597

Comments

Doug Burns about 10053 Trace Files - Different Plan in Different Environments
Tue, 02.04.2013 08:57
You're welcome. Now I just nee d to pull my finger out and ac tually come up [...]
Howard Rogers about 10053 Trace Files - Different Plan in Different Environments
Mon, 01.04.2013 23:08
Makes a big difference, so tha nks for that! With two brow ser windows, o [...]
stelioscharalambides.com about 10053 Trace Files
Sat, 30.03.2013 16:28

Upcoming Presentations

Bookmark

Open All | Close All

Syndicate This Blog

  • XML RSS 2.0 feed
  • ATOM/XML ATOM 1.0 feed
  • XML RSS 2.0 Comments
  • Feedburner Feed

Powered by

Serendipity PHP Weblog

Show tagged entries

xml 11g
xml ACE
xml adaptive thresholds
xml ASH
xml Audit Vault
xml AWR
xml Blogging
xml conferences
xml Cuddly Toys
xml Database Refresh
xml DBMS_STATS
xml Direct Path Reads
xml Fun
xml grid control
xml hotsos 2010
xml listener
xml Locking
xml oow
xml oow2009
xml optimiser
xml OTN
xml Parallel
xml Partitions
xml Patching
xml swingbench
xml The Reality Gap
xml time matters
xml ukoug
xml ukoug2009
xml Unix/Shell
xml Useful Links

Disclaimer

For the avoidance of any doubt, all views expressed here are my own and not those of past or current employers, clients, friends, Oracle Corporation, my Mum or, indeed, Flatcat. If you want to sue someone, I suggest you pick on Tigger, but I hope you have a good lawyer. Frankly, I doubt any of the former agree with my views or would want to be associated with them in any way.

Design by Andreas Viklund | Conversion to s9y by Carl