Here’s a summary of a question that appeared on the Oracle Forum some time ago:
I had been seeing frequent log file switching (resulting in “checkpoint not complete” reports) at night when some export dumps have to occur simultaneously, so I increased my redo log file sizes from 5MB to 10MB.
I now have a user who complains that the system is slow, and I see that the buffer cache hit ratio (BCHR) has dropped to about 90% from what was usually 95% or higher.
Can anyone tell me whether increasing the log file size could cause a performance decrease (and thus buffer cache hit ratio decrease)?
Now the intuitive response to this question is “surely not”. And, of course, the immediate association between poor performance and a lower “buffer cache hit ratio” (BCHR) is inviting a lecture on the general irrelevance of hit ratios.
BUT – there are two important points to consider in this case: (i) a user has reported a performance problem after the change in the log file size and (ii) the hit ratio did drop after the change in log file size. So the question, and the association, should not be dismissed out of hand.
First, of course, we have to recite the dictum: “correlation is not causation”. In other words when two events occur together it isn’t necessarily the case that one caused the other – and when you do start to think about cause and effect, don’t jump to any conclusions about which is cause and which the effect.
Secondly we have to remember the mantra of Greg House M.D.: “Everybody lies”. In its friendlier form we might word this as “there are likely to be important details that haven’t been mentioned”. Most significantly, do we believe that the user’s process started running more slowly the moment the redo log file size was changed; but also: is it just one task that goes more slowly – is it always slower, or just slower sometimes – is it a read-intensive process or a write-intensive process – and do we believe that the user’s process has been examined to see if there is a more obvious reason for why it is running more slowly.
Finally, since we aren’t on the spot and able to apply a proper inquisition, let’s just assume that there really is a link between the resizing operation and the slow-down of the user process and try to work out how that could happen.
This is a situation I find myself in a little too often – I have to diagnose a problem hands-off and blind-folded while someone else tells me what’s going on, so my only option is to trust what I’m hearing and create a reasonable explanation for the given symptoms. It’s slightly more difficult in this case, because I can’t even ask any questions.
So we’re going to play: “Let’s pretend”. What could possibly be going on that could make a process slow down because the redo log file size has been increased and, incidentally, make the BCHR drop at the same time.
One obvious thought, of course, is that you can’t resize log files – you create new ones and drop the old ones. So the new log files might be on a slower disc or on a hot bit of the SAN, and if the log file writes are slower then a job that does lots of commits might run noticeable slower. (Bong 0/10 – because that wouldn’t, at first sight, cause the BCHR to drop; moreover, if this were the case, wouldn’t the process have been blocked by the ‘checkpoint not complete’ anyway).
Second thoughts, then. The log files were made bigger to avoid ‘checkpoint not complete’ problems. This suggests that the other user’s process was a read-intensive one rather than a write-intensive one otherwise it, too, would have been waiting on ‘checkpoint not complete’ and should have been able to work faster when the log file sizes were increased. But that means something is going faster because of the change in log file size, but it’s not this other user.
Take a side step for a moment – what makes the BCHR down ? If you follow the typical formula it’s either a drop in the rate of buffer gets or an increase in the rate of disc reads. So why should the BCHR go down when some jobs can go faster ? Here’s one easy answer:
I have a batch update job that needs to do a lot of disc I/O; but it keeps stopping because of the checkpoints. You have a big report that gets through a lot of buffer visits, and keeps running even when the checkpoints are stopping my batch. Because your job is running, you can keep revisiting buffers, promoting them in memory and pushing the BCHR up.
As soon as I am allowed to work for longer periods, I can get through more disc I/O in a given interval and revisit the blocks I am interested in at a higher rate. So I push the BCHR down because of the extra reads, I knock your blocks out of the buffer because of my increased read rate, and I protect my blocks better because I can revisit them more often.
At the same time, you have less success in re-visiting buffered blocks because I have a better chance of kicking them out before they are promoted, and you end up doing more physical reads – pushing the BCHR down even further.
So, a fix that allows me to work harder (visiting the disc more, and disrupting the cache more) slows you down and increases the BCHR. It’s just the old problem of local vs. global optimisation. If I can work harder I may cause you more pain – that’s the way it is in a multi-user system.
It took me some time to write all this down – but it took just a couple of minutes to sit back and ask myself if there was a scenario that could reasonably fit the facts supplied. It’s an approach I often take:
- What are the known facts ?
- What reasonable hypothesis will explain the known facts ?
- What further facts should be present if the hypothesis is correct ?
It’s called the scientific method. It’s a good methodology to follow. Work at it and you’ll end up wasting less time chasing round in circles; you get to the right answer more often, more rapidly.
(Readers are invited to join in the game – can you suggest a possible cause, and then say what other indications you would expect to see, and where you’d see them, if your suggestion is correct.)
Similar to the “I switched to faster CPUs ; Why is my performance Poorer” ? issue.
Another track to take is that the “user reporting that the system is slow” is NOT correlated to the “BCHR is lower” ? Maybe the two are caused by independent events which coincidentally happened at the same time (one of the two events could be the “resizing” of the redo log files) ? We don’t have enough possibe causes for both reports.
OR : the DBA resized the redo logs by recreating them on disks which were the “query” disks for the user. Now, the user’s query keeps suffering IO waits on his disks because LGWR is constantly repositioning the heads back to the redo log file sectors — and this scenario could still be consistent with your description of faster transaction performance impacting buffer access.
Comment by Hemant K Chitale — October 6, 2008 @ 3:47 am UTC Oct 6,2008 |
>(Readers are invited to join in the game – can you suggest a possible cause, and then say what other indications you would expect to see, and where you’d see them, if your suggestion is correct.)
Will I get a winner T-Shirt from you Jonathan for a correct answer?
Regards,
Jaffar
Comment by Syed Jaffar Hussain — October 6, 2008 @ 6:48 am UTC Oct 6,2008 |
I’m curious…
I don’t think many of us will try to “compete” with you.
I just have one guess (but I don’t like it very much):
The larger size of the redo log, can introduce more wait time if the log writer is not very fast. In this case I must also found some latch contention, perhaps bad statistics. If the log writer wake ups at some intervals, even the normal activity can suffer.
Comment by lascoltodelvenerdi — October 6, 2008 @ 12:58 pm UTC Oct 6,2008 |
So I will try.
What are the facts? As a dump does not leed to massive redo generation as far as I know, there must be another source for that. As the dumps are running at night, I think we are talking about a 24/7 system.
Then the redo log size. Someone changed it from the standard 50MB dbca would take to only 5. Why? Perhaps to save some disk storage? If this was the reason (and this is already my first hypothesis) we are not talking about a big database with hundreds of GB or even TBs with 4, 8 or more CPUs. Following this assumption I would say that we are talking about a small instance with let’s say from 1 to 10GB or so on a small 1 or 2 CPU system.
Also the hardware is on its limit when a dump job is hitting the system. This might be from (too) slow disks or CPU or both I don’t know.
Now when one enlarges the redologs, there can be more dirty block in the block buffer before DBW has to write them to disk because of a logfile switch. So when we changed the redo log size, we achieved, that DBW has to write, lets say, twice the data to disk but less frequent.
The conclusion is, that we might have reduced the count of the wait states but each wait state takes about double the time it took before. And this might be the cause why a user suddently realised these waits now.
Regards
Wolfgang
Comment by Wolfgang — October 6, 2008 @ 6:46 pm UTC Oct 6,2008 |
Wolfgang,
Here’s another hypothesis, prompted by your comment that “a dump does not lead to massive redo generation”.
In fact if the “dump” is an export it is little more than a set of tablescans, and it could lead to massive redo generation if those tablescans caused a lot of delayed block cleanouts.
If the user who is complaining about performance is complaining about some reports that run at the same time as the dump, we’ve just let the export run faster – because it doesn’t have to pause for log file switches and checkpoints so often – and it gets to do more physical reads faster. So the BCHR in the interval goes down (as the read rate goes up) and everything else runs more slowly because of the increased interference.
Comment by Jonathan Lewis — October 8, 2008 @ 9:10 pm UTC Oct 8,2008 |
Jonathan,
yes delayed block cleanouts might be a reason (especially because DBW has to write these blocks down again).
Depends on how large the block buffer is (if the changed rows fits into 10% of the blockbuffer they will be cleanout immediately after commit) and how many blocks are changed in a typical transaction, how much transactions are running on a normal day etc etc.
Comment by Wolfgang — October 9, 2008 @ 5:07 pm UTC Oct 9,2008 |
Sorry I don’t get the point.
Well, I understand the problem of block clean outs but I can not get the correlation between redo log and DBW in this scenario.
Does a DB dump (i.e. export) generate redo logs?
Or perhaps I’m misunderstanding something…
Comment by lascoltodelvenerdi — October 9, 2008 @ 8:25 pm UTC Oct 9,2008 |
Hi,
when you clean out ones block’s old transaction table entries these are changes on the block. And these block changes are protected by redo.
But as you have changed the block, it is dirty again and has to be written to disk by DBW.
A dump might generate redo logs. Also a dbms_stats job might generate redo logs because it full scans the table and might clean out some outdated transaction data.
Comment by Wolfgang — October 9, 2008 @ 8:50 pm UTC Oct 9,2008 |
“Let’s Pretend”
Yet another case:
In this case we’ll assume that the following details are not specified by the questioner:
- it’s a Data Guard configuration with two physical standby databases running in MAXAVAILABILITY mode
- primary database has default value for LOG_ARCHIVE_MAX_PROCESSES(on 10g it’s 2)
MAXAVAILABILITY – LGWR SYNC used. Standby redo logs used(mandatory in this case).
After primary db redo log size change takes effect, the database goes to MAXPERFORMANCE mode(it’s my assumption(not yet tested, please correct if I’m wrong) since it will not be able to find standby redo logs on physical standby databases with appropriate sizes). In MAXPERFORMANCE primary db will start to use ARCH processes to send redo data to standby databases. Since we have at least one local and two remote destinations and only two archiver processes there will be new waits introduced on the primary database(due to not enough ARC processes). This leads to LGWR waits and so on. The whole database becomes slower and as a result regular “big writers” jobs start to span over daily hours when users run their reports. Let’s say that the jobs are some accounting data and users run queries on some other sort of data. All accounting data will flush user’s needed data and here is the buffer cache hit ration decrease.
Please, pretend further
Comment by Adrian Angelov — October 9, 2008 @ 11:25 pm UTC Oct 9,2008 |
@Wolfgang
Yep, you’re right.
I was thinking of something like: all written to disk, let’s do the export!
In such a scenario, I think, no redo logs from export.
A question, as you can turn on the “auto analyze” (i.e. sampling) feature on a table, can this generate more redo logs?
Comment by lascoltodelvenerdi — October 10, 2008 @ 6:46 am UTC Oct 10,2008 |
lascoltodelvenerdi,
if a process reads a block, he checks its transaction table. If there is an entry he checks if the transaction is committed or if he has to go to the undo and gets its data from there.
If the process asserts that the transaction is already committed, he will clean out the old transaction entry so that the next process who reads this block will not have to check the same thing again.
This has nothing to do if the block was already written to disk or not.
Comment by Wolfgang — October 11, 2008 @ 1:51 pm UTC Oct 11,2008 |
@Wolfgang,
I was not very clear.
I was thinking about this scenario: some transactions work on a table, that table has sampling on. At a point in time, Oracle “auto analyze” the table.
We have no idea what blocks Oracle will check. Probably if they are dirty they will be written.
Am I wrong?
If I’m right than there will be redo, probably a bit more than what we expect?
Comment by lascoltodelvenerdi — October 13, 2008 @ 6:11 am UTC Oct 13,2008 |
Adrian,
I like it.
I don’t know if your assumption about the switch to maximum performance mode is correct. But it provides a possible cause with a list of symptoms which can be checked very easily (especially the existence of the standby databases).
A particularly interesting feature of your suggestion is that it gives an example of the type of question that should have been asked BEFORE a feature was implemented. By which I mean there should have been a brain-storming session where someone said:
and we hope someone would have made some comments about:
Comment by Jonathan Lewis — October 18, 2008 @ 9:51 am UTC Oct 18,2008 |