Monday, April 4, 2011

Getting log switching info

The amount of log switches that does an Oracle database is an indicator about the amount of data modified in the database; as long as select operations does not generate redo, log switching is closely related to data manipulation. Therefore, you can get the number of log switches and the size of each log file and have a rough idea about how much data is being modified in your database in a period of time:

SQL> select MAX(i.INSTANCE_NAME) as INSTANCE, MIN(h.FIRST_TIME) as FIRST_TIME,
SQL> MIN(h.SEQUENCE#) as MIN_SEQUENCE#, MAX(h.SEQUENCE#) as MAX_SEQUENCE#,
SQL> MAX(l.BYTES)/1048576 as LOG_SIZE_MB,
SQL> MAX(h.SEQUENCE#)-MIN(h.SEQUENCE#)+1)*MAX(l.BYTES)/1073741824 as DATA_GB
SQL> from V$LOG_HISTORY h, V$LOG l, V$INSTANCE i where h.FIRST_TIME > SYSDATE-7;

INSTANCE FIRST_TIME MIN_SEQUENCE# MAX_SEQUENCE# LOG_SIZE_MB DATA_GB
---------------- ----------- ------------- ------------- ----------- ----------
mydb 12-jun-2010 178 182 256 1.25

No comments:

Post a Comment