【问题标题】:array_intersect giving performance issue in prestoarray_intersect 在 presto 中给出性能问题
【发布时间】:2019-10-11 16:17:30
【问题描述】:

我有一个在 presto 中运行的查询,它具有 array_intersect 条件。这大约需要 5 个小时才能运行。如果我删除 array_intersect 那么它需要不到一个小时。

CARDINALITY(ARRAY_INTERSECT(links, ARRAY['504949547', '504949616', '515604515', '515604526', '515604527', '515604528'])) > 0

谁能告诉我如何提高性能。必须在 5 分钟内搞定。

已尝试启用溢出磁盘,但没有帮助。输入数据大小约为 1TB。

谢谢

【问题讨论】:

    标签: presto


    【解决方案1】:

    array_intersect 将结果(交集)具体化,而您唯一要检查的是某些预定义元素的成员资格。 在这种情况下,我建议改用any_match

    any_match(links, e -> e IN ('504949547', '504949616', ...))
    

    如果您使用的 Presto 版本没有any_match,您可以使用reduce

    reduce(
        links, -- array to reduce
        false, -- initial state
        (s, e) -> s OR e IN ('504949547', '504949616', ...), -- reduction function
        s -> s) -- output function
    

    已尝试启用溢出磁盘,但没有帮助。

    注意:In Presto, spill is supported for certain operators(大多数联接、聚合、排序依据、窗口函数)。它不适用于在ARRAYs 上运行的标量函数。此外,您不应期望溢出会提高性能。它只能减少内存占用,以性能为代价

    【讨论】:

    • 嗨@piotrfindeisen,感谢您的快速回复。我使用的是 0.224 版本,但我没有在其中找到 any_match 函数。我们实际上是 AWS EMR,AWS 中可用的更高版本是 0.224。谢谢
    • 顺便说一句,我邀请您加入 Presto Community Slack prestosql.io/slack.html
    • 感谢您的回答。另外,我加入了 Slack。再次感谢
    • 我在 Slack 上看不到你,所以你可能加入了 Facebook Presto 的 slack。请检查松弛链接@prestosql.io/slack.html
    猜你喜欢
    • 2016-02-17
    • 2017-03-12
    • 2016-10-06
    • 1970-01-01
    • 1970-01-01
    • 2019-01-21
    • 2017-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多