<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 12px; border-collapse: collapse; "><div>Have over a million POINT (the_geom) records located in two separate tables - x.table & y.table. x.table 50,000 records; y.table 995,000 records.</div>
<div>Distances required are all less than 1.5 miles (2414 meters) : all locations are located within a specific region of the US.</div><div>GiST index on the_geom </div><div>Goal: distance from all y.the_geom to x.the_geom - (shortest distance). And then place this distance back into each respective y.table.record (currently creating temp table to then update y.table)</div>
<div><br></div><div>Current sql:</div><div><div>SELECT <a href="http://m.id/" target="_blank" style="color: rgb(64, 100, 128); ">m.id</a> AS mid, </div><div><span style="white-space: pre; "> </span>m.building_i AS mb_id, </div>
<div><span style="white-space: pre; "> </span><a href="http://c.id/" target="_blank" style="color: rgb(64, 100, 128); ">c.id</a> AS cid, c.building_i AS cb_id, </div><div><span style="white-space: pre; "> </span>m.streetaddr AS m_address, </div>
<div><span style="white-space: pre; "> </span>m.city AS m_city, </div><div><span style="white-space: pre; "> </span>m.state AS m_state, </div><div><span style="white-space: pre; "> </span>m.zip AS m_zip, </div><div><span style="white-space: pre; "> </span>m.zip4 AS m_zip4, </div>
<div><span style="white-space: pre; "> </span>round(CAST(</div><div><span style="white-space: pre; "> </span>ST_Distance_Sphere(</div><div><span style="white-space: pre; "> </span>ST_Transform(m.the_geom,4326),</div>
<div><span style="white-space: pre; "> </span>ST_Transform(c.the_geom,4326)</div><div><span style="white-space: pre; "> </span>)</div><div><span style="white-space: pre; "> </span>AS numeric</div><div><span style="white-space: pre; "> </span>)</div>
<div><span style="white-space: pre; "> </span>,2) AS dist_meters</div><div>FROM market_locations m, customer_locations c</div><div>WHERE st_dwithin(ST_Transform(m.the_geom,4326),</div><div><span style="white-space: pre; "> </span>ST_Transform(c.the_geom,4326) ,2414.016)</div>
<div><br></div><div>I tried ST_Spheroid as well but after 28 hours I killed it. This current query (ST_Sphere) has been working for .... 14 hrs. Question is, should this be expected in terms of overhead and time, are there areas I might be able to tighten to increase performance on the query (additional btree index etc.)</div>
<div>System Information: PostgreSQL 8.3.7 on i386-apple-darwin8.11.1, compiled by GCC i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5370)</div><div><br></div><div>Thanks to any and all for assistance.</div>
<div><br></div><div> - bo</div><div><br></div></div></span>