<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">I have the following query which I'd like to speed up from the current 200ms. I do need the distance in meters which is why I'm using ST_Distance_Sphere. Your help is very much appreciated.</span><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<br><div><pre style="white-space:pre-wrap;line-height:16px;width:744px;font-size:12px;margin-bottom:0px;font-family:Consolas,'Liberation Mono',Courier,monospace;margin-top:0px;padding:0px"><div>
SELECT "places".* FROM (</div><div> SELECT</div><div> *,</div><div> ST_Distance_Sphere(geom, 'SRID=4326;POINT(-79.3937393 43.6526704)') as distance</div>
<div> FROM places</div><div> ORDER by geom <#> 'SRID=4326;POINT(-79.3937393 43.6526704)' LIMIT 50</div><div>
) AS places</div><div> WHERE "places"."place_category_id" = 10 ORDER BY distance ASC LIMIT 5</div></pre></div></div></div>