使用 `LIKE` 时,Amazon Athena 中的全文查询超时
Full text query in Amazon Athena is timing-out when using `LIKE`
像这样在 Athena 中获取全文查询的超时错误...
SELECT count(textbody) FROM "email"."some_table" where textbody like '% some text to seach%'
有什么办法可以优化吗?
更新:
创建 table 语句:
CREATE EXTERNAL TABLE `email`.`email5_newsletters_04032019`(
`nesletterid` string,
`name` string,
`format` string,
`subject` string,
`textbody` string,
`htmlbody` string,
`createdate` string,
`active` string,
`archive` string,
`ownerid` string
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ',',
'ESCAPED BY' = '\'
) LOCATION 's3://some_bucket/email_backup_updated/email5/'
TBLPROPERTIES ('has_encrypted_data'='false');
以及 S3 存储桶内容:
# aws s3 ls s3://xxx/email_backup_updated/email5/ --human
2020-08-22 15:34:44 2.2 GiB email_newsletters_04032019_updated.csv.gz
这个文件中有1100万条记录。该文件可以在 Redshift 中在 30 分钟内导入,并且在 redshift 中一切正常。我会更喜欢使用 Athena!
CSV 不是一种与 presto 引擎集成得很好的格式,因为查询需要读取整行才能到达单个列。一种优化 athena 使用的方法,也可以为您节省大量存储成本,是切换到列式存储格式,如 parquet 或 orc,您实际上可以通过查询来实现:
CREATE TABLE `email`.`email5_newsletters_04032019_orc`
WITH (
external_location = 's3://my_orc_table/',
format = 'ORC')
AS SELECT *
FROM `email`.`email5_newsletters_04032019`;
然后在新 table:
上重新运行上面的查询
SELECT count(textbody) FROM "email"."email5_newsletters_04032019_orc" where textbody like '% some text to seach%'
像这样在 Athena 中获取全文查询的超时错误...
SELECT count(textbody) FROM "email"."some_table" where textbody like '% some text to seach%'
有什么办法可以优化吗?
更新:
创建 table 语句:
CREATE EXTERNAL TABLE `email`.`email5_newsletters_04032019`(
`nesletterid` string,
`name` string,
`format` string,
`subject` string,
`textbody` string,
`htmlbody` string,
`createdate` string,
`active` string,
`archive` string,
`ownerid` string
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ',',
'ESCAPED BY' = '\'
) LOCATION 's3://some_bucket/email_backup_updated/email5/'
TBLPROPERTIES ('has_encrypted_data'='false');
以及 S3 存储桶内容:
# aws s3 ls s3://xxx/email_backup_updated/email5/ --human
2020-08-22 15:34:44 2.2 GiB email_newsletters_04032019_updated.csv.gz
这个文件中有1100万条记录。该文件可以在 Redshift 中在 30 分钟内导入,并且在 redshift 中一切正常。我会更喜欢使用 Athena!
CSV 不是一种与 presto 引擎集成得很好的格式,因为查询需要读取整行才能到达单个列。一种优化 athena 使用的方法,也可以为您节省大量存储成本,是切换到列式存储格式,如 parquet 或 orc,您实际上可以通过查询来实现:
CREATE TABLE `email`.`email5_newsletters_04032019_orc`
WITH (
external_location = 's3://my_orc_table/',
format = 'ORC')
AS SELECT *
FROM `email`.`email5_newsletters_04032019`;
然后在新 table:
上重新运行上面的查询SELECT count(textbody) FROM "email"."email5_newsletters_04032019_orc" where textbody like '% some text to seach%'