Hive 分区性能
Hive Partition Performance
想问一下Hive分区性能。
我需要多少条记录(按行计算)才能查看分区性能?
目前,我有超过 200 万条记录,我已将 table 分成 2 个分区。
我的分区条件如下:
ADD PARTITION (year_month=’2017_07’)
ADD PARTITION (year_month=’2017_08’)
INSERT OVERWRITE TABLE T PARTITION (year_month='2017_07')
SELECT * FROM T WHERE st_time < '2017_08_01 00:00:00.0';
INSERT OVERWRITE TABLE T PARTITION (year_month='2017_08')
SELECT * FROM T WHERE st_time >= '2017_08_01 00:00:00.0';
当我尝试在分区 table 和非分区 table 之间进行一些性能测试时,这两个 table 的性能相对相同。
我的性能测试查询如下:
SELECT * FROM T WHERE st_time < '2017_08_01 00:00:00.0';
SELECT * FROM non_part_table WHERE st_time < '2017_08_01 00:00:00.0';
我是不是漏掉了一些重要的点?
此外,分区是否适用于派生 column/function?例如。 date_format(st_time, yyyy-MM)
非常感谢任何帮助或建议。
the performance of both tables is relatively the same
您忘记了针对分区的 WHERE 子句。只有当您在其中选择数据 时,分区才会提高性能。
SELECT * FROM T
WHERE year_month = '2017_07'
-- AND st_time < '2017_08_01 00:00:00.0'
;
没有这个,您仍在扫描整个 table 以寻找 st_time
值。
您可以在查询中添加 EXPLAIN
以查看差异
通过将数据转换为 Parquet 或 ORC,您将获得额外的性能提升
想问一下Hive分区性能。 我需要多少条记录(按行计算)才能查看分区性能?
目前,我有超过 200 万条记录,我已将 table 分成 2 个分区。 我的分区条件如下:
ADD PARTITION (year_month=’2017_07’)
ADD PARTITION (year_month=’2017_08’)
INSERT OVERWRITE TABLE T PARTITION (year_month='2017_07') SELECT * FROM T WHERE st_time < '2017_08_01 00:00:00.0';
INSERT OVERWRITE TABLE T PARTITION (year_month='2017_08') SELECT * FROM T WHERE st_time >= '2017_08_01 00:00:00.0';
当我尝试在分区 table 和非分区 table 之间进行一些性能测试时,这两个 table 的性能相对相同。 我的性能测试查询如下:
SELECT * FROM T WHERE st_time < '2017_08_01 00:00:00.0';
SELECT * FROM non_part_table WHERE st_time < '2017_08_01 00:00:00.0';
我是不是漏掉了一些重要的点?
此外,分区是否适用于派生 column/function?例如。 date_format(st_time, yyyy-MM)
非常感谢任何帮助或建议。
the performance of both tables is relatively the same
您忘记了针对分区的 WHERE 子句。只有当您在其中选择数据 时,分区才会提高性能。
SELECT * FROM T
WHERE year_month = '2017_07'
-- AND st_time < '2017_08_01 00:00:00.0'
;
没有这个,您仍在扫描整个 table 以寻找 st_time
值。
您可以在查询中添加 EXPLAIN
以查看差异
通过将数据转换为 Parquet 或 ORC,您将获得额外的性能提升