2

我可以运行下面的查询,但是当我将参数交换为 sdo_nn 时,我得到一个错误,即 SDO_NN 无法在不使用索引的情况下进行评估

作品:

SELECT
c.customer_id,
c.first_name,
c.last_name,
sdo_nn_distance (1) distance
FROM stores s,
customers c
AND sdo_nn
(c.cust_geo_location, s.store_geo_location, 'sdo_num_res=1', 1)= 'TRUE'
ORDER BY distance;

不工作:

SELECT
c.customer_id,
c.first_name,
c.last_name,
sdo_nn_distance (1) distance
FROM stores s,
customers c
AND sdo_nn
(s.store_geo_location,c.cust_geo_location, 'sdo_num_res=1', 1)= 'TRUE'
ORDER BY distance;

任何人都可以向我解释为什么顺序很重要?

4

2 回答 2

0

From Oracle's online docs sdo_nn needs the first parameter to be spatially indexed. the second parameter does not have that necessity/constraint.

So when swapping parameters you need to make sure the "now first" parameter (i.e. s.store_geo_location) is spatially indexed. See this on how to create a spatial index in Oracle.

于 2012-04-08T18:36:31.460 回答
0

添加编译器提示以告诉查询解析器使用什么索引,例如:

select
/*+ index(tableName,sdoIndexName) */
...

警告编译器提示静默失败

于 2014-12-19T05:03:47.307 回答