WEB开发网
开发学院数据库Oracle Oracle数据库11g:SQL计划管理(二) 阅读

Oracle数据库11g:SQL计划管理(二)

 2008-09-04 12:50:24 来源:WEB开发网   
核心提示: ◆然后,我将在我的生产数据库中通过函数DBMS_SPM.UNPACK_STGTAB_BASELINE直接重新构建那些基线概念证明我已经通过查询数据字典视图DBA_SQL_PLAN_BASELINES校验了成功的“unpacking”,Oracle数据库11g:SQL

◆然后,我将在我的生产数据库中通过函数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
;

上一页  2 3 4 5 6 7 8  下一页

Tags:Oracle 数据库 SQL

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接