使用PostGIS快速查找附近的用户
我有 5 个表:
- users - information about user with current location_id (fk to geo_location_data)
- geo_location_data - information about location, with PostGIS geography(POINT, 4326) column
- user_friends - relationships between users.
我想为当前用户找到附近的朋友,但是执行选择查询需要花费大量时间来了解用户是否是朋友,然后使用 ST_DWithin
执行选择。领域模型或查询中可能有问题吗?
I have 5 tables:
- users - information about user with current location_id (fk to geo_location_data)
- geo_location_data - information about location, with PostGIS geography(POINT, 4326) column
- user_friends - relationships between users.
I want to find near friends for current user, but it takes a lot of time of executing select query to know if user is a friend and after that execute select using ST_DWithin
. May be something wrong in domain model or in queries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一步是索引几何列。像这样的东西:
The first step is to index the geometry column. Something like this:
尝试在您的点和相交运算符上使用缓冲区。
应该会更快。
Try to use a buffer on your points and the the intersects operator.
It should be faster.