【发布时间】:2019-09-03 09:18:42
【问题描述】:
我在 S3 中有一个存储桶,其中包含镶木地板文件并按日期分区。
使用以下查询:
select
count(1)
from logs.logs_prod
where partition_1 = '2019' and partition_2 = '03'
直接在 Athena 中运行该查询,不到 10 秒即可执行。但是当我在 Redshift 中运行相同的查询时,它需要 3 多分钟。它们都返回相同的正确值,在这种情况下,该分区中的行数少于 8 万。
我使用 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 附近执行?
【问题讨论】:
-
我遇到了类似的问题。我对外部表进行了一个非常简单的查询,其中镶木地板文件由 varchar 和日期分区。我用一个 parquet 文件编写了一个针对单个分区的查询,它需要一分钟多的时间才能返回。我不想回答问题,所以我为格式化道歉...查询:
SELECT uuid FROM spectrum.telemetry_event WHERE "tag" = 'my.test.tag' AND date = '2020-05-06';查询计划:XN Partition Loop \n -> XN Seq Scan \n Filter \n -> XN S3 Query Scan \n -> S3 Seq Scan
标签: amazon-athena amazon-redshift-spectrum