Boa tarde pessoal,
 
Tenho um banco de dados para o qual é enviado um comando com hint.
A hint está fazendo besteira, o plano de execução fica muito melhor sem ela.
Ao invés de alterar a aplicação direto, gostaríamos de fazer alguns teste antes 
para validar o real ganho no processo. Segundo a Oracle seria possível remover 
a hint utilizando o DBMS_ADVANCED_REWRITE, porém estou tendo dificuldades ao 
utilizar este recurso.
 
Segue um cenário que ilustra o problema que estamos encontrando:
 
Tenho um usuário user1 e uma tabela tabtest;
create table tabtest (num integer, mensag varchar2(10));
 
Tentei então eliminar a hint reescrevendo o plano:
 
SQL> BEGIN
  2  SYS.DBMS_ADVANCED_REWRITE.DECLARE_REWRITE_EQUIVALENCE (
  3  NAME             => 'Teste',
  4  SOURCE_STMT      => 'Select /*+ rule*/ NUM, MENSAG from user1.tabtest 
order by NUM',
  5  DESTINATION_STMT => 'Select NUM, MENSAG from user1.tabtest order by NUM',
  6  VALIDATE         => FALSE,
  7  REWRITE_MODE     => 'TEXT_MATCH');
  8  END;
  9  /
BEGIN
*
ERRO na linha 1:
ORA-30394: source statement identical to the destination statement
ORA-06512: at "SYS.DBMS_ADVANCED_REWRITE", line 29
ORA-06512: at "SYS.DBMS_ADVANCED_REWRITE", line 185
ORA-06512: at line 2
 
Apesar de os comandos não serem idênticos, o Oracle entede que são. Ao tentar 
diferenciá-los (where 1=1) obtenho um outro erro:
 
SQL> BEGIN
  2  SYS.DBMS_ADVANCED_REWRITE.DECLARE_REWRITE_EQUIVALENCE (
  3  NAME             => 'Teste',
  4  SOURCE_STMT      => 'Select /*+ rule*/ NUM, MENSAG from user1.tabtest 
order by NUM',
  5  DESTINATION_STMT => 'Select NUM, MENSAG from user1.tabtest where 1=1 order 
by NUM',
  6  VALIDATE         => FALSE,
  7  REWRITE_MODE     => 'TEXT_MATCH');
  8  END;
  9  /
BEGIN
*
ERRO na linha 1:
ORA-30389: the source statement is not compatible with the destination
statement
ORA-00907: missing right parenthesis
ORA-06512: at "SYS.DBMS_ADVANCED_REWRITE", line 29
ORA-06512: at "SYS.DBMS_ADVANCED_REWRITE", line 185
ORA-06512: at line 2
 
 
Alguém já passou por isso?
Alguma sugestão?
 
 
 
Atenciosamente,
Cláudio Moraes
 
 
 


      

[As partes desta mensagem que não continham texto foram removidas]

Responder a