我想要这样的输出:
obid | sid_count
1 | 3
2 | 2
3 | 4
obid 位于 custdata 表上,sid_count 来自标识符表。
样本数据为:
custdata
obid
1
2
3
identifier
obid | type
1 | SID
1 | SID
1 | XID
1 | SID
2 | SID
2 | SID
3 | SID
3 | SID
3 | XID
3 | SID
3 | SID
我尝试运行此查询:
select custdata.obid,
count (identifier.obid) filter (where identifier.type = 'SID') as sid_count
from myschema.custdata, myschema.identifier group by custdata.obid
花了大约一个小时,但出现错误:
[53100] ERROR: could not write block 37583345 of temporary file: No space left on device
custdata 大约有 6500 万条记录。标识符大约有 2.5 亿条记录。
如何克服这个问题?为什么数据库需要写入磁盘?还是我需要重写我的查询?因为我无法向磁盘添加更多空间。
谢谢。