列出旧对象

发布于 2024-11-30 13:10:43 字数 149 浏览 0 评论 0原文

只是想知道是否有一种方法可以列出数据库中尚未查询的所有对象。 我知道你可以通过sys.dba_Objects看到last_ddl_time和Created Time。但我对对象上的 Total_reads 更感兴趣,特别是索引和表。以及谁使用过它。(不是所有者)

谢谢

just wondering is there a way to List all objects in database which have not been Queried.
i know you can see the last_ddl_time and Created Time through sys.dba_Objects. But i am More interested in Total_reads on Objects specially Indexes and tables.And Who has Used it.(Not the Owner)

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怎言笑 2024-12-07 13:10:43

您可以使用 V$SEGMENT_STATISTICS 视图来获取您想要的信息。例如,如果您想查看自上次数据库重新启动以来 SCOTT 模式中的每个段已完成多少逻辑读取

SQL> select owner, object_name, value
  2    from v$segment_statistics
  3   where statistic_name = 'logical reads'
  4     and owner = 'SCOTT';

OWNER                          OBJECT_NAME                         VALUE
------------------------------ ------------------------------ ----------
SCOTT                          STATS_TEST                            448
SCOTT                          BIN$bQrMO1+dTOOh9S8K9O+z+Q==$0          0
SCOTT                          COUNTER_TEST                         1760
SCOTT                          BIN$763dsleISbi+AfEp20EN7A==$0         80
SCOTT                          TEST_TABLE                           5424
SCOTT                          BIN$5QAh3TmjRWqeMKof7tY93g==$0        144
SCOTT                          BIN$1i4uV7CbQL2Pl0tANHsJQw==$0         80
SCOTT                          BIN$8ydZ/jHySAeudojTmTtByQ==$0         48
SCOTT                          FOO_TEMP                              112
SCOTT                          ERR$_FOO                               64
SCOTT                          EVENT                                  32
SCOTT                          FOO                                    32
SCOTT                          T1                                    176
SCOTT                          T2                                     80
SCOTT                          EMP                                    32
SCOTT                          GRAD_STUDENT_TB                       240
SCOTT                          SYS_C0024557                           64
SCOTT                          PK_EMP                                  0

18 rows selected.

如果您获得使用 AWR 的许可并且您的 AWR 保留时间足够长并且如果您可以使用较少的可用统计信息,并且您只对最常用的段感兴趣,那么您也可以使用DBA_HIST_SEG_STAT 表。

SQL> ed
Wrote file afiedt.buf

  1  select snap.begin_interval_time,
  2         stat.logical_reads_delta,
  3         obj.object_name
  4    from dba_hist_seg_stat stat
  5         join dba_hist_snapshot snap using (snap_id)
  6         join dba_objects obj on (obj.object_id = stat.obj#)
  7*  where obj.owner = 'SCOTT'
SQL> /

BEGIN_INTERVAL_TIME            LOGICAL_READS_DELTA OBJECT_NAME
------------------------------ ------------------- --------------------
16-AUG-11 04.00.11.428 PM                      160 T1
18-AUG-11 12.00.13.856 PM                      144 GRAD_STUDENT_TB
18-AUG-11 12.00.13.856 PM                       48 SYS_C0024557
20-AUG-11 03.00.59.376 PM                      144 LOAN_TXN

然而,如果您试图查明某个特定对象是否被轻度使用,AWR 可能不是正确的解决方案,因为尽管偶尔使用,它可能不会显示为任何快照窗口中的顶部片段之一。

或者,您可以编写自己的流程来定期从 V$SEGMENT_STATISTICS 捕获数据,并通过减去不同快照的统计值来计算增量。

You can probably use the V$SEGMENT_STATISTICS view to get the information you're after. For example, if you wanted to see how many logical reads had been done on each segment in the SCOTT schema since the last database restart

SQL> select owner, object_name, value
  2    from v$segment_statistics
  3   where statistic_name = 'logical reads'
  4     and owner = 'SCOTT';

OWNER                          OBJECT_NAME                         VALUE
------------------------------ ------------------------------ ----------
SCOTT                          STATS_TEST                            448
SCOTT                          BIN$bQrMO1+dTOOh9S8K9O+z+Q==$0          0
SCOTT                          COUNTER_TEST                         1760
SCOTT                          BIN$763dsleISbi+AfEp20EN7A==$0         80
SCOTT                          TEST_TABLE                           5424
SCOTT                          BIN$5QAh3TmjRWqeMKof7tY93g==$0        144
SCOTT                          BIN$1i4uV7CbQL2Pl0tANHsJQw==$0         80
SCOTT                          BIN$8ydZ/jHySAeudojTmTtByQ==$0         48
SCOTT                          FOO_TEMP                              112
SCOTT                          ERR$_FOO                               64
SCOTT                          EVENT                                  32
SCOTT                          FOO                                    32
SCOTT                          T1                                    176
SCOTT                          T2                                     80
SCOTT                          EMP                                    32
SCOTT                          GRAD_STUDENT_TB                       240
SCOTT                          SYS_C0024557                           64
SCOTT                          PK_EMP                                  0

18 rows selected.

If you are licensed to use the AWR and your AWR retention is long enough and you can make due with fewer available statistics, and you are only interested in the most used segments, you may also be able to use the DBA_HIST_SEG_STAT table.

SQL> ed
Wrote file afiedt.buf

  1  select snap.begin_interval_time,
  2         stat.logical_reads_delta,
  3         obj.object_name
  4    from dba_hist_seg_stat stat
  5         join dba_hist_snapshot snap using (snap_id)
  6         join dba_objects obj on (obj.object_id = stat.obj#)
  7*  where obj.owner = 'SCOTT'
SQL> /

BEGIN_INTERVAL_TIME            LOGICAL_READS_DELTA OBJECT_NAME
------------------------------ ------------------- --------------------
16-AUG-11 04.00.11.428 PM                      160 T1
18-AUG-11 12.00.13.856 PM                      144 GRAD_STUDENT_TB
18-AUG-11 12.00.13.856 PM                       48 SYS_C0024557
20-AUG-11 03.00.59.376 PM                      144 LOAN_TXN

If you are trying to find out whether a particular object is lightly used, however, the AWR is probably not the right solution since it might not show up as one of the top segments in any snapshot window despite being used occasionally.

Alternately, you could write your own process to capture the data from V$SEGMENT_STATISTICS periodically and compute the deltas by subtracting the statistic values from different snapshots.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文