Wednesday 11 July 2012

log file switch (private strand flush incomplete)/Private Redo Strands( Private Redo )


Earlier there was a single redo allocation latch available for the entire log buffer. This was a major contention point as till the time one won’t be able to pin the latch, he wont be able to write his changed redo vectors in the log buffer. From 10.1 onwards, the log buffer is broken in to smaller sub-buffers called Private Redo Strands(shown in the x$kcrfstrand). These are also allocated in the shared pool. These all are written by redo allocation latches. There are allocation latches now for each private strand. The data when changed now, doesn’t contend to go into the log buffer as like before but goes into the private redo strands and from there, it goes into the log buffer when the buffer pools become full or when the transaction is committed. We can see the private strands shown in the shared pool from the V$sgastat

SQL> select name,pool from V$sgastat
2 where name like ‘%private%’;

NAME POOL
————————– ————
private strands shared pool
KCB private handles shared pool
At log file switch , when the data is still is in the Private redo strands, lgwr may wait to get the flush done by DBWR. Hence the event, log file switch (private strand flush incomplete) may occur

log file switch (private strand flush incomplete)
New wait 10g
Like a “log file switch Completion”

Wait for lgwr to switch log files when generating redo
Solution:
Increase redo log file size
Reduces frequency of switches


What happens when a log file switch occurs:
Get next log file from control file
Get Redo Copy and Redo Allocation latch
Flush redo
Close File
Update Controlfile
Set new file to Current
Set old file to Active
If in Archivelog mode add file to archive list
Open all members of new logfile group
Write the SCN to the headers
Enable redo log generation
DBWR makes a list of blocks that need to be written out in order to over write the Redo log file a list of blocks that need to be written out in order to over write the Redo log file

Tuesday 10 July 2012

Oracle Error :: SP2-1503 Unable to initialize Oracle call interface SP2-0152: ORACLE may not be functioning properly

Oracle Error :: SP2-1503 Unable to initialize Oracle call interface
Cause

Indicates a library used by SQL*Plus to communicate with the database failed to initialize correctly.
Action

1)  Check that the Oracle environment variable are set properly .
2) If using the SQL*Plus Instant Client make sure the SQL*Plus and Oracle libraries are from the same release
3) Make sure you have read access to the libraries.

In my case there are both 10g and 11g are installed on same server . and 11g is default home .now i want to connect with oracle 10g home on the server

I have export the  ORACLE_BASE, ORACLE_HOME, ORACLE_SID

$export ORACLE_BASE=/home/oracle/apps
$ export ORACLE_HOME=$ORACLE_BASE/product/db_1/10.2.0
$ export ORACLE_SID=DB01

and run sqlplus and got below error

$ sqlplus / as sysdba
SP2-1503: Unable to initialize Oracle call interface
SP2-0152: ORACLE may not be functioning properly


Then i have export the path  with above environment variables which i set earlier

$ export PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin
$ PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:/bin:/usr/lib64/:$ORACLE_HOME/OPatch

and it sucessfully connected


$ sqlplus / as sysdba
Connected to:
Oracle Database 10g Release 10.2.0.4.0 - 64bit Production







Materialized View: ORA-22818 subquery expressions not allowed here


CREATE MATERIALIZED VIEW mv1 AS
(SELECT s.id AS sport_no
, c.rollno id
, (SELECT NAME FROM class c WHERE id = sport_no ) AS stu_name
from sport s);

Error: ORA-22818 subquery expressions not allowed here

This is a documented restriction of Materialized view.
Solution: rewrite the query replacing scalar subquery with outer join



create meterialized view mv1 as
select s.id AS sport_no
, c.rollno id
from sport s , class c
where s.id = c.rollno(+);

A simpler solution: creating MV on top of the view

CREATE or REPLACE VIEW view_sport_stu_name AS
(SELECT s.id AS sport_no
, c.rollno id
, (SELECT NAME FROM class c WHERE id = sport_no ) AS stu_name
from sport s);

create MATERIALIZED VIEW mview_sport_stu_name AS
select * from view_sport_stu_name;