- 浏览: 90639 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (81)
- 读书笔记 (14)
- NetBeans学习 (1)
- JavaBeans and Bean Events (3)
- 《Pro Oracle SQL》Chapter 2 SQL Execution (13)
- 《Pro Oracle SQL》Chapter 3 Access and Join Methods (16)
- Pro Oracle SQL Chapter 5 (0)
- Pro Oracle SQL Chapter 6 (0)
- Pro Oracle SQL Chapter 7 (9)
- Pro Oracle SQL Chapter 8 (9)
- 《Pro Oracle SQL》Chapter 9 The Model Clause (11)
- 《Pro Oracle SQL》Chapter 10 Subquery Factoring (7)
最新评论
-
mojunbin:
这个不能不顶。
《Pro Oracle SQL》 Chapter2--2.1 Oracle Architecture Basics -
Branding:
谢谢,获益匪浅
《Pro Oracle SQL》--chapter 5--5.6 Building Logical Expressions -
Branding:
《Pro Oracle SQL》--Chapter 5--5.4 Questions about the Question -
Branding:
谢谢
《Pro Oracle SQL》 翻译序 -- 读书心得 -
jiaoshiguoke:
继续 加油
《Pro Oracle SQL》--Chapter 6--6.1 Explain Plans--之三
《Pro Oracle SQL》Chapter10.2.3 Testing the Effects of Query Changes
Testing the Effects of Query Changes 测试查询改变的效果 (page 315)
Even as data does not remain static, SQL is not always static.
Sometimes requirements change, so code must be modified. What if the requirements changed for the examples in Listings 10-3 and 10-4? Would minor changes invalidate the use of the hints embedded in the SQL? This is probably something worth investigating, so let’s do so.
正如数据不会保持静态,SQL也不总是静态。
有时候需求改变,因此代码需要修改。如果需求改变对于列表10-3和10-4中例子的会怎样?是否最小的改变使得嵌入SQL中的提示失效?这可能是值得调查的,因此让我们研究一下。
Previously, you were reporting on income bracket
s when the count of them for any country was
greater than or equal to 25% of the total global count for that bracket. Now you are asked to include an
income bracket if it is among those income brackets the number of which is greater than the median,
based on the number of customers per bracket. This SQL is seen in Listing 10-6. Notice that the INLINE
hint has been left in. So now there’s an additional full table scan and index scan as compared to the
execution plan in Listing 10-4. While the elapsed time has increased, it still seems reasonable.
之前,你报告了任意国家的
收入阶层,
他们的数量大于或等于全球那个阶层数量的25%。现在你要求包含一个收入阶层,如果它位列那些数量大于中位数的收入阶层,基于每桶的顾客数。
SQL如列表
10-6所示。注意INLINE提示留下了。因此,相比于列表10-4的执行计划,现在有一个额外的全表扫描和索引扫描,虽然消耗时间增加,它似乎还是合理的。
Now that there’s an additional table scan and index scan, how do you think the performance of this
query will fare if temporary table transformations are allowed to take place? The results can be seen in
Listing 10-7.
既然这里有了额外的表扫描和索引扫描,你如何认为这个查询的性能是公平的,即使临时表变换运行发生?结果可从列表10-7中看出。
Because there’s that additional scan taking place in the modified version of the query, the overhead
of logical IO becomes more apparent. It is significantly more efficient with this query to allow Oracle to
perform table transformations, writing the results of the hash join to a temporary table on disk where
they can be reused throughout the query.
因为在修改版的查询中有额外的扫描发生,逻辑IO的开销变得更明显。这个查询显然较为有效率,因为允许Oracle执行表变换,把哈希连接的结果写入磁盘的临时表,可贯穿于整个查询重用。
Listing 10-6. Modified Income Search - INLINE
1 with cust as (
2 select /*+ inline
gather_plan_statistics */
3 b.cust_income_level,
4 a.country_name
5 from sh.customers b
6 join sh.countries a on a.country_id = b.country_id
7 ),
8 median_income_set as (
9 select /*+ inline */ cust_income_level, count(*) income_level_count
10 from cust
11 group by cust_income_level
12 having count(cust_income_level) > (
13 select median(income_level_count) income_level_count
14 from (
15 select cust_income_level, count(*) income_level_count
16 from cust
17 group by cust_income_level
18 )
19 )
20 )
21 select country_name, cust_income_level, count(country_name) country_cust_count
22 from cust c
23 having count(country_name) >
24 (
25 select count(*) * .01
26 from cust c2
27 )
28 or cust_income_level in ( select mis.cust_income_level from median_income_set mis)
29 group by country_name, cust_income_level;
COUNTRY INCOME LEVEL COUNT
------------------------------ -------------------- --------
Argentina D: 70,000 - 89,999 25
Argentina E: 90,000 - 109,999 39
...
United States of America K: 250,000 - 299,999 1062
United States of America L: 300,000 and above 982
123 rows selected.
Elapsed: 00:00:01.26
Statistics
----------------------------------------------------------
1524 recursive calls
0 db block gets
23362 consistent gets
1486 physical reads
0 redo size
15570 bytes sent via SQL*Net to client
1195 bytes received via SQL*Net from client
63 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
123 rows processed
---------------------------------------------------------------------------------
|
Id | Operation |
Name |Starts |E-Rows |A-Rows | A-Time
|
---------------------------------------------------------------------------------
|
0 | SELECT STATEMENT | |
1 | | 123 |00:00:00.37 |
|* 1
| FILTER |
| 1 | | 123 |00:00:00.37 |
|
2 | SORT GROUP BY | |
1 | 20 | 236 |00:00:00.08 |
|* 3
| HASH JOIN | |
1 | 55500 | 55500 |00:00:00.38 |
| 4 | TABLE ACCESS FULL | COUNTRIES | 1 | 23 | 23 |00:00:00.01 |
| 5 | TABLE ACCESS FULL | CUSTOMERS | 1 | 55500 | 55500 |00:00:00.08 |
|
6 | SORT AGGREGATE | |
1 | 1 | 1 |00:00:00.04 |
|* 7
| HASH JOIN | |
1 | 55500 | 55500 |00:00:00.43 |
| 8 | INDEX FULL SCAN | COUNTRIES_PK | 1 | 23 | 23 |00:00:00.01 |
| 9 | TABLE ACCESS FULL | CUSTOMERS | 1 | 55500 | 55500 |00:00:00.10 |
|*
10 | FILTER |
| 13 | | 6 |00:00:00.65 |
|
11 | HASH GROUP BY | |
13 | 1 | 133 |00:00:00.59 |
|* 12
| HASH JOIN | |
13 | 55500 | 721K |00:00:05.18 |
| 13 | INDEX FULL SCAN | COUNTRIES_PK | 13 | 23 | 299 |00:00:00.01|
| 14 | TABLE ACCESS FULL | CUSTOMERS | 13 | 55500 | 721K |00:00:01.10|
|
15 | SORT GROUP BY | |
1 | 1 | 1 |00:00:00.06|
| 16
| VIEW
| | 1 | 12 |
13 |00:00:00.06|
| 17 | SORT GROUP BY |
| 1 | 12 |
13 |00:00:00.06|
|* 18 | HASH
JOIN | | 1 |
55500 | 55500 |00:00:00.42|
| 19 | INDEX FULL SCAN | COUNTRIES_PK | 1 | 23 | 23 |00:00:00.01|
| 20 | TABLE ACCESS FULL | CUSTOMERS | 1 | 55500 | 55500 |00:00:00.08|
---------------------------------------------------------------------------------
Listing 10-7. Modified Income Search - MATERIALIZE
1 with cust as (
2 select /*+ materialize
gather_plan_statistics */
3 b.cust_income_level,
4 a.country_name
5 from sh.customers b
6 join sh.countries a on a.country_id = b.country_id
7 ),
...
CUSTOMER
COUNTRY INCOME LEVEL COUNT
------------------------------ ------------------------- --------
Argentina D: 70,000 - 89,999 25
Argentina E: 90,000 - 109,999 39
...
United States of America K: 250,000 - 299,999 1062
United States of America L: 300,000 and above 982
123 rows selected.
Elapsed: 00:00:00.87
Statistics
----------------------------------------------------------
2001 recursive calls
324 db block gets
3221 consistent gets
1822 physical reads
1244 redo size
15570 bytes sent via SQL*Net to client
1195 bytes received via SQL*Net from client
63 SQL*Net roundtrips to/from client
38 sorts (memory)
0 sorts (disk)
123 rows processed
-------------------------------------------------------------------------------
|
Id |Operation
|Name |Starts |E-Rows |A-Rows | A-Time
|
-------------------------------------------------------------------------------
|
0 |SELECT STATEMENT | |
1 | | 123 |00:00:00.54 |
|
1 | TEMP TABLE TRANSFORMATION | | 1
| | 123 |00:00:00.54 |
| 2
| LOAD AS SELECT | |
1 | | 0 |00:00:00.37 |
|*
3 | HASH JOIN
| | 1 | 55500 | 55500
|00:00:03.21 |
| 4 | TABLE ACCESS FULL | COUNTRIES | 1 | 23 | 23 |00:00:00.01 |
| 5 | TABLE ACCESS FULL | CUSTOMERS | 1 | 55500 | 55500 |00:00:02.91 |
|
6 | LOAD AS SELECT |
| 1 | | 0 |00:00:00.10 |
|*
7 | FILTER
| | 1 | |
6 |00:00:00.09 |
| 8
| HASH GROUP BY | |
1 | 1 | 13 |00:00:00.06 |
|
9 | VIEW
| | 1 | 55500 | 55500
|00:00:00.24 |
| 10 | TABLE ACCESS FULL | SYS_TEMP_0F | 1 | 55500 | 55500 |00:00:00.11 |
|
11 | SORT GROUP BY |
| 1 | 1 | 1 |00:00:00.03 |
|
12 | VIEW
| | 1 |12 |
13 |00:00:00.03|
| 13 | SORT GROUP
BY | | 1 |
12 | 13 |00:00:00.03 |
|
14| VIEW |
| 1 | 55500 | 55500 |00:00:00.21 |
| 15 | TABLE ACCESS FULL |SYS_TEMP_0F | 1 | 55500 | 55500 |00:00:00.07 |
|*
16| FILTER
| | 1 | | 123
|00:00:00.06 |
| 17 | SORT GROUP
BY | | 1 |
20 | 236 |00:00:00.05|
| 18 |
VIEW | |
1 | 55500 | 55500 |00:00:00.21|
| 19 | TABLE ACCESS FULL |SYS_TEMP_0F | 1 | 55500 | 55500 |00:00:00.07|
|
20 | SORT AGGREGATE | |
1 | 1 | 1 |00:00:00.01|
|
21 | VIEW |
| 1 | 55500 | 55500 |00:00:00.21|
| 22 | TABLE ACCESS FULL |SYS_TEMP_0F | 1 | 55500 | 55500 |00:00:00.07|
|*
23| VIEW |
| 13 | 1 | 6
|00:00:00.01|
| 24 | TABLE ACCESS FULL |SYS_TEMP_0F | 13 | 1 | 63 |00:00:00.01|
-------------------------------------------------------------------------------
发表评论
-
《Pro Oracle SQL》10.3 Recursive Subqueries
2012-07-06 00:30 1450Recursive Subqueries 递归子查询 ... -
《Pro Oracle SQL》Chapter 10.2.5 Applying Subquery Factoring to PL/SQL
2012-07-04 23:19 1433Applying Subquery Factoring to ... -
《Pro Oracle SQL》 10.2.4 Seizing Other Optimization Opportunities
2012-07-03 23:31 98210.2.4 Seizing Other Optimizati ... -
《Pro Oracle SQL》Chapter 10.2.2 Testing Over Multiple Executions
2012-05-24 00:41 954Testing Over Multiple Execution ... -
《Pro Oracle SQL》Chapter10 -- 10.2 Optimizing SQL -10.2.1Testing Execution Plans
2012-05-14 22:19 132610.2 Optimizing SQL 优化SQL ... -
《Pro Oracle SQL》Chapter 10 Subquery Factoring --10.1 Standard Usage
2012-05-02 22:46 1139Subquery Factoring 子查询分解 ( ...
相关推荐
《使用FireDAC在XE10.2.3中连接Oracle数据库的实践》 在Delphi XE10.2.3开发环境中,连接Oracle数据库是一项常见的任务,这通常涉及到使用FireDAC组件。FireDAC(Firebird Data Access Components)是Embarcadero...
原书名: Pro Oracle SQL 原出版社: Apress 作者: (美)Karen Morton Kerry Osborne Robyn Sands Riyaj Shamsudeen Jared Still 译者: 朱浩波 丛书名: 图灵程序设计丛书 出版社:人民邮电出版社 ISBN:...
RAD Studio 10.2.3 2631 keygen source RAD Studio 10.2.3 keygen 支持delphi c++builder10.2.3的一键激活!同时向下兼容激活10.0 10.1 10.2等版本。 RAD Studio 10.2.3 Tokyo v25.0.29899.2631 官方 ISO 文件下载...
delphi 10.2.3 keygen 源代码,
AutoUpgrader_Pro_v5.2_XE7_XE8_XE10_XE10.1_XE10.3_Rio Devart_SQL_Server_Data_Access_Components_SDAC_for_Delphi_8.0.1_Tokyo Devart_SQL_Server_Data_Access_Components_SDAC_8.2.8_Full_Source Devart_SQL_...
Indy10.2.3是Indy(Internet Direct)组件库的一个特定版本,适用于Embarcadero Delphi编程环境。这个版本主要针对Delphi 7到Delphi 2007这些早期的IDE版本,提供了全面的网络通信功能。Indy是一个开源的、跨平台的...
SecureBridge是一个Delphi, Delphi for .NET, C++Builder的非可视组件库。用来保护计算机与可信任网络之间的连接,阻止未经授权的访问。可以为安全连接远程服务提供SSH协议,可以配合使用数据访问组件,以防止资料被...
本实例专注于使用DELPHI XE10.2.3环境实现这一目标,特别是在FireMonkey (FMX)平台上。该环境提供了跨平台开发的能力,允许开发者创建能在不同操作系统上运行的应用程序。 DELPHI XE10.2.3是一款强大的对象 Pascal ...
Delphi 10.2.3安装文件及破解,亲自安装可用,适合初学者,安装破解中文翻译以便看不懂英文的安装
arcgis android 10.2.3
C++Builder 10.2.3(keygen)实测可用 1. http://altd.embarcadero.com/download/radstudio/10.2/delphicbuilder10_2_3_2631.iso MD5:1bd28e95596ffed061e57e28e155666d Version:25.0.29899.2631 Click "Generate" ...
delphi10.2.3(keygen) delphi10.2.3(keygen) delphi10.2.3(keygen)
RadStudio10.2.3-KeyGen支持最新版的RadStudio10.2.3.3231,亲测可用。
亲自试验过,好用。 安装步骤:1、在D7的目录下,双击Borland Delphi7.msi文件。 2、在弹出的对话框中选“Modify”。 3、然后点“Next”,在接下来的对话框中,找到Indy,点“Do Not Install”。...
Delphi 10.2.3 - 中文版.rar
DXperience产品概述: ...DXperienceUniversal-10.2.3.exe 下载 ttp://downloads.devexpress.com/0f3bbde2-fe6b-49de-96de-9d656f391b8a/0.0.0.0/DXperience/2010.2/3/DXperienceUniversal-10.2.3.exe ...
DXperience 10.2.3 Crack
下面将详细阐述Devexpress 10.2.3的重编译步骤。 1. **环境准备**: 在开始重编译之前,确保你的计算机上已经安装了以下软件: - .NET Framework:根据Devexpress 10.2.3的要求,你需要安装相应的.NET版本,可能...
DXperience是DevExpress公司提供的一款强大的UI控件套件,版本号10.2.3代表这是该产品的第10.2.3次更新。DevExpress是一家知名的软件开发工具供应商,为.NET Framework、ASP.NET、WinForms、JavaScript等平台提供...