超出假脱机空间错误 - 有助于优化sql / primary索引

时间:2017-07-16 11:13:50

标签: sql teradata

我正在使用以下TeraData代码:

CREATE SET TABLE WebSesData1
(
    Id CHAR(5) CHARACTER SET LATIN NOT CASESPECIFIC
    ,WebSessionId BIGINT
) PRIMARY INDEX (WebSessionId);

CREATE SET TABLE WebSesData1
(
    Id CHAR(5) CHARACTER SET LATIN NOT CASESPECIFIC
    ,WebSessionId BIGINT
) PRIMARY INDEX (WebSessionId);

SELECT 
    One.Id AS PickedId
    ,Two.Id AS InteractingId 
    ,COUNT(*) AS Evidence
FROM WebSesData1 AS One
INNER JOIN WebSesData2 AS Two
ON
    One.Id  < Two.Id
    AND One.WebSessionId = Two.WebSessionId
GROUP BY 1,2
QUALIFY ROW_NUMBER() OVER(PARTITION BY One.Id ORDER BY COUNT(*) DESC) <= 10
;

为WebSesData1中的每个Id标识WebSesData2中的TOP 10不同ID,它们共享相同的WebSessionId。偶尔,我仍然会因上述查询而出现假脱机空间错误。我已经在&#39; chunks&#39;中写了数据。进入WebSesData1和WebSesData2以试图提高效率。

我能做些什么来提高上述效率吗?通过更改SQL和/或主索引。我也可以创建不同的工作表。任何建议都非常欢迎。

0 个答案:

没有答案