Oracle生成不同时间段时的统计对比报表

在没有awr 之前,如果希望对不同时间段时,数据库的整体影响进行对比,只能依靠DBA 手工查询相关视图,并通过时间条件来获取差异(还有些统计已经无法对比),而在 AWR 中, 直接就提供了,对不同时间段时,数据库的性能统计做差异对比的功能。

 

执行脚本如下:


SQL> @$ORACLE_HOME/rdbms/admin/awrddrpt.sql


Current Instance


~~~~~~~~~~~~~~~~

 

DB Id

DB Id

DB Name

Inst Num Inst Num Instance

----------- ----------- ------------ -------- -------- ------------

 

3812548755

3812548755 TEST08

1

1 test08

 

 

 

 

 


Specify the Report Type


~~~~~~~~~~~~~~~~~~~~~~~


Would you like an HTML report, or a plain text report?


Enter 'html' for an HTML report, or 'text' for plain text


Defaults to 'html'


Enter value for report_type: html

 


生成的报表格式,没啥说的,就默认的 格式吧。


Type Specified:    HTML


 

 

Instances in this Workload Repository schema


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

DB Id

Inst Num DB Name

Instance

Host

------------ -------- ------------ ------------ ------------

 

* 3812548755

1 TEST08

test08

yans1


 


Database Id and Instance Number for the First Pair of Snapshots


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Using 3812548755 for Database Id for the first pair of snapshots


Using                       1 for Instance Number for the first pair of snapshots


 

 

注意,下面紧接着,是选择第一份报表的相关参数,包括快照的区间,以及开始和结束 的快照 ID


Specify the number of days of snapshots to choose from


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Entering the number of days (n) will result in the most recent


