Vous êtes sur la page 1sur 8

Royaume du Maroc Université IBN TOFAIL

Ministère de l'Education Nationale, Licence professionnelle


de l'Enseignement Supérieur, de la Formation Administration des bases de données
des Cadres et de la Recherche Scientifique PR. A. ALLA

CREATION DES PLANS ABSTRAITS : SCRIPT

set showplan on
go
use pubs2
go
select au_id, title, pubdate from titles t, titleauthor ta
where t.title_id = ta.title_id and price>10
go

QUERY PLAN FOR STATEMENT 1 (at line 1).

STEP 1
The type of query is SELECT.

FROM TABLE
titles
t
Nested iteration.
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.

FROM TABLE
titleauthor
ta
Nested iteration.
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.
(19 rows affected)
Royaume du Maroc Université IBN TOFAIL
Ministère de l'Education Nationale, Licence professionnelle
de l'Enseignement Supérieur, de la Formation Administration des bases de données
des Cadres et de la Recherche Scientifique PR. A. ALLA

set showplan off


go
set plan dump on /* Activation de la creation des PA*/
go
select au_id, title, pubdate from titles t, titleauthor ta
where t.title_id = ta.title_id and price>10
go

sp_find_qplan "%from titles%" /* Recherche de l’ID du PA créé */

gid id text
----------- ----------- ----
2 656002337 select au_id, ...............

sp_help_qplan 656002337, full /* Affiche les informations complètes sur le PA */

gid hashkey id
----------- ----------- -----------
2 309011764 656002337

query
-----
select au_id, title, pubdate from titles t, titleauthor ta where t.title_id = ta.title_id
and price>10

plan
----
( nl_g_join
( t_scan ( table ( t titles ) ) )
( t_scan ( table ( ta titleauthor ) ) )
)
( prop ( table ( ta titleauthor ) )
( parallel 1 )
( prefetch 2 )
( lru )
)
( prop ( table ( t titles ) )
( parallel 1 )
( prefetch 2 )
( lru )
)
Royaume du Maroc Université IBN TOFAIL
Ministère de l'Education Nationale, Licence professionnelle
de l'Enseignement Supérieur, de la Formation Administration des bases de données
des Cadres et de la Recherche Scientifique PR. A. ALLA

set plan dump off /* Désactive la creation des PA */


go

set plan load ap_stdout on /* Activation de l’utilisation des PA depuis le groupe


ap_sdout explicitement */
go

set showplan on
go
select au_id, title, pubdate from titles t, titleauthor ta
where t.title_id = ta.title_id and price>10
go

QUERY PLAN FOR STATEMENT 1 (at line 1).


Optimized using an Abstract Plan (ID : 656002337).

STEP 1
The type of query is SELECT.

FROM TABLE
titles
t
Nested iteration.
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.

FROM TABLE
titleauthor
ta
Nested iteration.
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.

(19 rows affected)


Royaume du Maroc Université IBN TOFAIL
Ministère de l'Education Nationale, Licence professionnelle
de l'Enseignement Supérieur, de la Formation Administration des bases de données
des Cadres et de la Recherche Scientifique PR. A. ALLA

CHANGEMENT DU PLAN ABSTRAIT

set showplan off


go

sp_set_qplan 656002337, "(nl_g_join (t_scan (table (t titles)))(t_scan (table (ta


titleauthor))))(prop (table (ta titleauthor))(parallel 1)(prefetch 2)(mru))(prop
(table(t titles))(parallel 1)(prefetch 2)(mru))" /* Change le PA de la requite ayant
l’ID 656...*/
go
sp_help_qplan 656002337,full
go
gid hashkey id
----------- ----------- -----------
2 309011764 656002337

query
-----
select au_id, title, pubdate from titles t, titleauthor ta where t.title_id = ta.title_id
and price>10

