执行计划和临时表 [英] Execution plans and temporary tables

查看:95
本文介绍了执行计划和临时表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有建议的方法来获取涉及

全局临时表(来自UNIX命令行或脚本)的查询的执行计划?


我在Perl脚本中运行查询,并且我想到的唯一方法

正在创建看起来像临时表的永久表并运行测试

版本的脚本使用永久表;然后我可以让

脚本在任何我想要的地方停止并启动db2expln。


但这种方式看起来有点麻烦且容易出错。


Joachim

解决方案

Joachim Pense写道:

是否有推荐的获取方法涉及全局临时表(来自UNIX命令行或脚本)的查询的执行计划?

我在Perl脚本中运行查询,这是我想到的唯一方法
正在创建看起来像临时表的永久表,并运行使用永久表的脚本的测试版本;然后我可以让
脚本停在我想要的地方并启动db2expln。



类型db2expln -help

检查-setup选项


干杯

Serge


PS:我已联系店主询问为何该选项不在文档中。< br $>
-

Serge Rielau

DB2解决方案开发

IBM多伦多实验室


Am Sun,2006年4月23日07:40:52 -0400 schrieb Serge Rielau:

Joachim Pense写道:

是否有推荐获取涉及全局临时表(来自UNIX命令行或脚本)的查询的执行计划的方法?

我在Perl脚本中运行查询,这是唯一的方法在我看来
正在创建看起来像临时表的永久表,并运行使用永久表的脚本的测试版本;然后我可以让
脚本停在我想要的地方并启动db2expln。


输入db2expln -help
检查-setup选项



我没有找到-setup选项。


Joachim


Joachim Pense写道:

我没有找到-setup选项。

Joachim



D:\ Workinging> db2expln - 帮助


DB2通用数据库版本8.1,5622-044(c)版权所有IBM Corp. 1991,2002

许可材料 - IBM的程序属性
IBM DB2通用数据库SQL说明工具

SQL说明描述了存储在DB2中的包中的静态SQL语句的访问计划选择

通用数据库系统目录。

给定数据库名称,包名称,包创建者和节号,

SQL Explain将解释和描述这些目录中的信息。 / >

语法为:


.-----------。

V |

- db2expln ----< option> - + - ><




其中< option>和<参数>取自下面的列表。每个<选项>

可能只出现一次,并且可以按任何顺序指定。

连接选项:

-database<分贝> =连接到名为< db>的数据库。

-d< db>


-user< name> < PW> =以用户身份连接< name>密码< pw> ;.

-u< name> < pw>


必须指定数据库名称。

输出选项:

-terminal =将输出发送到终端。

-t


-output< file> =将输出写入名为< file>的文件。

-o< file>


必须指定终端或文件输出。

帮助选项:

-help =显示此帮助文本。

-h

- ?

套餐选项:

-schema< pattern> =包创建者必须匹配< pattern> ;.

-c< pattern>


-package< pattern> =包名必须与< pattern>匹配。

-p< pattern>


-version< pattern> =包版本必须与< pattern>匹配。如果没有指定

