我在 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 附近执行?