SQL> select ename from emp where sal >= 2000;
SQL> select * from emp where sal >= 2000;
포인터란?
- 어떤 곳의 메모리 주소
- 어떤 변수나 함수 등의 주소를 가리키는 개념이다.
- 주소를 저장하는 변수(메모리)를 의미(단, 그 변수가 주소를 가지고 있어야 한다.)
SQL>select count(*) from t;
==========
COUNT(*)
----------
49993
==========
SQL>select count(*) from t where owner like 'SYS%';
==========
COUNT(*)
----------
24707
==========
=========================================================
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE (cr=691 pr=0 pw=0 time=15591 us)
24707 TABLE ACCESS FULL T (cr=691 pr=0 pw=0 time=74159 us)
=========================================================
SQL>select count(*) from where owner like 'SYS%' and object_name = 'ALL_OBJECTS';
==========
count(*)
----------
1
==========
============================================================
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE (cr=691 pr=0 pw=0 time=4676 us)
1 TABLE ACCESS FULL T (cr=691 pr=0 pw=0 time=4654 us)
============================================================
SQL>create index t_idx on t (owner, object_name);
SQL>select /*+ index(t t_idx) */ count(*) from t
where owner like 'SYS%' and object_name = 'ALL_OBJECTS';
==========
count(*)
----------
1
==========
============================================================
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE (cr=77 pr=76 pw=0 time=73964 us)
1 INDEX RANGE SCAN T_IDX (cr=77 pr=76 pw=0 time=73939 us)(object id 54391)
=============================================================
SQL> select /*+ index(t t_idx) */ count(*) from t
where owner like 'SYS%'
and ((owner = 'SYS' and object_name >= 'ALL_OBJECTS' ) or (owner >'SYS'));
==========
count(*)
----------
14641
==========
============================================================
Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE (cr=79 pr=0 pw=0 time=9708 us)
14641 CONCATENATION (cr=79 pr=0 pw=0 time=204995 us)
12905 INDEX RANGE SCAN T_IDX (cr=67 pr=0 pw=0 time=25834 us)(object id 54391)
1736 INDEX RANGE SCAN T_IDX (cr=12 pr=0 pw=0 time=5227 us)(object id 54391)
============================================================
SQL>create index t_idx on t (object_name, owner);
SQL>select /*+ index(t t_idx) */ count(*) from t where owner like 'SYS%' and object_name = 'ALL_OBJECTS';
==========
count(*)
----------
1
==========
============================================================
Rows Row Source Operation
------- ---------------------------------------------------
1 TABLE ACCESS BY INDEX ROWID T (cr=2 pr=0 pw=0 time=32 us)
1 INDEX RANGE SCAN T_IDX (cr=2 pr=0 pw=0 time=21 us)(object id 54393)
============================================================
SQL> create index t_idx on t(owner);
SQL> select object_id from t where owner ='SYS' and object_name = 'ALL_OBJECTS';
==========
OBJECT_ID
----------
2377
==========
============================================================
Rows Row Source Operation
------- ---------------------------------------------------
1 TABLE ACCESS BY INDEX ROWID T (cr=739 pr=0 pw=0 time=39522 us)
22934 INDEX RANGE SCAN T_IDX (cr=51 pr=0 pw=0 time=12072 us)(object id 54404)
============================================================
SQL>create index t_idx on t(owner, object_name);
SQL>select object_id from t where owner ='SYS' and object_name = 'ALL_OBJECTS';
==========
OBJECT_ID
----------
2377
==========
======================================================================
Rows Row Source Operation
------- ---------------------------------------------------
1 TABLE ACCESS BY INDEX ROWID T (cr=4 pr=0 pw=0 time=57 us)
1 INDEX RANGE SCAN T_IDX (cr=3 pr=0 pw=0 time=49 us)(object id 54404)
======================================================================