Oracle物化视图调优

发布于 2024-07-15 13:24:25 字数 1519 浏览 8 评论 0原文

我正在尝试在我的应用程序中对物化视图进行调整。 我开始执行:

 dbms_advisor.tune_mview()

过程,并将以下代码写入 Oracle SQL Developer 的 SQL_Worksheet 中:

variable mvtask varchar2(100); 
variable mvddl varchar2(4000);

execute :mvtask := 'MV_FOO_BAR';
execute select query into :mvddl from user_mviews where view_name = 'MV_FOO_BAR';

execute dbms_advisor.tune_mview(:mvtask, :mvddl);

select * from user_tune_mview;

显然,物化视图已经创建(提交时刷新速度很快,但是运行速度慢得令人无法接受) 。 Advisor 报告以下错误:

Error report:
ORA-13600: error encountered in Advisor
QSM-03112: Invalid CREATE MATERIALIZED VIEW statement
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.PRVT_ACCESS_ADVISOR", line 202
ORA-06512: at "SYS.PRVT_TUNE_MVIEW", line 1026
ORA-06512: at "SYS.DBMS_ADVISOR", line 754
ORA-06512: at line 1
13600. 00000 -  "error encountered in Advisor\n%s"
*Cause:    An error occurred in the Advisor.
           This message will be followed by a second message giving
           more details about the nature of the error.
*Action:   See the Advisor documentation
           for an explanation of the second error message.

但是,没有再报告任何内容,也没有第二条错误消息的踪迹。 有谁知道这里有什么问题吗? 更让我惊讶的是,MV 已经存在并且可以在数据库中运行,尽管速度很慢。

相关说明,有谁知道如何在 SQL Developer 中输入多行字符串。 当我尝试类似以下内容时:

execute :mvddl :='create materialized view MV_FOO_BAR
build immediate
refresh fast on commit
...
';

SQL Developer 在第一行就卡住了。 我曾想过字符串连接,但我有几个 100-150 行的 MV,我讨厌为每一个手动操作。

I am trying to perform tuning of materialized views in my application. I set out to execute:

 dbms_advisor.tune_mview()

procedure, and wrote the following code into an SQL_Worksheet of Oracle SQL Developer:

variable mvtask varchar2(100); 
variable mvddl varchar2(4000);

execute :mvtask := 'MV_FOO_BAR';
execute select query into :mvddl from user_mviews where view_name = 'MV_FOO_BAR';

execute dbms_advisor.tune_mview(:mvtask, :mvddl);

select * from user_tune_mview;

Obviously, materialized view is already created (with refresh fast on commmit, which, however, runs unacceptably slow). Advisor reports a following error:

Error report:
ORA-13600: error encountered in Advisor
QSM-03112: Invalid CREATE MATERIALIZED VIEW statement
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.PRVT_ACCESS_ADVISOR", line 202
ORA-06512: at "SYS.PRVT_TUNE_MVIEW", line 1026
ORA-06512: at "SYS.DBMS_ADVISOR", line 754
ORA-06512: at line 1
13600. 00000 -  "error encountered in Advisor\n%s"
*Cause:    An error occurred in the Advisor.
           This message will be followed by a second message giving
           more details about the nature of the error.
*Action:   See the Advisor documentation
           for an explanation of the second error message.

But, there is nothing more reported, no trace of the second error message. Does anyone know what's the issue here? I'm all the more surprised since the MV already exists and works in the database, albeit slowly.

On a related note, does anyone know how to enter a multi-line string in SQL Developer. When I try something like:

execute :mvddl :='create materialized view MV_FOO_BAR
build immediate
refresh fast on commit
...
';

SQL Developer chokes on the first line. String concatenation crossed my mind, but I have several MVs of 100-150 lines and I would hate doing it manually for each one of them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沙与沫 2024-07-22 13:24:25

(1) 当错误 13600 的文本引用“第二个错误消息”时,它表示堆栈中的下一个错误 - 在本例中为 QSM-03112。

(2) 我认为,错误的原因是调用 TUNE_MVIEW 中的第二个参数应该是 CREATE MATERIALIZED VIEW 语句的全文,但您只传递查询文本。

(3) 对于多行问题,我希望如果您使用显式 PL/SQL 匿名块而不是“执行”,它会起作用,例如:

BEGIN
  :mvddl := 'create materialized view MV_FOO_BAR
             build immediate
             refresh fast on commit
             ...
            ';
END;
/

(1) When the text for error 13600 refers to the "second error message", it means the next error in the stack -- in this case QSM-03112.

(2) The reason for the error, I believe, is that the second parameter in the call to TUNE_MVIEW is meant to be the full text of a CREATE MATERIALIZED VIEW statement, but you are passing just the query text.

(3) For the multi-line issue, I expect it will work if you use an explicit PL/SQL anonymous block instead of "execute", e.g.:

BEGIN
  :mvddl := 'create materialized view MV_FOO_BAR
             build immediate
             refresh fast on commit
             ...
            ';
END;
/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文