我目前正在尝试将设备的每个lat-long ping与其邮政编码相关联。
我已经取消了lat long设备ping数据的规范化,并创建了一个跨积/笛卡尔积联接表,其中每一行都有st_point(long,lat)、geometry_shape_of_zip以及该几何体的相关邮政编码。出于测试目的,我在表中有大约4500万行,它的产量将增加到每天大约10亿行。
即使数据被展平并且没有连接条件,查询也需要大约2小时才能完成。有没有更快的方法来计算空间查询?或者如何优化以下查询。
inline是我已经执行的一些优化步骤。使用优化,除了这一步,其他所有操作最多只需5分钟即可完成。我使用的是aws群集2个主节点和5个数据节点。
set hive.vectorized.execution.enabled = true;
set hive.execution.engine=tez;
set hive.enforce.sorting=true;
set hive.cbo.enable=true;
set hive.compute.query.using.stats=true;
set hive.stats.fetch.column.stats=true;
set hive.stats.fetch.partition.stats=true;
analyze table tele_us_zipmatch compute statistics for columns;
CREATE TABLE zipcheck (
`long4` double,
`lat4` double,
state_name string,
country_code string,
country_name string, region string,
zip int,
countyname string) PARTITIONED by (state_id string)
STORED AS ORC TBLPROPERTIES ("orc.compress" = "SNAPPY",
'orc.create.index'='true',
'orc.bloom.filter.columns'='');
INSERT OVERWRITE TABLE zipcheck PARTITION(state_id)
select long4, lat4, state_name, country_code, country_name, region, zip, countyname, state_id from tele_us_zipmatch
where ST_Contains(wkt_shape,zip_point)=TRUE;
st\ U contains是esri的函数(参考:https://github.com/esri/spatial-framework-for-hadoop/wiki/udf-documentation#relationship-测试)。
非常感谢您的帮助。
谢谢。
1条答案
按热度按时间wkyowqbh1#
如果邮政编码数据集可以放入内存中,请尝试一个自定义的map reduce应用程序,通过调整hadoop的gis工具中的示例,对邮政编码数据使用即时内存四叉树索引。
[合作者]