Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

Querying really slow Postgres

$
0
0

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)

rxmsg

VEHICLES (63 rows)

vehicles

DRIVERS (2 rows)

drivers

STOPS (338 rows)

stops

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


Viewing all articles
Browse latest Browse all 1138

Latest Images

Trending Articles



Latest Images