SELECT
a,
b,
c,
d,
SUM(e + f) AS ef,
SUM(g) / 1000 AS g1,
SUM(h * 100) AS h,
SUM(i) AS i1,
SUM(j) AS j1,
k,
SUM(l) AS l
FROM
t1
WHERE
a = 1
AND b NOT IN (1188751, 595110, 519727, 1155905)
AND c = 0
AND d >= ‘1721087400’
AND e < ‘2024-07-16 08:50:00’
AND f >= ‘2024-07-16 07:50:00’
AND g < 1721091000
GROUP BY
a,
b,
c,
d,
e;
解决办法:
打开 session 级别的 force mpp(既:忽略任何代价直接走 tiflash),不可行,因为只是 session 级别的
这样改写一下呢?主要是把聚合函数里的计算拿出来了,还有就是把group by e改成了group by k,不知道是不是笔误。
SELECT
a,b,c,d,
e + f AS ef,
g / 1000 AS g1,
h * 100 AS h,
i AS i1,
j AS j1,
k,
l AS l
FROM (
SELECT
a,b,c,d,
SUM(e) AS e, SUM(f) AS f,
SUM(g) AS g,
SUM(h) AS h,
SUM(i) AS i,
SUM(j) AS j,
k,
SUM(l) AS l
FROM t1
WHERE a = 1
AND b NOT IN (1188751, 595110, 519727, 1155905)
AND c = 0
AND d >= '1721087400'
AND e < '2024-07-16 08:50:00'
AND f >= '2024-07-16 07:50:00'
AND g < 1721091000
GROUP BY a,b,c,d,k
) t