You are on page 1of 30

oracle

20150513

(Access path)

SQL

ROWID 'AAAGFqAABAAAIWEAAA'

show db_block_size

SELECT ROWID, last_name FROM hr.employees WHERE department_id = 20;

I/O

Table access by index rowid

Oracle

ROWID

Rowid
OOOOOOFFFBBBBBBRRR
OOOOOO data object number, dba_objects.data_object_id

FFF file#, v$datafile.file#


BBBBBB block#

RRR row#

'AAAGFqAABAAAIWEAAA'

select * from SPCT where rowid='AAA0zqAA3AANKdNAAA';

B*

rowid

Full Table
Scans,FTS
partition scan
index full scan
index fast full scan
index range scan
index unique scan
ROWID Table Access by
ROWID

SQL
where
from

cost
cost

ROWID
Rowid

select * from SPCT where rowid='AAA0zqAA3AANKdNAAA';


----------------------------------------------------------------------------------| Id | Operation
|

| Name | Rows | Bytes | Cost (%CPU)| Time

----------------------------------------------------------------------------------|

0 | SELECT STATEMENT

1 | TABLE ACCESS BY USER ROWID| SPCT |

1|
1|

17 |
17 |

(0)| 00:00:01 |
1

(0)| 00:00:01 |

-----------------------------------------------------------------------------------

cost

where

create unique index uni_id_idx on spct(id);

rowid

select * from spct where id=40000;

Execution Plan
---------------------------------------------------------Plan hash value: 1504785184
-------------------------------------------------------------------------------| Id | Operation

| Name

| Rows | Bytes | Cost (%CPU)| Time

-------------------------------------------------------------------------------|

0 | SELECT STATEMENT

1 | TABLE ACCESS BY INDEX ROWID| SPCT

|* 2 |

INDEX UNIQUE SCAN

1|

40 |

(0)|00:00:01 |

1|

40 |

| UNI_ID_IDX |

1|

--------------------------------------------------------------------------------

2
1

(0)|00:00:01 |
(0)|00:00:01 |

index rang scan 3

range > < <> >= <= between

- ( )

order by desc INDEX RANGE SCAN DESCENDING

select id from spct where id<300 ORDER BY id desc ;


299 rows selected.
-----------------------------------------------------------------------------------------| Id | Operation
| Time
|

| Name

| Rows | Bytes | Cost (%CPU)

-----------------------------------------------------------------------------------------| 0 | SELECT STATEMENT


:00:01 |
|* 1 | INDEX RANGE SCAN DESCENDING
:01 |

|
| UNI_ID_IDX |

299 | 1495 |

299 | 1495 |

------------------------------------------------------------------------------------------

2
2

(0)| 00

(0)| 00:00

< >

IO index full scan

db file scattered read

db file sequential read

select name,num from spct where num=1 order by name;


80008 rows selected.
Execution Plan
| Id | Operation

| Name

| Rows | Bytes | Cost (%CPU)| Time

----------------------------------------------------------------------------|

0 | SELECT STATEMENT

|* 1 | INDEX FULL SCAN

| 79542 |

| COMB_IDX | 79542 |

699K|

699K|

283

283

-----------------------------------------------------------------------------

(1)| 00:00:04 |

(1)| 00:00:04 |

Execution Plan
---------------------------------------------------------Plan hash value: 1375286672
----------------------------------------------------------------------------| Id | Operation
| Name
| Rows | Bytes | Cost (%CPU)| Time
|
----------------------------------------------------------------------------| 0 | SELECT STATEMENT |
| 79542 | 699K| 283 (1)| 00:00:04 |
|* 1 | INDEX FULL SCAN | COMB_IDX | 79542 | 699K| 283 (1)| 00:00:04
|
-----------------------------------------------------------------------------

Execution Plan
---------------------------------------------------------Plan hash value: 2527155910
-----------------------------------------------------------------------------------------| Id | Operation
| Name
| Rows | Bytes |TempSpc| Cost (%CPU)| Time
|
-----------------------------------------------------------------------------------------| 0 | SELECT STATEMENT
|
| 79542 | 699K|
| 386 (2)| 00:00:05 |
| 1 | SORT ORDER BY
|
| 79542 | 699K| 1568K| 386 (2)| 00:00:05
|
|* 2 | INDEX FAST FULL SCAN| COMB_IDX | 79542 | 699K|
| 78 (2)|
00:00:01 |
------------------------------------------------------------------------------------------

CONCATENATED INDEXES index join

CREATE INDEX emp_name_ix ON employees (last_name ,first_name )

index join

select /*+INDEX_JOIN(SP NUM_IDX UNI_ID_IDX)*/ name,num from spct sp


where num=1 order by name;

Pstart Pstop

PARTITION RANGE SINGLE

PARTITION RANGE ITERATOR

PARTITION RANGE OR

sql hint

hint sql

select /*+ALL_ROWS*/ num from spct where num<10;

select /*+FIRST_ROWS*/ num from spct where num<10;

select /*+FULL(SP)*/ num from spct sp where num<10;

select /*+ROWID(SP)*/ num from spct sp where num<10 and ROWID>='AAA0zqAA3AANKd


NAAA';

select /*+INDEX(SPCT COMB_IDX)*/ num from spct;

select /*+INDEX_DESC(SPCT NUM_IDX)*/ num from spct where num<50000;

select /*+INDEX_FFS(SPCT NUM_IDX)*/ num from spct where num<99999 and num>9000
0;

stats 500 proc


SQL> select * from stats where name='F' and proc<5000;
500 rows selected.

stats 500000

stats index range scan Cost 34


Cost 3
hint 10 Cost 245

2 F 1000 M
exec :B1:='M';
select render from bias where render=:B1;

sql M
sql shared pool
exec :B1:='F';
select render from bias where render=:B1;
F cost 14

2 Oracle Optimizer Histogram:

Join (Cardinality)

<> !=

OR

IS NULL IS NOT NULL

NOT NULL

CBO


20150513

You might also like