plan
----
(nl_g_join (t_scan (table (t titles)))(t_scan (table (ta titleauthor))))(prop (table (ta
titleauthor))(parallel 1)(prefetch 2)(mru))(prop (table(t titles))(parallel 1)(prefetch
2)(mru))
Royaume du Maroc Université IBN TOFAIL
Ministère de l'Education Nationale, Licence professionnelle
de l'Enseignement Supérieur, de la Formation Administration des bases de données
des Cadres et de la Recherche Scientifique PR. A. ALLA

set showplan on
go
select au_id, title, pubdate from titles t, titleauthor ta
where t.title_id = ta.title_id and price>10
go

QUERY PLAN FOR STATEMENT 1 (at line 1).


Optimized using an Abstract Plan (ID : 656002337).

STEP 1
The type of query is SELECT.

FROM TABLE
titles
t
Nested iteration.
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With MRU Buffer Replacement Strategy for data pages.

FROM TABLE
titleauthor
ta
Nested iteration.
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With MRU Buffer Replacement Strategy for data pages.

(19 rows affected)


Royaume du Maroc Université IBN TOFAIL
Ministère de l'Education Nationale, Licence professionnelle
de l'Enseignement Supérieur, de la Formation Administration des bases de données
des Cadres et de la Recherche Scientifique PR. A. ALLA

set showplan,noexec off


go

sp_set_qplan 656002337, "(m_g_join (t_scan (table (t titles)))(t_scan (table (ta


titleauthor))))"
go
sp_help_qplan 656002337,full
go

gid hashkey id
----------- ----------- -----------
2 309011764 656002337

query
-----
select au_id, title, pubdate from titles t, titleauthor ta where t.title_id = ta.title_id
and price>10

plan
----
(m_g_join (t_scan (table (t titles)))(t_scan (table (ta titleauthor))))

set sort_merge on /* Active le MERGE JOIN */


go
set showplan,noexec on
go
select au_id, title, pubdate from titles t, titleauthor ta
where t.title_id = ta.title_id and price>10
go

QUERY PLAN FOR STATEMENT 1 (at line 1).


Optimized using an Abstract Plan (ID : 656002337).

STEP 1
The type of query is INSERT.
The update mode is direct.

FROM TABLE
titles
t
Nested iteration.
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.
TO TABLE
Worktable1.
Royaume du Maroc Université IBN TOFAIL
Ministère de l'Education Nationale, Licence professionnelle
de l'Enseignement Supérieur, de la Formation Administration des bases de données
des Cadres et de la Recherche Scientifique PR. A. ALLA

Worktable1 created for sort merge join.

STEP 2
The type of query is INSERT.
The update mode is direct.

FROM TABLE
titleauthor
ta
Nested iteration.
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.
TO TABLE
Worktable2.
Worktable2 created for sort merge join.

STEP 3
The type of query is SELECT.

FROM TABLE
Worktable1.
Merge join (outer table).
Serial data merge.
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.

FROM TABLE
Worktable2.
Merge join (inner table).
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.
Royaume du Maroc Université IBN TOFAIL
Ministère de l'Education Nationale, Licence professionnelle
de l'Enseignement Supérieur, de la Formation Administration des bases de données
des Cadres et de la Recherche Scientifique PR. A. ALLA

AUTRE METHODE D’UTILISATION

select au_id, title, pubdate from titles t, titleauthor ta


where t.title_id = ta.title_id and price>10
plan "(m_g_join (scan titles) (scan titleauthor))"
go

QUERY PLAN FOR STATEMENT 1 (at line 1).


Optimized using the Abstract Plan in the PLAN clause.

STEP 1
The type of query is INSERT.
The update mode is direct.

FROM TABLE
titleauthor
ta
Nested iteration.
Table Scan.
Forward scan.
Positioning at start of table.
Using I/O Size 2 Kbytes for data pages.
With LRU Buffer Replacement Strategy for data pages.
TO TABLE
Worktable1.
Worktable1 created for sort merge join.

...
...
...
...
...
...