sql >> Database teknologi >  >> RDS >> Oracle

Forespørgselsomskrivning mislykkes, hvis MV bruger ASNI Join

Jeg kan ikke rigtig forklare hvorfor , men jeg lavede en observation, der kan få dig til at omgå problemet.

Her er resultatet af explain_mview for forespørgslen af din MV

exec dbms_mview.explain_mview(q'[select A.y, B.z from A join B on A.x = B.x]');

SELECT capability_name, possible, SUBSTR(related_text,1,8)
AS rel_text, SUBSTR(msgtxt,1,60) AS msgtxt
FROM MV_CAPABILITIES_TABLE
WHERE capability_name   like '%REWRITE%'
ORDER BY seq;

CAPABILITY_NAME                P REL_TEXT MSGTXT                                                      
------------------------------ - -------- ------------------------------------------------------------
REWRITE                        Y                                                                      
REWRITE_FULL_TEXT_MATCH        Y                                                                      
REWRITE_PARTIAL_TEXT_MATCH     Y                                                                      
REWRITE_GENERAL                N          the reason why the capability is disabled has escaped analys
REWRITE_PCT                    N          general rewrite is not possible or PCT is not possible on an

Problemet er IMO i REWRITE_GENERAL = 'N'

Hvis du gentager den samme explain_mview kun ved at bruge POJO (=almindelig gammel deltagelse i Oracle) vil du se et andet resultat.

truncate table mv_capabilities_table;
exec dbms_mview.explain_mview(q'[select A.y, B.z from A, B where A.x = B.x]');

CAPABILITY_NAME                P REL_TEXT MSGTXT                                                      
------------------------------ - -------- ------------------------------------------------------------
REWRITE                        Y                                                                      
REWRITE_FULL_TEXT_MATCH        Y                                                                      
REWRITE_PARTIAL_TEXT_MATCH     Y                                                                      
REWRITE_GENERAL                Y                                                                      
REWRITE_PCT                    N          general rewrite is not possible or PCT is not possible on an
PCT_TABLE_REWRITE              N A        relation is not a partitioned table                         
PCT_TABLE_REWRITE              N B        relation is not a partitioned table

Igen vigtigt `REWRITE_GENERAL ='Y'.

Bemærk, at jeg bruger 18.4 XE, og dette er meget mistænkeligt og bør afklares med Oracle Support.

Den sidste gode nyhed er, hvis du definerer MV med Oracle join , kan du bruge ASNI-joint, og du vil se omskrivningen:

Eksempel

create materialized view MV2 
  enable query rewrite
  as 
  select
    A.y, B.z from A, B where A.x = B.x

EXPLAIN PLAN  SET STATEMENT_ID = 'jara1' into   plan_table  FOR
select   A.y, B.z from A join B on A.x = B.x where y = 'A' and z = 'Z'
;
  
SELECT * FROM table(DBMS_XPLAN.DISPLAY('plan_table', 'jara1','ALL'));

-------------------------------------------------------------------------------------
| Id  | Operation                    | Name | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |      |  3846 | 15384 |   456   (8)| 00:00:01 |
|*  1 |  MAT_VIEW REWRITE ACCESS FULL| MV2  |  3846 | 15384 |   456   (8)| 00:00:01 |
-------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
 
   1 - filter("MV2"."Z"='Z' AND "MV2"."Y"='A')



  1. Tvinge Postgres til at installere med UTF8-kodning, ikke LATIN1?

  2. Android Room:Sådan migreres kolonneomdøbning?

  3. MariaDB navngivne kommandoer

  4. mkdir /mnt/data:skrivebeskyttet filsystem Back-off genstart mislykkedes postgres container