<div dir="ltr">I'm trying to query all the records within XX distance from a geometry. I would like to be able to reference the subject geometry via it's id, and then find every geometry that is either:<div><br></div>
<div>A) within XX distance from a x/y coordinate of the geometry</div><div>B) within XX distance from the edge of the geometry on all sides. (ideal)</div><div><br></div><div>What is the best way to accomplish this? My current query:</div>
<div><br></div><div><div>SELECT *</div><div><span class="" style="white-space:pre"> </span>FROM sdgis.parcels4326 AS parcels</div><div><span class="" style="white-space:pre"> </span>WHERE ST_Distance_Sphere(</div><div><span class="" style="white-space:pre"> </span>parcels.geom,</div>
<div><span class="" style="white-space:pre"> </span>ST_Transform(ST_SetSRID(ST_MakePoint('6255896.314288','1898596.929109'),2230),4326)</div><div><span class="" style="white-space:pre"> </span>) < 100.0;</div>
<div><br></div><div>This takes a few minutes to run on a table with just over 1 million records. I would like to swap out the ST_MakePoint, with a multipolygon from a record that is looked up via it's id. </div><div>
<br>
</div><div>Any suggestions are greatly appreciated.</div><div><div><br></div>-- <br>Alexander W. Rolek<br><br></div></div></div>