views:

50

answers:

1

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?

+1  A: 

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);
fmark