Est-ce que le résultat d’une requête dépend de son plan d’exécution ?
Bien sûr que non! :lol:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
Connecté à :
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set linesize 132
SQL> create index hr.emp_hire_date on hr.employees(hire_date)
/
Index créé.
SQL> set autotrace on
SQL> Select
employee_id,
first_name,
salary
From (
Select employee_id,
first_name,
salary,
hire_date
from hr.employees
order by hire_date desc
)
where rownum = 1
/
EMPLOYEE_ID FIRST_NAME SALARY
----------- -------------------- ----------
173 Sundita 6100
Plan d'exécution
----------------------------------------------------------
Plan hash value: 3645119196
-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 38 | 2 (0)| 00:00:01 |
|* 1 | COUNT STOPKEY | | | | | |
| 2 | VIEW | | 1 | 38 | 2 (0)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID| EMPLOYEES | 107 | 2461 | 2 (0)| 00:00:01 |
| 4 | INDEX FULL SCAN DESCENDING| EMP_HIRE_DATE | 1 | | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(ROWNUM=1) |
C'est Sundita!
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
Select --+ ALL_ROWS
employee_id,
first_name,
salary
From (
Select employee_id,
first_name,
salary,
hire_date
from hr.employees
order by hire_date desc
)
where rownum = 1
/
EMPLOYEE_ID FIRST_NAME SALARY
----------- -------------------- ----------
167 Amit 6200
Plan d'exécution
----------------------------------------------------------
Plan hash value: 3819624196
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 38 | 4 (25)| 00:00:01 |
|* 1 | COUNT STOPKEY | | | | | |
| 2 | VIEW | | 107 | 4066 | 4 (25)| 00:00:01 |
|* 3 | SORT ORDER BY STOPKEY| | 107 | 2461 | 4 (25)| 00:00:01 |
| 4 | TABLE ACCESS FULL | EMPLOYEES | 107 | 2461 | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(ROWNUM=1)
3 - filter(ROWNUM=1) |
Non c'est Amit!
Non c’est Sundita !
Non c’est Amit !