如何在 SQL CE 中有效搜索作为路口的附近地理节点?
我有以下查询:
var nodes = DB.Nodes
.Where(x => x.Lon > 486400
&& x.Lon < 486600
&& x.Lat > 5025100
&& x.Lat < 5025300)
.Join(DB.RoadNodes, x => x.Id, y => y.NodeId, (x, y) => x);
这会搜索特定位置附近的 DB.Nodes
中的所有节点,然后通过与 DB.RoadNodes
连接来检查该节点是否是路口。代码>;然而,这需要几秒钟的时间,速度很慢。
看起来我必须在这里做两件事:
优化
Where
部分,它本身需要~5
秒,我听说过一些关于 Spatial 的事情?优化
Join
部分,它本身需要剩余~15
秒,我需要一个索引,对吗?
所以我对此有两个问题:
如何在 SQL Server Compact Edition 中进行空间存储和搜索?
如果不受支持,我该如何解决此问题?
我需要为哪些列建立索引才能使该查询充分发挥作用?
似乎对 RoadNodes 的 NodeId 建立索引并没有真正改善查询。
请注意,我仅限于 SQL CE,因为我打算在 Windows Phone 7 上运行它。
另外,我需要从中获取 Unique()
,这使得查询稍微长一些,但我我猜如果查询本身运行得很快,那应该不是问题。只是他 join 引入了双重结果,或者我应该以其他方式进行 Join 吗?
I have the following query:
var nodes = DB.Nodes
.Where(x => x.Lon > 486400
&& x.Lon < 486600
&& x.Lat > 5025100
&& x.Lat < 5025300)
.Join(DB.RoadNodes, x => x.Id, y => y.NodeId, (x, y) => x);
This searches all the nodes in DB.Nodes
near a certain location, then it checks whether the node is a road junction by taking a join with DB.RoadNodes
; however, this takes several seconds which is slow.
It looks like I have to do two things here:
Optimize the
Where
part which takes~5
seconds on its own, I heard something about Spatial?Optimize the
Join
part which takes a remaining~15
seconds on its own, I need an index, right?
So I have two questions about this:
How can I do spatial storage and searching in SQL Server Compact Edition?
If this is unsupported, how do I work around this issue?
Which columns do I need to index for this query to work sufficiently?
It seems like indexing the NodeId of RoadNodes doesn't really improve the query.
Please note that I am restricted to SQL CE as I intend to run this on a Windows Phone 7.
Also node that I need to take an Unique()
from that, which makes the query slightly longer but I guess that shouldn't be an issue if the query itself runs fast. It's just that he join introduces double results, or should I do the Join in another way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论