使用PostGIS在用户附近快速找到 [英] Fast find near users using PostGIS

查看:86
本文介绍了使用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 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?

推荐答案

第一步是索引几何列.像这样:

The first step is to index the geometry column. Something like this:

  CREATE INDEX geo_location_data_the_geom_idx ON geo_location_data USING GIST (the_geom);

这篇关于使用PostGIS在用户附近快速找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