求助:系统临时表空间的指定

[复制链接]
查看11 | 回复9 | 2007-7-25 04:01:02 | 显示全部楼层 |阅读模式
在使用with temp(a,b)as (select a,b from AAA union select t1.a,t2.b from AAA t1,temp t2 where t1.a=t2.b)进行递归的时候,产生了系统临时表空间不足的错误提示:[IBM][CLI Driver][DB2/6000] SQL1585N不存在具有足够页大小的系统临时表空间。SQLSTATE=54048
使用的是V8,
目前两个bufferpool,buff1为pagesize 4k,npages 1000,buff2为 pagesize 8k,npages 20000
两个系统临时表空间:tempsapce1 ,pagesize 4096,使用buff1
tempspace2 ,pagesiaze 8192,使用buff2
问题:我现在不知道temp表使用的是哪个表空间,我应该怎么确定目前temp使用的表空间?
目前temp的结果应该是200条记录,每条记录的大小不超过200个字符,我查了一些文档,说当表空间使用的pagesize为4k时,支持每行4005个字符,所以,出错的原因不可能是因为超行限,列数限制是500,我只有两列,也不可能超列限,那么唯一出错的可能就是最终结果的大小(200行*200字符 = 40000)超过了临时表空间的大小了。通过使用SNAPSHOT_TBS_CFG,我查到tempspace1的total_pages=1,肯定是不够的,tempspace2的total_pages=97950,肯定够用。那么我有两个方法来解决,第一,扩展tempspace1的页数量,第二,生成temp表的时候指定使用tempspace2。
问题:1、如果使用第一个方法,我应该怎么扩展tempspace1的大小?扩展了之后会对数据库性能之类的造成什么影响?
2、如果使用第二种方法,怎么才能指定使用的系统临时表空间?查了无数手头能看到的东东,就是没找到啊

请老大们赐教一下,谢谢啦
回复

使用道具 举报

千问 | 2007-7-25 04:01:02 | 显示全部楼层
把整个的SQL贴出来看看吧。
回复

使用道具 举报

千问 | 2007-7-25 04:01:02 | 显示全部楼层
--字段类型
--id
varchar(30)
--id4
varchar(30)
--id3
varchar(30)
--id2
varchar(30)
--id1
varchar(30)
--tsx
dec(10,0)
--bblb
dec(2,0)
--ywlb
dec(2,0)
--cc
int
with tmp (id,id4,id3,id2,id1,tsx,bblb,ywlb,cc) as (
select id,sjid,space(30),space(30),space(30),tsx,bblb,ywlb,1
from table_1
where sjid is null
union all
select t1.id,t1.sjid,t2.id4,t2.id3,t2.id2,t1.tsx,t1.bblb,t1.ywlb,t2.cc+1
from table_1 t1
,tmp t2
where t1.sjid = t2.id
)
selectid

,id4

,id3

,id2

,id1

,tsx

,bblb

,ywlb

,cc
from tmp
;
回复

使用道具 举报

千问 | 2007-7-25 04:01:02 | 显示全部楼层
我把space(30)改成'
'(30个空格),这个sql就又不报错了,真是奇怪啊,谁给解释一下啊,谢啦
回复

使用道具 举报

千问 | 2007-7-25 04:01:02 | 显示全部楼层
Returns a character string consisting of blanks with length specified by the second argument.
The argument can be SMALLINT or INTEGER.
The result of the function is VARCHAR(4000). The result can be null; if the argument is null, the result is the null value.
VARCHAR(4000)
回复

使用道具 举报

千问 | 2007-7-25 04:01:02 | 显示全部楼层
最初由 askgyliu 发布
[B]Returns a character string consisting of blanks with length specified by the second argument.
The argument can be SMALLINT or INTEGER.
The result of the function is VARCHAR(4000). The result can be null; if the argument is null, the result is the null value.
VARCHAR(4000) [/B]

不好意思,我没看太明白,您能不能简单的用汉语解释一下?
我测了一下length(space(30)),返回是30啊
回复

使用道具 举报

千问 | 2007-7-25 04:01:02 | 显示全部楼层
Space(参数)会返回一个空格STRING,而STRING的空格数目是由第二个参数决定的。
参数可以是SMALLINT,或是INTEGER。
结果会是VARCHAR(4000)。结果可能是NULL,如果参数是NULL的话。
回复

使用道具 举报

千问 | 2007-7-25 04:01:02 | 显示全部楼层
试试下面的两个QUERIES。
with tt as(
select char(space(1),1) as f1, char(space(1),1) as f2 from sysibm.sysdummy1)
select a.f1, a.f2, b.f1, b.f2, length(space(1))
from tt a, tt b
;
with tt as(
select space(1) as f1 from sysibm.sysdummy1)
select a.f1, length(a.f1)
from tt a, tt b
;
象SPACE这种函数,返回值若是用在SORTING的话,内部空间都是VARCHAR(4000)。所以你多放几个SPACE(30)就不可以了。
真的需要用到的话,加个限制吧,CHAR(SPACE(30))。
回复

使用道具 举报

千问 | 2007-7-25 04:01:02 | 显示全部楼层
1. the optimizer chooses the temporary tablespace with larger bp size (in your case tmp2).
2. The size you got with snapshot is the actual allocation size, you can see tmp2 oversized.
回复

使用道具 举报

千问 | 2007-7-25 04:01:02 | 显示全部楼层
最初由 askgyliu 发布
[B]试试下面的两个QUERIES。
with tt as(
select char(space(1),1) as f1, char(space(1),1) as f2 from sysibm.sysdummy1)
select a.f1, a.f2, b.f1, b.f2, length(space(1))
from tt a, tt b
;
with tt as(
select space(1) as f1 from sysibm.sysdummy1)
select a.f1, length(a.f1)
from tt a, tt b
;
象SPACE这种函数,返回值若是用在SORTING的话,内部空间都是VARCHAR(4000)。所以你多放几个SPACE(30)就不可以了。
真的需要用到的话,加个限制吧,CHAR(SPACE(30))。 [/B]

明白啦,谢谢老大
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行