Oracle Scratchpad

August 28, 2009

Quiz Night

Filed under: Infrastructure,Performance,Troubleshooting — Jonathan Lewis @ 5:51 pm UTC Aug 28,2009

I was using my “recent sql” check on client site some time ago, and found that one of their programmers had clearly been advised to make use of bind variables when writing SQL for an OLTP system, because I found code like the following in the library cache:


select   customer_name from customers where cust_id = :v_104356;

Seems okay so far – but the second statement dumped by my query looked like this:


select   customer_name from customers where cust_id = :v_27054;

And so it went on – I found about 30 statements like this that had appeared in the previous 60 seconds. The developer was using bind variables but managing to do it in a way that caused a “hard parse” on every statement.

I couldn’t help smiling when I saw this, then I paused to ask myself if this was a deliberate design decision and if so what possible justification there could be for doing something like this. And then I thought of a rational answer that might explain the findings.

This week’s challenge: can you think of a reasonable explanation for finding 30 statements like this as recent arrivals in the library cache ?

Update – for clarification:

While looking at an OLTP system you find 30 statements like the above (yes, absolutely that simple) in v$sql, and say to the client: “This is a little unusual, why are you doing it?” The client supplies an explanation.

Although you were expecting to respond to any explanation with a comment like “You shouldn’t do it like that” (or possibly “We’ll have to find out why that’s happening and stop it” ) you feel the urge to say “That was a good idea”.

So can you think why something that initially looks like an odd design flaw could actually be a clever idea.

August 27, 2009

Philosophy – 4

Filed under: Philosophy — Jonathan Lewis @ 7:38 pm UTC Aug 27,2009

There are two critical aspects to scalability:

  • In single user-mode: will the response time next year be the same as it is this year (see Philosophy – 3)
  • In multi-user mode: will the response time be the same when the number of users doubles, trebles, quadruples …

If you want that as a snappy catch-phrase Cary Millsap produced a good one at Collaborate 2009: “Fast Now, Fast Later”.

[The Philosophy Series]

August 26, 2009

Index Explosion 3

Filed under: Index Explosion,Indexing,Infrastructure,Troubleshooting — Jonathan Lewis @ 6:53 pm UTC Aug 26,2009

At the end of part 2 of Index Explosion I left you with three questions: 

  • how can you set maxtrans on an index in 10g (and above)
  • what strategies exist for minimising the potential for damage if you actually have to face this problem
  • why haven’t I noticed the space-wasting phenomenon more often despite seeing indexes where it could have been happening

In this post I’ll address the maxtrans issue. If you try to set maxtrans on an index in 10g it simply doesn’t work, and here’s a quick cut-n-paste from SQL*Plus running 10.2.0.3 to demonstrate the point:

(more…)

August 18, 2009

Why test ?

Filed under: Troubleshooting — Jonathan Lewis @ 6:28 pm UTC Aug 18,2009

Here’s a simple problem that came up on the Oracle newsgroup a little while ago: how do you get the date for the last day of the previous month?

(more…)

August 17, 2009

treedump

Filed under: Indexing,Infrastructure,trace files,Troubleshooting — Jonathan Lewis @ 5:31 pm UTC Aug 17,2009

Here’s a mechanism for examining indexes in some detail if you think that something odd may be going on inside them. It’s a feature that I first decribed in Practical Oracle 8i, although the book doesn’t mention a problem with it that I subsequently discovered that means I always test it carefully on a small index before I use it on a large one.  Here’s a demonstration – cut from an SQL*Plus session on 10.2.0.3:

(more…)

August 14, 2009

Tera-bug

Filed under: Infrastructure,Troubleshooting — Jonathan Lewis @ 12:26 pm UTC Aug 14,2009

I came across an interesting Oracle error recently: “ORA-15099: disk {name} is larger than maximum size of 2097152 MBs”, which you can find on Metalink under bug 7243305.

The status of this bug is: “Closed, Not a Bug” – but the description points you to bug 6453944 (present in 10.2.0.3, fixed in 11.2) for which the only visible text is:

RELEASE NOTES: ORA-15196(ASM block corruption) occured, if larger than 2TB disk was part of a diskgroup
REDISCOVERY INFORMATION: If you added larger than 2TB size disk to a diskgroup and saw ORA-15196, then you hit this issue.
WORKAROUND: Not to add larger than 2 TB size disk to a diskgroup

The text for bug note 6453944.8 tells you that the patch (to stop you creating diskgroups with oversize LUNs) is in the 10.2.0.4 and 11.1.0.7 patch sets – but the patch only stops you adding new oversize LUNs, it doesn’t help if you’re already using them. So if you’re running a very large system on ASM, you might want to check the sizes of your ASM volumes and take some remedial action if you’ve already got LUNs larger than 2TB.

