嗨,我有这个 postgresql 代码,我想优化它以使用更少的临时磁盘空间:
SELECT l1.name, l2.name
FROM label l1 INNER JOIN label l2 ON l1.id > l2.id INNER JOIN
label l3 ON l1.id <> l3.id AND l2.id <> l3.id
WHERE NOT EXISTS (SELECT * FROM release_label rl1 INNER JOIN release_label rl2 ON rl1.release = rl2.release WHERE rl1.label = l1.id AND rl2.label = l2.id) AND
EXISTS (SELECT * FROM release_label rl1 INNER JOIN release_label rl3 ON rl1.release = rl3.release WHERE rl1.label = l1.id AND rl3.label = l3.id) AND
EXISTS (SELECT * FROM release_label rl2 INNER JOIN release_label rl3 ON rl2.release = rl3.release WHERE rl2.label = l2.id AND rl3.label = l3.id)`
我使用的数据库是 musicbrainz 但它给了我这个错误:
“无法写入临时文件的块 1973434:设备上没有剩余空间”
我有一个简化版的 musicbrainz 数据库,它的行数更少,而且运行良好,请帮我找到优化此代码的方法,干杯