给定一个1.4 TB的Parquet数据源,存储在S3上,按时间戳字段进行分区(因此分区为年
-月
-日
),我正在通过Redshift Spectrum查询特定日期的数据(2.6 GB的数据),并检索Parquet文件中的所有可用字段,使用以下查询:
SELECT *
FROM my_external_schema.my_external_table
WHERE year = '2020' and month = '01' and day = '01'
这张表格是通过一个指向S3顶级“文件夹”的Glue Crawler提供的;这将创建一个数据库,然后通过此命令将数据库链接到新的外部架构:
create external schema my_external_schema from data catalog
database 'my_external_schema'
iam_role 'arn:aws:iam::123456789:role/my_role'
region 'my-region-9';
通过我的IDE分析表格,我可以看到该表格是由以下语句生成的:
create external table my_external_schema.my_external_table
(
id string,
my_value string,
my_nice_value string
)
partitioned by (year string, month string, day string)
row format serde 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
with serdeproperties ('serialization.format'='1')
stored as
inputformat 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
outputformat 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
location 's3://my-bucket/my/location/'
table properties ('CrawlerSchemaDeserializerVersion'='1.0', 'CrawlerSchemaSerializerVersion'='1.0', 'UPDATED_BY_CRAWLER'='my_crawler');
当我分析Redshift查询时,我发现它扫描了大约86GB的数据。
这怎么可能呢?这是一个问题,因为Redshift根据扫描的数据量计费,看起来该服务正在扫描该分区中实际数据量的约40倍。
我还尝试在Athena中执行相同的查询,那里只扫描了2.55GB的数据(明显更合理)。
我不能提供太多有关集群大小的细节,但可以假设这86GB的扫描数据可以适应集群的内存。