Home > Database > Mysql Tutorial > body text

accessandfilter

WBOY
Release: 2016-06-07 16:01:02
Original
856 people have browsed it

access:表示这个谓词条件的值将会影响数据的访问路径(表还是索引)。 filter:表示谓词条件的值并不会影响数据访问路径,只起到过滤的作用。 ----创建一张表echo----SQL create table echo as select * from dba_objects;Table created.SQL set autotrace trac

access:表示这个谓词条件的值将会影响数据的访问路径(表还是索引)。

filter:表示谓词条件的值并不会影响数据访问路径,只起到过滤的作用。

----创建一张表echo----
SQL> create table echo as select * from dba_objects;

Table created.

SQL> set autotrace trace exp;
SQL> set linesize 150;
SQL> select * from echo where object_id=1000;

Execution Plan
----------------------------------------------------------
Plan hash value: 642657756

--------------------------------------------------------------------------
| Id  | Operation      | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |     |    12 |  2484 |   289   (1)| 00:00:04 |
|*  1 |  TABLE ACCESS FULL| ECHO |    12 |  2484 |   289   (1)| 00:00:04 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("OBJECT_ID"=1000)  ----因为表echo没有创建索引,执行计划没有选择数据访问路径的余地,谓词条件在这里只是起到数据过滤的作用,所以使用了filter。

Note
-----
   - dynamic sampling used for this statement (level=2)

 ----创建索引的情况----
SQL> create index echo_ind on echo(object_id);

Index created.

SQL> select * from echo where object_id=1000;

Execution Plan
----------------------------------------------------------
Plan hash value: 1345159126

----------------------------------------------------------------------------------------
| Id  | Operation            | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT        |           |     1 |   207 |     2     (0)| 00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID| ECHO     |     1 |   207 |     2     (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN        | ECHO_IND |     1 |       |     1     (0)| 00:00:01 |
----------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OBJECT_ID"=1000)  ----谓词条件影响到数据访问的路径,选择了索引,所以用access。

Note
-----
   - dynamic sampling used for this statement (level=2)
Copy after login
以上转自网络

关于access的谓词信息要格外注意,把自己当成优化器,要明白为什么谓词条件会这样影响访问路径。

没有索引就没有选择余地了,那谓词条件一定不会觉得访问路径,那只能是filter的了。对于filter,下面只有一个节点一般仅仅是起到过滤的作用,但是多余两

个节点基本上会涉及到被驱动表可能处于驱动表的循环中,一般可以通过改写sql的方式避免。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!