I assume you mean it takes a long time? The key is to create a buffer around the point that is as big as you feel necessary to make a match, and then in your where clause only match lines that intersect this. That way the index is used to limit the number of candidates to get the distance for. Something like
where line && st_expand(myPoint, bufferSizeInYourProjectionUnits) hth charles On Aug 20, 2011, at 4:56 AM, Aurélien FILEZ wrote: > Hi, > > I have two tables, one which define lines (ST_LineString) and a point > (St_Points). > > I'm searching to get the nearest line from this point. > > My first solution was to use this type of query : > SELECT > id, > St_Distance(line, myPoint) d > FROM > my_lines_tables > ORDER BY d ASC LIMIT 1 > > But it's very long. Is there is another way to make this ? > > Thank you all, > Kin > _______________________________________________ > postgis-users mailing list > [email protected] > http://postgis.refractions.net/mailman/listinfo/postgis-users _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users
