如何生成指定SQL语句的AWR报表
给表取个别名,然后进行,多表用逗号分隔。如`
dede__arctiny` arc , `dede__archives` arv WHERE arvppid=arcppid
这种形式其中ARC和ARV分别是这两张表的别名,然后按照你的需求写WHERE条件不就行了?
将以下函数放入include/extendfuncphp
//统计栏目文章数function GetTotalArc($tid){
global $dsql;
$sql = GetSonIds($tid);
$row = $dsql->GetOne("Select count(id) as dd From `#@__archives` where typeid
in({$sql})");
return $row['dd'];
}
//统计当前栏目信息数
function dynamic_num($current_id){
global $dsql;
//读取当前栏目的子ID
$sql = "SELECT id FROM `#@__arctype` WHERE id='$current_id' ||
topid='$current_id'";
$dsql->SetQuery($sql);
$dsql->Execute();
while($row = $dsql->GetArray()){
$arr[]=$row[id];
}
foreach($arr as $key=>$value){
$type = $value ',';
}
$ty= ""$type"0";
//echo $ty;
$t_num = $dsql->GetOne("select count() as num from `#@__archives` where typeid
in($ty)");
//echo $t_num[num];
if(is_array($t_num)){
return " "$t_num[num]" ";
}else{
return "0" ;
}
}
模板中使用以下标签调用:
{dede:field name=’typename’/}</b>(此栏目共{dede:type}[field:idfunction="dynamic_num(@me)" /]{/dede:type}条记录)
{dede:channel type=’son’ }
<li><a href=’[field:typelink/]‘>[field:typename/]</a>(<span>[field:ID
runphp='yes'] @me = GetTotalArc(@me);[/field:ID]</span>)</li>
{/dede:channel}
以上代码是两个函数,一个统计栏目文章数,另一个统计当前栏目信息数。
如果希望对多实例的数据库做对比,那就要使用$ORACLE_HOME/rdbms/admin/awrddrpisql脚本了。该脚本的操作基本与单实例基本相同,
1,生成指定SQL语句的统计报表 如果希望对多实例的数据库做对比,那就要使用$Oracle_HOME/rdbms/admin/awrddrpisql脚本了。该脚本的操作基本与单实例基本相同,这里不再演示,感兴趣的朋友可以自己测试下。
2 ,,生成指定SQL语句的统计报表 这项统计专门用来分析某条指定的SQL语句,通过awrsqrptsql脚本,awr能够生成指定sql(曾经执行过的SQL)的执行计划,消耗的资源等等信息,有助于DBA进行SQL调优。[oracle@even ~]$ sqlplus / as sysdba
SQLPlus: Release 102010 - Production on Sun Dec 23 11:39:53 2012
Copyright (c) 1982, 2005, Oracle All rights reserved
Connected to:Oracle Database 10g Enterprise Edition Release 102010 - ProductionWith the Partitioning, Oracle Label Security, OLAP and Data Mining options
SQL> exec dbms_workload_repositorycreate_snapshot;
PL/SQL procedure successfully completed
SQL> @$ORACLE_HOME/rdbms/admin/awrsqrptsql
Current Instance~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance----------- ------------ -------- ------------ 2100083002 TEST 1 test
Specify the Report Type~~~~~~~~~~~~~~~~~~~~~~~Would you like an HTML report, or a plain text reportEnter 'html' for an HTML report, or 'text' for plain textDefaults 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------------ -------- ------------ ------------ ------------ 2100083002 1 TEST test evenoracle com
Using 2100083002 for database IdUsing 1 for instance number
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 Pressingwithoutspecifying a number lists all completed snapshots
Enter value for num_days: 1
Listing the last day's Completed Snapshots
SnapInstance DB Name Snap Id Snap Started Level------------ ------------ --------- ------------------ -----test TEST 34 23 Dec 2012 11:00 1 35 23 Dec 2012 11:30 1 36 23 Dec 2012 11:40 1
Specify the Begin and End Snapshot Ids~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Enter value for begin_snap: 34Begin Snapshot Id specified: 34
Enter value for end_snap: 36End Snapshot Id specified: 36
Specify the SQL Id~~~~~~~~~~~~~~~~~~注意,这里要指定分析的SQL_ID,你可能想问,要分析的SQL ID从何而来呢?一般来说,SQL_ID可以通过V$SQL(及其它相关视图),要么是通过AWR/STATSPACK等工具。Enter value for sql_id: 4vsh055snc3duSQL ID specified: 4vsh055snc3du
Specify the Report Name~~~~~~~~~~~~~~~~~~~~~~~The default report file name is awrsqlrpt_1_34_36html To use this name,pressto continue, otherwise enter an alternative
Enter value for report_name: /home/oracle/awr_20121231html
Using the report name /home/oracle/awr_20121231html
AWR SQL Reportbodyawr {font:bold 10pt Arial,Helvetica,Geneva,sans-serif;color:black;Report written to /home/oracle/awr_20121231html
0条评论