2

我在 S3 中有一个带有镶木地板文件并按日期分区的存储桶。

使用以下查询:

select
    count(1)
from logs.logs_prod
where partition_1 = '2019' and partition_2 = '03'

直接在 Athena 中运行该查询,不到 10 秒即可执行。但是当我在 Redshift 中运行相同的查询时,它需要 3 多分钟。它们都返回相同的正确值,在这种情况下,该分区中的行数少于 80,000。

我使用 AWS Glue 作为 Athena 和 Redshift 的元数据存储。

Redshift 的查询计划如下:

QUERY PLAN
XN Limit  (cost=250000037.51..250000037.51 rows=1 width=8)
  ->  XN Aggregate  (cost=250000037.51..250000037.51 rows=1 width=8)
        ->  XN Partition Loop  (cost=250000000.00..250000035.00 rows=1000 width=8)
              ->  XN Seq Scan PartitionInfo of logs.logs_prod  (cost=0.00..15.00 rows=1 width=0)
                    Filter: (((partition_1)::text = '2019'::text) AND ((partition_2)::text = '03'::text))
              ->  XN S3 Query Scan logs_prod  (cost=125000000.00..125000010.00 rows=1000 width=8)
                    ->  S3 Aggregate  (cost=125000000.00..125000000.00 rows=1000 width=0)
                          ->  S3 Seq Scan logs.logs_prod location:"s3://logs-prod/" format:PARQUET  (cost=0.00..100000000.00 rows=10000000000 width=0)

这个问题是 Redshift Spectrum 配置问题吗?Redshift 中的查询是否可能不会在 Athena 附近执行?

4

1 回答 1

1

我认为你不应该对这个测试过于重视。从计划来看,它似乎没有利用 Parquet 文件包含有关每个文件中的行数的元数据这一事实——我相信 Athena/Parquet 可以做到这一点。

Athena 与 Redshift Spectrum 的实际实际性能很难衡量,因为使用 Athena,您不知道获得了多少容量(但数量很多),而在 Redshift Spectrum 中,您获得的专用容量取决于您的集群大小. 对于具有约 20 个 CPU 的 Redshift 集群,我发现 Athena 对大多数查询的性能更好,但更大的 Redshift 集群可能会获得更好的性能。

于 2019-04-12T16:15:47.093 回答