【Oracle】Exadata Smart Scan---Column Projection
The term Column Projection refers to Exadata‘s ability to limit the volume of data transferred between the storage tier and the database tier by only returning columns of interest (that is, those in the select list or
necessary for join operations on the database tier). If your query requests five columns from a 100-column table, Exadata can eliminate most of the data that would be returned to the database servers by non-Exadata storage. This feature is a much bigger deal than you might expect and it can have a very significant impact on response times. Here is an example:
字段投影是指在Exadata中通过只返回感兴趣的列(指那些在SELECT列表中或者必须参加数据库层JOIN操作的列)来限制在存储层和数据库层之间的数据传输。如果查询从拥有100列的表中请求5个字段的值,Exadata能够消除非Exadata存储原本会返回给数据库层的大部分数据。此功能所做的工作远超出你可能的预期,在响应时间上会带来非常巨大的影响。
下面是字段投影的一个例子:
首先在test用户下建立一张大表做测试表:
SQL> conn test/test
Connected.
SQL> @large_table.sql
Table created.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
[oracle@db1 ~]$ sqlldr userid=test/test direct=true rows=100000 control=large_table.ldr
SQL*Loader: Release 11.2.0.1.0 - Production on Fri Oct 10 20:18:25 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Save data point reached - logical record count 100000.
Save data point reached - logical record count 200000.
Save data point reached - logical record count 300000.
Save data point reached - logical record count 400000.
Save data point reached - logical record count 500000.
Save data point reached - logical record count 600000.
Save data point reached - logical record count 700000.
Save data point reached - logical record count 800000.
Save data point reached - logical record count 900000.
Save data point reached - logical record count 1000000.
Load completed - logical record count 1000000.
首先来看一下不启用Smart Scan的情况:
SQL> show parameter cell;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offload_compaction string ADAPTIVE
cell_offload_decryption boolean TRUE
cell_offload_parameters string
cell_offload_plan_display string AUTO
cell_offload_processing boolean TRUE
cell_partition_large_extents string DEFAULT
SQL> ALTER session SET cell_offload_processing=FALSE;
Session altered.
SQL> show parameter cell;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offload_compaction string ADAPTIVE
cell_offload_decryption boolean TRUE
cell_offload_parameters string
cell_offload_plan_display string AUTO
cell_offload_processing boolean FALSE
cell_partition_large_extents string DEFAULT
SQL> ALTER session SET "_serial_direct_read" = TRUE; 启用direct path read
Session altered.
SQL> set timing on
SQL> set autot trace
SQL> ALTER session SET cell_offload_processing=FALSE;
Session altered.
Elapsed: 00:00:00.00
SQL> SELECT id FROM large_table;
1000000 rows selected.
Elapsed: 00:00:11.64
Execution Plan
----------------------------------------------------------
Plan hash value: 1101256009
--------------------------------------------------------------------------------
---------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T
ime |
--------------------------------------------------------------------------------
---------
| 0 | SELECT STATEMENT | | 1000K| 4882K| 4285 (1)| 0
0:00:52 |
| 1 | TABLE ACCESS STORAGE FULL| LARGE_TABLE | 1000K| 4882K| 4285 (1)| 0
0:00:52 |
--------------------------------------------------------------------------------
---------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
81301 consistent gets
15619 physical reads
0 redo size
14646884 bytes sent via SQL*Net to client
733745 bytes received via SQL*Net from client
66668 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1000000 rows processed
SQL> set autot off
SQL> SELECT sql_id,
2 physical_read_bytes A,
3 io_interconnect_bytes B,
4 io_cell_offload_eligible_bytes C,
5 io_cell_offload_returned_bytes D
6 FROM v$sql
7 WHERE sql_text LIKE ‘%large_table%‘
8 AND sql_text NOT LIKE ‘%v$sql%‘;
SQL_ID A B C D
------------- ---------- ---------- ---------- ----------
8rxx50g4qjas9 16384 16384 0 0
6huzbgn52m7pz 127950848 127950848 0 0
再看一下开启Smart Scan的情况:
SQL> alter system flush shared_pool;
System altered.
SQL> ALTER session SET cell_offload_processing = TRUE;
Session altered.
SQL> ALTER session SET "_serial_direct_read" = TRUE;
Session altered.
SQL> show parameter cell;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offload_compaction string ADAPTIVE
cell_offload_decryption boolean TRUE
cell_offload_parameters string
cell_offload_plan_display string AUTO
cell_offload_processing boolean TRUE
cell_partition_large_extents string DEFAULT
SQL> set timing on
SQL> set autot trace
SQL> set timing on
SQL> SELECT id FROM large_table;
1000000 rows selected.
Elapsed: 00:00:05.08
Execution Plan
----------------------------------------------------------
Plan hash value: 1101256009
--------------------------------------------------------------------------------
---------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T
ime |
--------------------------------------------------------------------------------
---------
| 0 | SELECT STATEMENT | | 1000K| 4882K| 4285 (1)| 0
0:00:52 |
| 1 | TABLE ACCESS STORAGE FULL| LARGE_TABLE | 1000K| 4882K| 4285 (1)| 0
0:00:52 |
--------------------------------------------------------------------------------
---------
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
15623 consistent gets
15619 physical reads
0 redo size
14646884 bytes sent via SQL*Net to client
733745 bytes received via SQL*Net from client
66668 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1000000 rows processed
SQL> set timing off
SQL> set autot off
SQL> SELECT sql_id,
2 physical_read_bytes A,
3 io_interconnect_bytes B,
4 io_cell_offload_eligible_bytes C,
5 io_cell_offload_returned_bytes D
6 FROM v$sql
7 WHERE sql_text LIKE ‘%large_table%‘
8 AND sql_text NOT LIKE ‘%v$sql%‘;
SQL_ID A B C D
------------- ---------- ---------- ---------- ----------
8rxx50g4qjas9 16384 16384 0 0
6huzbgn52m7pz 127950848 12592432 127950848 12592432
可以看到在启用Smart Scan的时候,io_interconnect_bytes从127950848降到了12592432,执行时间从00:00:11.64降到了00:00:05.08,同时consistent gets从81301降到了15623。
由于此时没有where条件,所以只是字段投影的影响,没有谓词过滤和存储索引的影响。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。