eygle.com   eygle.com
eygle.com  
 

« December 26, 2005 | Blog首页 | December 28, 2005 »



December 27, 2005

My answer for-9个动态性能视图

作者:eygle

出处:http://blog.eygle.com

之前写过一个命题:列举你认为最重要的9个动态性能视图,在Itpub上有朋友忽然这个问题答案.原来是在面试中被问及了这个问题.

实际上我提出的只是一个命题,答案肯定因人而异,而且这个问题的答案也无所谓对错.
但是通过答案我们的确可以看出一个人对数据库的认识和理解,看出他的侧重点,看出他的知识面.
进而,面试者可以通过你的回答进行更为深入的提问,从而来考察你的真实水平.在完善的面试下,真实的技术水平肯定是无法隐瞒的.

在命这个题的时候,我也没有想过自己的答案.

所以说9,是因为考虑到,数以1始,以9终,是以为极.
故有9之说

如果真要我想,大约列了9个,真还不好取舍:

v$session + v$session_wait (在10g里功能被整合,凑合算1个吧.)
v$process
v$sql
v$sqltext
v$bh (更宁愿是x$bh)
v$lock
v$latch_children
v$sysstat
v$system_event

这是我的答案,这里有小惠惠的答案,大家都来列一下,我们取下交集或许可以给彼此一个参考:)

看到别人的答案我们应该思考:给我这些视图,我能获得哪些信息?我能解决哪些问题?

然后,如果有机会和答题者讨论沟通,必然有不错的提高,三人行必有我师,学习也正是一个不断借鉴交流提升的过程.

谢谢大家!

Posted by eygle at 10:23 PM | Comments (7)


what is SMON_SCN_TIME ?

作者:eygle

出处:http://blog.eygle.com

SMON_SCN_TIME是Oracle数据库的系统表,用以进行辅助恢复等功能。
在Oracle9iR2中,SMON_SCN_TIME每5分钟被更新一次。

[oracle@jumper oracle]$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Mon Dec 19 18:19:27 2005
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
Session altered.
SQL> select * from smon_scn_time where rownum <10;
    THREAD    TIME_MP TIME_DP                SCN_WRP    SCN_BAS
---------- ---------- ------------------- ---------- ----------
         1 1134916635 2005-12-18 22:37:15         25      65931
         1 1134916648 2005-12-18 22:37:28         25      65979
         1 1134917029 2005-12-18 22:43:49         25      66224
         1 1134917336 2005-12-18 22:48:57         25      66325
         1 1134917643 2005-12-18 22:54:04         25      66426
         1 1134917950 2005-12-18 22:59:11         25      66527
         1 1134918257 2005-12-18 23:04:18         25      66628
         1 1134918564 2005-12-18 23:09:25         25      66733
         1 1134918871 2005-12-18 23:14:33         25      66836
9 rows selected.

SMON_SCN_TIME记录5天的数据,也就是1440 ((5d x 24h x 12m = 1440) 条记录。
所以在Oracle9iR2中,表属性修改时间和flashback时间差至少应为5分钟。否则就会出现ORA-01466错误。

[oracle@jumper oracle]$ sqlplus eygle/eygle
SQL*Plus: Release 9.2.0.4.0 - Production on Mon Dec 19 19:34:53 2005
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
19:34:58 SQL> col myscn for 9999999999999999
19:34:58 SQL> variable myscn number;
19:34:58 SQL> create table eygle (c1 number);
Table created.
19:35:00 SQL> exec :myscn := dbms_flashback.get_system_change_number();
PL/SQL procedure successfully completed.
19:35:00 SQL> print myscn;
            MYSCN
-----------------
     107374274756
19:35:00 SQL> insert into eygle values(1);
1 row created.
19:35:00 SQL> commit;
Commit complete.
19:35:00 SQL> exec :myscn := dbms_flashback.get_system_change_number();
PL/SQL procedure successfully completed.
19:35:00 SQL> print myscn;
            MYSCN
-----------------
     107374274777
19:35:00 SQL> select * from eygle as of scn(:myscn);
select * from eygle as of scn(:myscn)
              *
ERROR at line 1:
ORA-01466: unable to read data - table definition has changed
19:41:10 SQL> select * from eygle as of scn(:myscn);
select * from eygle as of scn(:myscn)
              *
ERROR at line 1:
ORA-01466: unable to read data - table definition has changed
19:43:03 SQL> select dbms_flashback.get_system_change_number myscn from dual;
            MYSCN
-----------------
     107374274944
19:43:15 SQL> select * from eygle as of scn 107374274944;
        C1
----------
         1

此时SMON_SCN_TIME中的信息如下: 

19:45:11 SQL> select * from (select * from smon_scn_time order by time_dp desc) where rownum <5;
    THREAD    TIME_MP TIME_DP                SCN_WRP    SCN_BAS
---------- ---------- ------------------- ---------- ----------
         1 1134992658 2005-12-19 19:44:18         25      92565
         1 1134992351 2005-12-19 19:39:11         25      92463
         1 1134992042 2005-12-19 19:34:04         25      92256
         1 1134991731 2005-12-19 19:28:53         25      92149

在Oracle10g中,SMON_SCN_TIME表每6秒被更新一次。所以这个Flashback时间被缩小为6秒。

[oracle@danaly ~]$ sqlplus eygle/eygle
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 19 19:37:19 2005
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
19:37:22 SQL> col myscn for 9999999999999999
19:37:22 SQL> variable myscn number;
19:37:22 SQL> create table eygle (c1 number);
Table created.
19:37:22 SQL> exec :myscn := dbms_flashback.get_system_change_number();
PL/SQL procedure successfully completed.
19:37:22 SQL> print myscn;
            MYSCN
-----------------
      16011230122
19:37:22 SQL> insert into eygle values(1);
1 row created.
19:37:22 SQL> commit;
Commit complete.
19:37:22 SQL> exec :myscn := dbms_flashback.get_system_change_number();
PL/SQL procedure successfully completed.
19:37:22 SQL> print myscn;
            MYSCN
-----------------
      16011230124
19:37:22 SQL> select * from eygle as of scn(:myscn);
select * from eygle as of scn(:myscn)
              *
ERROR at line 1:
ORA-01466: unable to read data - table definition has changed

19:37:22 SQL> select scn_to_timestamp(16011230124) from dual;
SCN_TO_TIMESTAMP(16011230124)
---------------------------------------------------------------------------
19-DEC-05 07.37.21.000000000 PM
 
19:38:50 SQL> select timestamp_to_scn('19-DEC-05 07.37.27.000000000 PM') MYSCN from dual;
            MYSCN
-----------------
      16011230125
19:39:02 SQL> select * from eygle as of scn 16011230125;
        C1
----------
         1

Posted by eygle at 8:19 PM | Comments (3)



CopyRight © 2004-2008 eygle.com, All rights reserved.