Oracle数据库11g:SQL计划管理(二)
2008-09-04 12:50:24 来源:WEB开发网◆然后,我将在我的生产数据库中通过函数DBMS_SPM.UNPACK_STGTAB_BASELINE直接重新构建那些基线
概念证明
我已经通过查询数据字典视图DBA_SQL_PLAN_BASELINES校验了成功的“unpacking”。(在本系列前面的文章中我使用过相同的查询,请参考列表1.3)。这六个目标查询的SQL计划基线显示的输出结果在列表2.9中,将MANUAL_LOAD值标记为ORIGIN以指示来源于DBA的干预而不是自动SQL计划基线捕获方式。
下一步
我已经讲述了在数据库升级过程中SQL计划基线如何有效地限制(如果不能消除)SQL语句性能突然倒退,以及在部署一个崭新的应用程序之前如何捕获SQL计划基线以限制计划性能降低,在本系列下一篇也是最后一篇中,我将讲述另外一个SQL计划管理情景,在Oracle 10g和11g数据库之间不用导出SQL计划基线进行数据库升级,我还将讨论如何:
SPM情景#1:
/*
|| Script: SPM_2_1.sql
|| Purpose: Generate several SQL statements that perform Data
|| Warehouse query loads on an Oracle 10gR2 database
|| for capture into a SQL Tuning Set (STS) that will be
|| transferred to an Oracle 11g database to demonstrate
|| SQL Plan Baseline seeding.
*/
-----
-- Query: SPM_2_1.1
-- Purpose: Summarize sales activity within country and Promotion
-----
select /*SPM_2_1.1*/
CTY.country_total_id
,PR.promo_total_id
,count(S.amount_sold)
,SUM(S.amount_sold)
,SUM(S.quantity_sold)
FROM
sh.sales S
,sh.customers C
,sh.countries CTY
,sh.promotions PR
where S.cust_id = C.cust_id
AND C.country_id = CTY.country_id
AND S.promo_id = PR.promo_id
GROUP BY
CTY.country_total_id
,PR.promo_total_id
;
-----
-- Query: SPM_2_1.2
-- Purpose: Summarize sales activity within country and Promotion
-----
select /*SPM_2_1.2*/
CTY.country_id
,CTY.country_subregion_id
,CTY.country_region_id
,CTY.country_total_id
,PR.promo_total_id
,count(S.amount_sold)
,SUM(S.amount_sold)
,SUM(S.quantity_sold)
FROM
sh.sales S
,sh.customers C
,sh.countries CTY
,sh.promotions PR
where S.cust_id = C.cust_id
AND C.country_id = CTY.country_id
AND S.promo_id = PR.promo_id
GROUP BY
CTY.country_id
,CTY.country_subregion_id
,CTY.country_region_id
,CTY.country_total_id
,PR.promo_total_id
;
-----
-- Query: SPM_2_1.3
-- Purpose: Summarize sales activity within country, Product,
-- Channel and Promotion
-----
select /*SPM_2_1.3*/
CTY.country_total_id
,P.prod_id
,P.prod_subcategory_id
,P.prod_category_id
,P.prod_total_id
,CH.channel_id
,CH.channel_class_id
,CH.channel_total_id
,PR.promo_total_id
,count(S.amount_sold)
,SUM(S.amount_sold)
,SUM(S.quantity_sold)
FROM
sh.sales S
,sh.customers C
,sh.countries CTY
,sh.products P
,sh.channels CH
,sh.promotions PR
where S.cust_id = C.cust_id
AND C.country_id = CTY.country_id
AND S.prod_id = P.prod_id
AND S.channel_id = CH.channel_id
AND S.promo_id = PR.promo_id
GROUP BY
CTY.country_total_id
,P.prod_id
,P.prod_subcategory_id
,P.prod_category_id
,P.prod_total_id
,CH.channel_id
,CH.channel_class_id
,CH.channel_total_id
,PR.promo_total_id
;
-----
-- Query: SPM_2_1.4
-- Purpose: Summarize sales activity within country, Product,
-- Channel and Promotion
-----
select /*SPM_2_1.4*/
CTY.country_total_id
,P.prod_category_id
,P.prod_total_id
,CH.channel_id
,CH.channel_class_id
,CH.channel_total_id
,PR.promo_total_id
,count(S.amount_sold)
,SUM(S.amount_sold)
,SUM(S.quantity_sold)
FROM
sh.sales S
,sh.customers C
,sh.countries CTY
,sh.products P
,sh.channels CH
,sh.promotions PR
where S.cust_id = C.cust_id
AND C.country_id = CTY.country_id
AND S.prod_id = P.prod_id
AND S.channel_id = CH.channel_id
AND S.promo_id = PR.promo_id
GROUP BY
CTY.country_total_id
,P.prod_category_id
,P.prod_total_id
,CH.channel_id
,CH.channel_class_id
,CH.channel_total_id
,PR.promo_total_id
;
-----
-- Query: SPM_2_1.5
-- Purpose: Summarize sales activity within country, Product,
-- Channel and Promotion
-----
select /*SPM_2_1.5*/
CTY.country_id
,CTY.country_subregion_id
,CTY.country_region_id
,CTY.country_total_id
,P.prod_id
,P.prod_subcategory_id
,P.prod_category_id
,P.prod_total_id
,CH.channel_id
,CH.channel_class_id
,CH.channel_total_id
,PR.promo_total_id
,count(S.amount_sold)
,SUM(S.amount_sold)
,SUM(S.quantity_sold)
FROM
sh.sales S
,sh.customers C
,sh.countries CTY
,sh.products P
,sh.channels CH
,sh.promotions PR
where S.cust_id = C.cust_id
AND C.country_id = CTY.country_id
AND S.prod_id = P.prod_id
AND S.channel_id = CH.channel_id
AND S.promo_id = PR.promo_id
GROUP BY
CTY.country_id
,CTY.country_subregion_id
,CTY.country_region_id
,CTY.country_total_id
,P.prod_id
,P.prod_subcategory_id
,P.prod_category_id
,P.prod_total_id
,CH.channel_id
,CH.channel_class_id
,CH.channel_total_id
,PR.promo_total_id
;
- ››sql server自动生成批量执行SQL脚本的批处理
- ››sql server 2008亿万数据性能优化
- ››SQL Server 2008清空数据库日志方法
- ››oracle 中 UPDATE nowait 的使用方法
- ››Oracle ORA-12560解决方法
- ››Oracle 10g RAC 常用维护命令
- ››Oracle如何在ASM中定位文件的分布
- ››sqlserver安装和简单的使用
- ››SQL Sever 2008 R2 数据库管理
- ››SQL SERVER无法安装成功,sqlstp.log文件提示[未发...
- ››Oracle的DBMS_RANDOM.STRING 的用法
- ››oracle 外部表导入时间日期类型数据,多字段导入
更多精彩
赞助商链接