How do I efficiently search in SQL CE for nearby geographical nodes that are road junctions?

你。 提交于 2019-12-11 03:49:17

问题


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:

  1. Optimize the Where part which takes ~5 seconds on its own, I heard something about Spatial?

  2. 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:

  1. How can I do spatial storage and searching in SQL Server Compact Edition?

    If this is unsupported, how do I work around this issue?

  2. 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?

来源:https://stackoverflow.com/questions/9163533/how-do-i-efficiently-search-in-sql-ce-for-nearby-geographical-nodes-that-are-roa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!