oracle st_geometry 百万级数据的空间属性快速查询

1.空间点查询

select t.columnName from  table t where sde.st_intersects(shape,
            sde.st_geometry( point (109.624 39.444),
            4490)) = 1

2.空间线查询

select t.columnName from  table t where sde.st_intersects(shape,
            sde.st_geometry( linestring (109.624 39.444,109.624 39.931,110.624 39.931,110.624 39.624),
            4490)) = 1

3.空间面查询

select t.columnName from  table t sde.st_intersects(shape,
            sde.st_geometry( linestring (POLYGON ((109.624 39.444,109.624 39.931,110.624 39.931,110.624 39.624,109.624 39.444)),
            4490)) = 1

说明 其中的 4490指的是空间表的shape的 srid ,注意如果将 4490改为 t.shape.srid ,查询会变得很慢,因为sql解析时,认为每一条属性数据都是不同的srid,正确的做法是将4490改为(select t1.shape.srid from table t1 where rownum=1) t 和t1是同一张表

另外查询 st_astext(shape)可能无法命中索引,这个时候需要强制使用索引

/*+ index(t ${indexName}) */

indexName 为 shape的索引名称

关于千万级数据查询需要写一些奇怪的where 条件来提升命中索引的问题,后续再写吧


版权声明:本文为weixin_43607989原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。