How to optimize scan of 1 huge file / table in Hive to confirm/check if lat long point is contained in a wkt geometry shape
我目前正在尝试将设备上的每个经纬度ping关联到其邮政编码。
我对设备长的ping数据进行了归一化,并创建了一个跨产品/笛卡尔积连接表,其中的每一行都具有ST_Point(long,lat),geometry_shape_of_ZIP以及与该几何相关的邮政编码。出于测试目的,我表中大约有4500万行,并且每天的产量将增加到约10亿。
即使数据被拉平并且没有连接条件,查询也需要大约2个小时来完成。有没有更快的方法来计算空间查询?或如何优化以下查询。
内联是我已经执行的一些优化步骤。使用优化,除此步骤外,所有其他操作最多可在5分钟内完成。我正在使用AWS Cluster 2个Mater节点和5个数据节点。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 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_Contains是esri中的函数(ref:https://github.com/Esri/spatial-framework-for-hadoop/wiki/UDF-Documentation#relationship-tests)。
非常感谢您的帮助。
谢谢。
如果邮政编码数据集可以容纳到内存中,请尝试通过在GIS工具中调整示例,使用定制的Map-Reduce应用程序,该应用程序对ZIP代码数据使用即时的内存中四叉树索引对于Hadoop。
[合作者]