Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

log file sync wait event in 11gr1

user530956Oct 30 2011 — edited Nov 10 2011
In 11gr1 we are seeing the logfile sync wait event in top event of awr report. We have optimized the storage still we are finding the same. Nature of Application as every commit after one transaction complete. Also they doing the rollback's at the same time with ratio of 2:1 i.e in awr report we have seen, if we there is 1000 commit, its also have 500 rollbacks.


To reduce the log file sync wait event, One of consultant as advised us to reduce the log_buffer init parameter to 1mb from default i.e 25mb

From google i find that log_buffer used in older version of oracle to reduce the logsync wait event. My understand in 11g this parameter is auto takencare by oracle. By changing of parameter any useful or anyother way to optimize this wait event?

Appreciate your reply.

Comments

mathguy

What happened when you tried? It's pretty easy to write a very small test case, which will tell you if they are compatible or not.

BEDE

Test and see.

For instance:

create table zz as

select to_char(sysdate,'mmss')+level n1, ora_hash( to_char(sysdate,'mmss')+level) c1

from dual

connect by level<1000

;

select *

from zz

order by n1

fetch first 10 rows only

for update

;

ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.

This I have tested in Live SQL.

So, you may well fetch the rowid and lock the rows as fetched.

I think of something like:

declare

   type tab_rid is table of varchar2(100);

   tb_rid tab_rid;

   v_rid varchar2(100);

begin

tb_rid:=tab_rid();

for r in (

select t.rowid rid, t.*

from zz t

order by n1

fetch first 10 rows only

)

loop

   begin

      select rowidtochar(t.rowid) into v_rid

      from zz t

      where t.rowid=r.rid

      for update nowait;

      tb_rid.extend;

      tb_rid(tb_rid.count):=v_rid;

   exception

      when others then null; --- what to do if one row can't be locked? suppose leave it for some other time...

   end;

end loop;

--- do whatever with the locked rows

---

commit;

end;

Jonathan Lewis

As Bede points out - Oracle does not allow "for update" with this basic query as "fetch first" is implemented through a view over an analytic function.

However the following is an approach that will work in pure SQL - fetch the rowids of the rows you want in an inline non-mergeable view - and, if necessary, force a nested loop joinback by rowid:

select

        *

from

        t1

where

        t1.rowid in (

                select

                        /*+ no_merge */

                        t1a.rowid

                from

                        t1 t1a

                order by

                        t1a.n1

                fetch

                        first 10 rows only

        )

;

Regards

Jonathan Lewis

Sanjib Saha

Thanks Jonathan, but this will not lock the desire row / rows.

Paulzip

Sanjib Saha wrote:

Thanks Jonathan, but this will not lock the desire row / rows.

?

cursor curSomething is

select

        *

from

        t1

where

        t1.rowid in (

                select

                        /*+ no_merge */

                        t1a.rowid

                from

                        t1 t1a

                order by

                        t1a.n1

                fetch

                        first 10 rows only

        )

for update;

-- Do stuff with cursor.

Jonathan Lewis

Sanjib Saha wrote:

Thanks Jonathan, but this will not lock the desire row / rows.

As PaulZip points out, my example does need the FOR UPDATE clause if you want to lock the rows.

Regards

Jonathan Lewis

1 - 6
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 8 2011
Added on Oct 30 2011
7 comments
2,517 views