There are no clear indications of what can go wrong with ASM LUNs larger than 2TB – but one example is wrapping: when Oracle gets to the end of 2TB, it may wrap back to the start of the LUN and overwrite the ASM metadata. When you’re running that big a system and need to do a full ASM disk group restore that’s a serious problem.

 

Useful related notes:

Metalink Doc ID: 370921.1: ASM – Scalability and Limits
Metalink Doc ID: 736891.1: ORA-15196 WITH ASM DISKS LARGER THAN 2TB

August 11, 2009

Index Explosion 2

Filed under: Index Explosion,Indexing,Infrastructure,Performance,Troubleshooting — Jonathan Lewis @ 7:27 pm UTC Aug 11,2009

As we saw in part 1 of Index Explosion, we can lose a lot of space in index leaf blocks because

  1. at even fairly low levels of concurrency Oracle can manage to introduce a large number of (redundant ?) ITL entries into a leaf block and …
  2. once a single leaf block has a large number of ITL entries the entire ITL is copied into both target blocks every time the leaf block splits – so one brief accident can have a significant long term effect.

But what’s happening, and what should we do about it ?

(more…)

August 10, 2009

Hanganalyze

Filed under: Troubleshooting — Jonathan Lewis @ 10:37 pm UTC Aug 10,2009

Here’s an interesting tale from Arup Nanda (of Oracle Magazine fame) of how to examine the hanganalyze report, including a note telling you about the undocumented: “sqlplus -prelim /nolog”  for those times when you can’t even connect to the instance to run the hanganalyze command.

August 7, 2009

Rownum effects

Filed under: CBO,Execution plans,Hints — Jonathan Lewis @ 7:21 pm UTC Aug 7,2009

A few months ago, I wrote a note about setting the optimizer_mode to one of the first_rows_N values (first_rows_1, first_rows_10, first_rows_100, or first_rows_1000).

One of the effects associated with this parameter is that the first_rows(N) hint and the predicate “rownum <= N” use the same first_rows_N arithmetic (although N can take any value for the rownum or hint).

In a recent follow-up, Timur Akhmadeev supplied a link to a discussion on the Oracle Forum about this topic, starting with a problem that a rownum predicate was causing and ending with a resolution through the row_number() analytic function.

I thought it would be worth making it easier for future researches to find the discussion by creating a specific blog item to point to it.

Index Fragmentation

Filed under: fragmentation,Indexing,Infrastructure,Oracle — Jonathan Lewis @ 6:07 pm UTC Aug 7,2009

Here’s a thought for the weekend:

When people talk about “index fragmentation”, what do they mean, and why do they care ?

I often see email or forum posts from people claiming that their indexes are fragmented and need to be rebuilt – but they rarely explain (even when asked) what they mean by “fragmented”, and how they have measured the “fragmentation”, and why they think they have evidence that the index needs to be rebuilt.

So if you are accustomed to talking about indexes being “fragmented”, would you let me know what you mean, and how you measure “fragmentation”. (I can think of three or four interpretations for the term – but I’m interested to hear from people who actually use it.)

[Further reading on Fragmentation]

August 6, 2009

Travelogue 2

Filed under: Uncategorized — Jonathan Lewis @ 2:37 pm UTC Aug 6,2009

I rarely make a fuss about the places I go and the things I do, but I had another one of those moments last week when I felt the weight of history.

I was in Capetown, South Africa, on a glorious winter week-end, and I had strolled out to the Waterfront. Walking back to the city at sunset, I was suddenly hit by a feeling of the immense age of the mountains compared to the (relatively) new city nestling in the hollow at their base.

Naturally I’d forgotten to take my camera with me on my walk, and my mobile phone couldn’t cope with the low light – but here’s a picture I’d taken (on my phone) on the way out to the Waterfront a couple of hours earlier. If you imagine the perspective from a mile further away, with the city looking about one third of the size and the mountains unchanged, you may get an idea of the image that made me stand and stare.

capetown_02a

Now that I’m back home I’ve got a load of comments that need answers – so you can expect to see my name as the author on just about every comment on the comment list for the next two days.

August 3, 2009

Testimonial

Filed under: Uncategorized — Jonathan Lewis @ 8:08 pm UTC Aug 3,2009

I’ve been too busy to respond to comments on the blog for the last few days – apologies to all who have contributed, I might had some time to catch up on Thursday when I get home – but it’s hard to pass up the opportunity to point people in the direction of a little article that gave me a warm feeling of a job well done.

Warning – if you don’t want to read a description of how truly amazing I am, don’t follow this link.

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 819 other followers