修改了 allowLargeResults ,我也尝试了交互式和批量查询优先级。 表 search_results 中有70M记录,搜索中有10M记录,购买表中约有(仅)900记录。并且WHERE也很好地减少了行数。
SELECT
s.flyFrom, s.to, s.typeFlight, r.price, b.price, b.affily
FROM [sptest.buy] AS b
INNER JOIN [sptest.search_results] AS r
ON b.booking_token=r.booking_token
INNER JOIN [sptest.searches] AS s
ON s.searchid=r.searchid
WHERE
DATE(r.saved_at) >= DATE('2015-06-23 00:00:00') AND
DATE(s.saved_at) >= DATE('2015-06-23 00:00:00')
LIMIT 10
问题可能是由大型连接键引起的吗? booking_token 键是可变大小的50-600个字符。
答案 0 :(得分:2)
我会对此查询进行一些修改:
SELECT
s.flyFrom, s.to, s.typeFlight, r.price, b.price, b.affily
FROM [sptest.buy] AS b
INNER JOIN EACH
(SELECT * FROM [sptest.search_results] WHERE saved_at > DATE('2015-06-23 00:00:00')) AS r
ON b.booking_token=r.booking_token
INNER JOIN EACH
(SELECT * FROM [sptest.searches] WHERE saved_at > DATE('2015-06-23 00:00:00') AS s
ON s.searchid=r.searchid
LIMIT 10