空间查询的 PGA 内存限制
我正在尝试对两个表进行空间查询,每个表大约有 10m 行。
我想做的是根据 t1 和 t2 在 t1 周围 50m 半径内的编辑距离将 table1 与 table2 关联起来。如果半径内没有记录,我们选择最近的邻居。
我的方法是创建两种视图:一种用于编辑距离,另一种用于最近邻。
-- VIEW1
SELECT ID,a,b
FROM TABLE(SDO_JOIN(t1, 'SHAPE', t2, 'SHAPE', 'DISTANCE=50 UNIT=M')) geom_join
LEFT JOIN t1 ON geom_join."ROWID1" = t1."ROWID"
LEFT JOIN t2 ON geom_join."ROWID2" = t2."ROWID"
WHERE SDO_GEOM.VALIDATE_GEOMETRY(t2."SHAPE", 0.005) = 'TRUE'
AND SDO_GEOM.VALIDATE_GEOMETRY(t1."SHAPE", 0.005) = 'TRUE'
and taking the MIN of levenshtein distance.
-- VIEW2
SELECT ID,a,b
FROM t1, t2
WHERE SDO_NN(t2, t1, 'SDO_NUM_RES=1, UNIT=M') = 'TRUE'
AND SDO_GEOM.VALIDATE_GEOMETRY(t1."SHAPE", 0.005) = 'TRUE'
AND SDO_GEOM.VALIDATE_GEOMETRY(t2."SHAPE", 0.005) = 'TRUE'
然后从这些视图创建表,因为
SELECT ID,
(CASE WHEN VIEW1.a IS NULL THEN VIEW2.a ELSE VIEW1.a END) a,
(CASE WHEN VIEW1.b IS NULL THEN VIEW2.b ELSE VIEW1.b END) b
FROM VIEW2
LEFT JOIN VIEW1 USING(ID)
这似乎适用于小型数据集,但对于实际表失败并引发以下错误:
cx_Oracle.DatabaseError: ORA-29902: error in executing ODCIIndexStart() routine
ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 588
我可能会提高限制(当前为 4Gb),但是我想首先检查是否存在是一个不这样做的解决方案。
I'm trying to make a spatial query on two tables with around 10m rows each.
What I'm trying to do is to relate table1 to table2 based on the levenshtein distance of t1 and t2 in a radius of 50m around t1. If no record is in the radius, we chose the nearest neighbour.
My approach was to create two views: one for the levenshtein distance, and one for the nearest neighbour.
-- VIEW1
SELECT ID,a,b
FROM TABLE(SDO_JOIN(t1, 'SHAPE', t2, 'SHAPE', 'DISTANCE=50 UNIT=M')) geom_join
LEFT JOIN t1 ON geom_join."ROWID1" = t1."ROWID"
LEFT JOIN t2 ON geom_join."ROWID2" = t2."ROWID"
WHERE SDO_GEOM.VALIDATE_GEOMETRY(t2."SHAPE", 0.005) = 'TRUE'
AND SDO_GEOM.VALIDATE_GEOMETRY(t1."SHAPE", 0.005) = 'TRUE'
and taking the MIN of levenshtein distance.
-- VIEW2
SELECT ID,a,b
FROM t1, t2
WHERE SDO_NN(t2, t1, 'SDO_NUM_RES=1, UNIT=M') = 'TRUE'
AND SDO_GEOM.VALIDATE_GEOMETRY(t1."SHAPE", 0.005) = 'TRUE'
AND SDO_GEOM.VALIDATE_GEOMETRY(t2."SHAPE", 0.005) = 'TRUE'
And then create the table from these views as
SELECT ID,
(CASE WHEN VIEW1.a IS NULL THEN VIEW2.a ELSE VIEW1.a END) a,
(CASE WHEN VIEW1.b IS NULL THEN VIEW2.b ELSE VIEW1.b END) b
FROM VIEW2
LEFT JOIN VIEW1 USING(ID)
This seems to work for small datasets, however fails for the real tables and raise the following error:
cx_Oracle.DatabaseError: ORA-29902: error in executing ODCIIndexStart() routine
ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 588
I could potentially raise the limit (currently 4Gb), however I'd like to check first if there was a solution without doing that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论