(n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots.


 

Enter value for num_days: 2


Listing the last 2 days of Completed Snapshots

 

 

 

 

 

 

Snap

Instance

DB Name

Snap Id

Snap Started

Level

------------ ------------ --------- ------------------ -----

 

 

test08

TEST08

7450 25 10 2009 00:00

1

 

 

7451 25 10 2009 01:00

1

 

 

7452 25 10 2009 02:00

1

 

 

7453 25 10 2009 03:00

1

 

 

7454 25 10 2009 04:00

1

 

 

7455 25 10 2009 05:00

1

 

 

7456 25 10 2009 06:00

1

 

 

7457 25 10 2009 07:00

1

 

 

7458 25 10 2009 08:00

1

 

 

7459 25 10 2009 09:00

1

 

 

7460 25 10 2009 10:00

1

 

 

7461 25 10 2009 11:00

1

 

 

7462 25 10 2009 12:00

1

 

 

7463 25 10 2009 13:00

1

 

 

7464 25 10 2009 14:00

1

 

 

7465 25 10 2009 15:00

1

 

 

7466 25 10 2009 16:00

1

 

 

7467 25 10 2009 17:00

1

 

 

7468 25 10 2009 18:00

1

 

 

7469 25 10 2009 19:00

1


 

 


7470 25 10 2009 20:00

1

7471 25 10 2009 21:00

1

7472 25 10 2009 22:00

1

7473 25 10 2009 23:00

1

7474 26 10 2009 00:00

1

7475 26 10 2009 01:00

1

7476 26 10 2009 02:00

1

7477 26 10 2009 03:00

1

7478 26 10 2009 04:00

1

7479 26 10 2009 05:00

1

7480 26 10 2009 06:00

1

7481 26 10 2009 07:00

1

7482 26 10 2009 08:00

1

7483 26 10 2009 09:00

1

7484 26 10 2009 10:00

1

7485 26 10 2009 11:00

1

7486 26 10 2009 12:00

1

7487 26 10 2009 13:00

1

7488 26 10 2009 14:00

1

7489 26 10 2009 15:00

1

 

 


Specify the First Pair of Begin and End Snapshot Ids


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Enter value for begin_snap: 7459


First Begin Snapshot Id specified: 7459


Enter value for end_snap: 7462


First End      Snapshot Id specified: 7462

 

然后,是选择要对比的报表相关参数,包括快照的区间,以及开始和结束的快照 ID


 

 

Instances in this Workload Repository schema


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

DB Id

Inst Num DB Name

Instance

Host

------------ -------- ------------ ------------ ------------

 

* 3812548755

1 TEST08

test08

yans1

 

 

 

 


 



Database Id and Instance Number for the Second Pair of Snapshots


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Using 3812548755 for Database Id for the second pair of snapshots


Using                       1 for Instance Number for the second pair of snapshots


 

 

Specify the number of days of snapshots to choose from


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Entering the number of days (n) will result in the most recent


(n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots.


 

Enter value for num_days2: 2


Listing the last 2 days of Completed Snapshots

 

 

 

 

 

 

Snap

Instance

DB Name

Snap Id

Snap Started

Level

------------ ------------ --------- ------------------ -----

 

 

test08

TEST08

7450 25 10 2009 00:00

1

 

 

7451 25 10 2009 01:00

1

 

 

7452 25 10 2009 02:00

1

 

 

7453 25 10 2009 03:00

1

 

 

7454 25 10 2009 04:00

1

 

 

7455 25 10 2009 05:00

1

 

 

7456 25 10 2009 06:00

1

 

 

7457 25 10 2009 07:00

1

 

 

7458 25 10 2009 08:00

1

 

 

7459 25 10 2009 09:00

1

 

 

7460 25 10 2009 10:00

1

 

 

7461 25 10 2009 11:00

1

 

 

7462 25 10 2009 12:00

1

 

 

7463 25 10 2009 13:00

1

 

 

7464 25 10 2009 14:00

1

 

 

7465 25 10 2009 15:00

1

 

 

7466 25 10 2009 16:00

1

 

 

7467 25 10 2009 17:00

1

 

 

7468 25 10 2009 18:00

1

 

 

7469 25 10 2009 19:00

1

 

 

7470 25 10 2009 20:00

1

 

 

7471 25 10 2009 21:00

1

 

 

7472 25 10 2009 22:00

1


 


7473 25 10 2009 23:00

1

7474 26 10 2009 00:00

1

7475 26 10 2009 01:00

1

7476 26 10 2009 02:00

1

7477 26 10 2009 03:00

1

7478 26 10 2009 04:00

1

7479 26 10 2009 05:00

1

7480 26 10 2009 06:00

1

7481 26 10 2009 07:00

1

7482 26 10 2009 08:00

1

7483 26 10 2009 09:00

1

7484 26 10 2009 10:00

1

7485 26 10 2009 11:00

1

7486 26 10 2009 12:00

1

7487 26 10 2009 13:00

1

7488 26 10 2009 14:00

1

7489 26 10 2009 15:00

1

 

 


Specify the Second Pair of Begin and End Snapshot Ids


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Enter value for begin_snap2: 7483


Second Begin Snapshot Id specified: 7483


Enter value for end_snap2: 7486


Second End      Snapshot Id specified: 7486


 

 

最后,为要生成的报表命令:


Specify the Report Name


~~~~~~~~~~~~~~~~~~~~~~~


The default report file name is awrdiff_1_7459_1_7483.html To use this name, press <return> to continue, otherwise enter an alternative.


Enter value for report_name: awr_diff_1_7459_1_7483.html


Using the report name awr_diff_1_7459_1_7483.html


 

 

<HTML><HEAD><TITLE>Workload Repository Compare Period Report</TITLE>


...............


...............




 

报表生成以后,在显示时将以并列的形式,直观的显示出两个不同时间段里,数据库各 项参数的差异,摘要如图:

 

生成指定 SQL 语句的统计报表

 

 

前例的对比是在单实例环境下进行的,如果希望对多实例的数据库做对比,那就要使用 $ORACLE_HOME/rdbms/admin/awrddrpi.sql 脚本了。该脚本的操作基本与前例相同,这里 不再演示,感兴趣的朋友不妨自行测试。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/1700919/viewspace-2120584/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/1700919/viewspace-2120584/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据引用\[1\]和引用\[2\],可以使用Oracle的语法来按时间段分组统计数据。首先,可以使用CONNECT BY LEVEL语句生成一个间序列,每个间间隔为6小。然后,可以使用TO_CHAR函数将间格式化为所需的格式,并使用FLOOR函数将分钟舍入到最接近的15分钟。接下来,可以使用WHERE子句筛选出指定间范围内的数据,并使用GROUP BY子句按时间段进行分组。最后,可以使用ORDER BY子句按间排序结果。 以下是一个示例查询的代码: ```sql SELECT TO_CHAR(StartTime, 'YYYY-MM-DD HH24:MI:SS') AS StartTime, SUM(Count) AS Counts FROM table WHERE StartTime <= TO_DATE('2016-11-29 18:00:00', 'YYYY-MM-DD HH24:MI:SS') GROUP BY TO_CHAR(StartTime, 'YYYY-MM-DD HH24:MI:SS') ORDER BY StartTime; ``` 这个查询将按照每个时间段(每15分钟)统计数据,并按照间顺序进行排序。你可以根据自己的需求修改查询中的间范围和间格式。 #### 引用[.reference_title] - *1* [Oracle时间段分组统计](https://blog.csdn.net/weixin_39752157/article/details/116335359)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Oracle数据库oracle时间段统计15分钟内的数据](https://blog.csdn.net/weixin_36232899/article/details/116293382)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值