,那么将解释版本为'''

(空字符串)的包。


-section< number> =部分编号是< number>。使用0(零)

-s< number>包中的所有部分。


-escape< charater> =使用< character>作为转义字符时

-e< character>匹配模式。


-noupper =不要大写创建者,包和版本

-l匹配之前。


除非动态SQL被解释为
,否则必须指定创建者和包信息。如果未指定部分信息,则将显示所有

部分。


< pattern>对于创建者,包和版本是LIKE谓词形式,

允许百分号(%)和下划线(_)作为模式匹配

字符。这允许使用db2expln的一个
调用来解释多个包。转义字符可用于强制按字面意思处理%

和_字符。 (有关LIKE谓词的更多信息,请参阅SQL参考。)如果可以匹配多个包,

则节号自动设置为0(所有节)。

动态报表选项:

-statement< statement> =动态语句< statement>将是

-q< sql>解释。


-stmtfile< file> =文件中包含的动态语句

-f< file> <文件>将被解释。 <文件>必须存在于客户端的



-noenv =默认情况下,db2expln会调用每个动态SET

语句后有人解释说。这个选项

阻止执行这些语句。

解释选项:

-setup< file> =< file>中的SQL语句将在解释任何部分或陈述之前调用



< file>中的SQL语句不会被解释为
。报告设置脚本中的错误

但忽略。


-terminator< character> = -statement和-setup的每个SQL语句结束

-z< character> at< character>。如果未指定此选项,

则假定每个语句为一行

长。


-graph =重建原始优化器计划图(由Visual Explain提供的
-g)。请注意,

重建图可能与

原始计划不完全匹配。


-opids =显示运营商ID号。

-i

可用的具体选项可能因数据库服务器而异。

使用db2expln -help -database< db>获取

a特定服务器的选项。

(2 / - )


D:\ Workinging> db2level

DB21085I实例DB2使用32表示32。位和DB2代码版本SQL08024

级别标识符" 03050106" ;.

信息令牌是DB2 v8.1.11.973,s060120,WR21365和FixPak

" 11"。

产品安装在D:\ SQLLIB中。

Jan M. Nelken


Is there recommended way to get the execution plan for queries involving
global temporary tables (from the UNIX command line or within a script)?

I run the queries in Perl scripts, and the only way that comes to my mind
is creating permanent tables that look like the temporary ones and run test
versions of the scripts that use the permanent tables; then I can let the
script stop wherever I want and start db2expln.

But this way looks a bit cumbersome and error-prone to me.

Joachim

解决方案

Joachim Pense wrote:

Is there recommended way to get the execution plan for queries involving
global temporary tables (from the UNIX command line or within a script)?

I run the queries in Perl scripts, and the only way that comes to my mind
is creating permanent tables that look like the temporary ones and run test
versions of the scripts that use the permanent tables; then I can let the
script stop wherever I want and start db2expln.


Type db2expln -help
Check the -setup option

Cheers
Serge

PS: I have contacted the owner to inquire why the option is not in the docs.
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


Am Sun, 23 Apr 2006 07:40:52 -0400 schrieb Serge Rielau:

Joachim Pense wrote:

Is there recommended way to get the execution plan for queries involving
global temporary tables (from the UNIX command line or within a script)?

I run the queries in Perl scripts, and the only way that comes to my mind
is creating permanent tables that look like the temporary ones and run test
versions of the scripts that use the permanent tables; then I can let the
script stop wherever I want and start db2expln.


Type db2expln -help
Check the -setup option



I didn''t find a -setup option.

Joachim


Joachim Pense wrote:

I didn''t find a -setup option.

Joachim


D:\Working>db2expln -help

DB2 Universal Database Version 8.1, 5622-044 (c) Copyright IBM Corp. 1991, 2002
Licensed Material - Program Property of IBM
IBM DB2 Universal Database SQL Explain Tool

SQL Explain describes the access plan selection for static SQL statements
in the packages stored in the DB2 Universal Database system catalogs.
Given a database name, package name, package creator, and section number,
SQL Explain will interpret and describe the information in these catalogs.

The syntax is:

.-----------.
V |

--db2expln----<option>--+--><



where <option> and <parameter> are taken from the list below. Each <option>
may appear only once, and they may be specified in any order.
Connection Options:
-database <db> = Connect to the database named <db>.
-d <db>

-user <name> <pw> = Connect as user <name> with password <pw>.
-u <name> <pw>

A database name must be specified.
Output Options:
-terminal = Send output to the terminal.
-t

-output <file> = Write output to the file named <file>.
-o <file>

Either terminal or file output must be specified.
Help Options:
-help = Display this help text.
-h
-?
Package Options:
-schema <pattern> = The package creator must match <pattern>.
-c <pattern>

-package <pattern> = The package name must match <pattern>.
-p <pattern>

-version <pattern> = The package version must match <pattern>. If not
specified, then the package with the version ''''
(the empty string) will be explained.

-section <number> = The section number is <number>. Use 0 (zero) for
-s <number> all sections in the package.

-escape <charater> = Use <character> as the escape character when
-e <character> matching patterns.

-noupper = Do not upper case creator, package and version
-l before matching.

The creator and package information must be specified unless dynamic SQL is
being explained. If the section information is not specified, then all
sections will be displayed.

The <pattern> for creator, package, and version is in LIKE predicate form,
which allows the percent sign (%) and underscore (_) as pattern matching
characters. This allows multiple packages to be explained with one
invocation of db2expln. The escape character can be used to force the %
and _ characters to be treated literally. (See the SQL Reference for more
information on the LIKE predicate.) If multiple packages may be matched,
the section number is automatically set to 0 (all sections).
Dynamic Statement Options:
-statement <statement> = The dynamic statement <statement> will be
-q <sql> explained.

-stmtfile <file> = The dynamic statements contained in the file
-f <file> <file> will be explained. <File> must exist at
the client.

-noenv = By default, db2expln will invoke each dynamic SET
statement after it has been explained. This option
prevents the execution of these statements.
Explain Options:
-setup <file> = The SQL statements in <file> will be invoked
before any sections or statements are explained.
The SQL statements in <file> will not be
explained. Errors in the setup script are reported
but ignored.

-terminator <character> = Each SQL statement for -statement and -setup ends
-z <character> at <character>. If this option is not specified,
then each statement is assumed to be one line
long.

-graph = Reconstruct the original optimizer plan graph (as
-g presented by Visual Explain). Note that the
reconstructed graph may not exactly match the
original plan.

-opids = Show the operator ID numbers.
-i
The specific options available may vary by database server.
Use "db2expln -help -database <db>" to get the options available for
a specific server.
(2/-)

D:\Working>db2level
DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL08024" with
level identifier "03050106".
Informational tokens are "DB2 v8.1.11.973", "s060120", "WR21365", and FixPak
"11".
Product is installed at "D:\SQLLIB".
Jan M. Nelken


这篇关于执行计划和临时表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