Chinaunix首页 | 论坛 | 博客
  • 博客访问: 103753875
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Oracle

2008-04-22 19:49:29

作者: Jim Czuprynski/黄永兵 译 出处:51CTO.com  
 
 
SPM_3_2:

-----
-- Query: SPM_3_2.1
-- Optimizer will use  "star transformation" method to retrieve a
-- smaller subset more efficiently
-----
SELECT /*SPM_3_2.1*/
S.cust_id
,C.cust_last_name
,S.prod_id
,P.prod_name
,S.amount_sold
,S.quantity_sold
FROM
sh.sales S
,sh.customers C
,sh.products P
WHERE S.cust_id = C.cust_id
AND S.prod_id = P.prod_id
AND S.prod_id BETWEEN 100 AND 500
AND C.cust_last_name LIKE 'Sand%'
ORDER BY
S.cust_id
,C.cust_last_name
,S.prod_id
,P.prod_name
;

-----
-- Query: SPM_3_2.2
-- Optimizer will choose a full table scan of SH.CUSTOMERS because of the larger
-- subset of data that's retrieved
-----
SELECT /*SPM_3_2.2*/
S.cust_id
,C.cust_last_name
,S.prod_id
,P.prod_name
,S.amount_sold
,S.quantity_sold
FROM
sh.sales S
,sh.customers C
,sh.products P
WHERE S.cust_id = C.cust_id
AND S.prod_id = P.prod_id
AND S.prod_id BETWEEN 0 AND 99999
AND C.cust_last_name LIKE 'Zil%'
ORDER BY
S.cust_id
,C.cust_last_name
,S.prod_id
,P.prod_name
;

-----
-- Query: SPM_3_2.3
-- Optimizer will still choose a full table scan of SH.CUSTOMERS but
-- return an even larger result set
-----
SELECT /*SPM_3_2.3*/
S.cust_id
,C.cust_last_name
,S.prod_id
,P.prod_name
,S.amount_sold
,S.quantity_sold
FROM
sh.sales S
,sh.customers C
,sh.products P
WHERE S.cust_id = C.cust_id
AND S.prod_id = P.prod_id
AND S.prod_id BETWEEN 0 AND 99999
AND C.cust_last_name LIKE 'S%'
ORDER BY
S.cust_id
,C.cust_last_name
,S.prod_id
,P.prod_name
;

阅读(343) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~