我能够成功创建如下的实例化视图,但是当我查看MV_CAPABILITIES_TABLE时,它告诉我REFRESH_FAST_AFTER_ONETAB_DML和REFRESH_FAST_ANY_DML是不可能的。
CREATE MATERIALIZED VIEW MV_contacts_table
BUILD IMMEDIATE
REFRESH FAST ON COMMIT AS
SELECT t.ID AS ID,
MAX(DECODE(t.FieldName, 'FirstName', t.FieldValue)) FirstName,
MAX(DECODE(t.FieldName, 'LastName', t.FieldValue)) LastName,
COUNT(*) AS NUM_FIELDS FROM Contacts_Table t
WHERE t.FieldName = 'FirstName' OR t.FieldName = 'LastName'
GROUP BY t.ID
这是MV_CAPABILITIES_TABLE
PCT N
REFRESH_COMPLETE Y
REFRESH_FAST Y
REWRITE N
PCT_TABLE N CONTACTS_TABLE 675 2068 relation is not a partitioned table
REFRESH_FAST_AFTER_INSERT Y
REFRESH_FAST_AFTER_ONETAB_DML N 2086 mv uses the MIN or MAX aggregate functions
REFRESH_FAST_AFTER_ANY_DML N 2161 see the reason why REFRESH_FAST_AFTER_ONETAB_DML is disabled
REFRESH_FAST_PCT N 2157 PCT is not possible on any of the detail tables in the materialized view
REWRITE_FULL_TEXT_MATCH N 2159 query rewrite is disabled on the materialized view
REWRITE_PARTIAL_TEXT_MATCH N 2159 query rewrite is disabled on the materialized view
REWRITE_GENERAL N 2159 query rewrite is disabled on the materialized view
REWRITE_PCT N 2158 general rewrite is not possible or PCT is not possible on any of the detail tables
PCT_TABLE_REWRITE N CONTACTS_TABLE 675 2068 relation is not a partitioned table
如果删除where子句,则可以使用REFRESH_FAST_AFTER_ANY_DML。是否有可能可以对该SQL查询进行调整,以使我的实例化视图设置为REFRESH_FAST_AFTER_ANY_DML并包含Where子句?
答案 0 :(得分:0)
这是restriction of materialized views:
删除后可快速刷新具有MAX或MIN的实例化视图 或混合的DML语句如果没有WHERE子句。
删除或混合DML后的最大/最小快速刷新没有 与仅插入情况相同的行为。它删除并重新计算 受影响组的最大值/最小值。您需要知道它的 性能影响。
(重点是我的)。
因此,您需要找到其他方法来实现自己的目标。