Ticker

6/recent/ticker-posts

Corrigindo o erro ‘PLAN_TABLE’ is old version


Quando é executado um explain e o mesmo utiliza uma PLAN_TABLE com uma versão inferior a versão do Oracle, é apresentada a mensagem “PLAN_TABLE” is old version e o resultado do explain pode, em alguns casos não apresentar a informação do tempo de execução do comando .
O problema de ‘PLAN_TABLE’ is old version  ocorre geralmente após o processo de upgrade da base onde o produto foi atualizado, porém o usuário ainda está usando uma versão antiga do PLAN_TABLE.
O primeiro passo que estarei realizando é a simulação do erro:
conn scott/tiger@teste</pre>
SQL> explain plan for
 2 select sysdate from dual;
Explained.
SQL> /
Explained.
SQL> set lines 190
set pages 50
select * from table(dbms_xplan.display);SQL> SQL>
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 1388734953
-----------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
| 1 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
-----------------------------------------------------------------
- 'PLAN_TABLE' is old version
Para resolver este problema é necessário identificar todas as tabelas PLAN_TABLE, remove-las e executar o script catplan.sql para recriar a PLAN_TABLE.
select owner, object_type, object_name
from all_objects
where
object_name like 'PLAN_TABLE%';
OWNER                          OBJECT_TYPE         OBJECT_NAME
------------------------------ ------------------- -----------
SYS                             TABLE              PLAN_TABLE$
PUBLIC                         SYNONYM             PLAN_TABLE
SCOTT                           TABLE              PLAN_TABLE
connect sys as sysdba
drop table plan_table$;
table dropped.
drop table SCOTT.PLAN_TABLE;
table dropped.
SQL> @?/rdbms/admin/catplan
create type dbms_xplan_type
 *
ERROR at line 1:
ORA-00955: name is already used by an existing object
create type dbms_xplan_type_table
 *
ERROR at line 1:
ORA-00955: name is already used by an existing object
Grant succeeded.
Grant succeeded.
create type sql_plan_row_type
 *
ERROR at line 1:
ORA-00955: name is already used by an existing object
Synonym created.
Grant succeeded.
create type sql_plan_table_type
 *
ERROR at line 1:
ORA-00955: name is already used by an existing object
Synonym created.
Grant succeeded.
create sequence ora_plan_id_seq$
 *
ERROR at line 1:
ORA-00955: name is already used by an existing object
drop table plan_table$
 *
ERROR at line 1:
ORA-00942: table or view does not exist
Table created.
Grant succeeded.
Synonym created.
create type sql_plan_stat_row_type
 *
ERROR at line 1:
ORA-00955: name is already used by an existing object
Synonym created.
Grant succeeded.
create type sql_plan_allstat_row_type
 *
ERROR at line 1:
ORA-00955: name is already used by an existing object
Synonym created.
Grant succeeded.
SQL>
Os erros que ocorreram na execução acima, podem ser desconsiderados pois estão relacionados a tentativa de criação de objetos já existentes na base.
Agora irei realizar um novo explain para mostrar que o erro não ocorre novamente.
conn scott/tiger@teste
SQL> explain plan for
 2 select sysdate from dual;
Explained.
SQL> /
Explained.
SQL> set lines 190
set pages 50
select * from table(dbms_xplan.display);SQL> SQL>
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 1388734953
-----------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
| 1 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
-----------------------------------------------------------------
8 rows selected.
É importante destacar, que este processo precisa ser realizado com cada usuário que será usado para gerar o explain**.

Referência: ‘PLAN_TABLE Is Old Version’ Message When Running EXPLAIN PLAN For Query (Doc ID 758702.1)

Postar um comentário

0 Comentários