I have multiple tables on Postgres wit GIS and when I query
SELECT * FROM rxmsg
JOIN Vehicles ON rxmsg.vid=Vehicles.vid
JOIN stops on ST_DWithin(rxmsg.point, stops.point,1000)
JOIN drivers ON Vehicles.vid = drivers.vehicle_id
WHERE rxmsg.rxdt BETWEEN drivers.date_activated AND drivers.date_deactivated;
the cost is enormous http://explain.depesz.com/s/8BE
My question is: Why is it so costly?
Sample data
RXMSG (estimated 60m rows)
Has indexes on date and on point (point is a geographic point made from lat and lon)

VEHICLES (63 rows)

DRIVERS (2 rows)

STOPS (338 rows)

Also, data and tables are in pastebin http://pastebin.com/Pj8vsL9R







