<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Implementing Zip Code Proximity Functions in MySQL and PostgreSQL</title>
	<atom:link href="http://iamtgc.com/2009/01/14/implementing-zip-code-proximity-functions-in-mysql-and-postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://iamtgc.com/2009/01/14/implementing-zip-code-proximity-functions-in-mysql-and-postgresql/</link>
	<description></description>
	<lastBuildDate>Sat, 28 Jan 2012 23:45:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Joel</title>
		<link>http://iamtgc.com/2009/01/14/implementing-zip-code-proximity-functions-in-mysql-and-postgresql/comment-page-1/#comment-3218</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Thu, 11 Aug 2011 17:55:02 +0000</pubDate>
		<guid isPermaLink="false">http://iamtgc.com/?p=95#comment-3218</guid>
		<description>Hey TGC,

First I just want to say thanks for posting this code, worked flawlessly for me.  I was doing some testing with alternate methods (in Postgres), looking for the fastest execution speed when I found this post.

The thing that surprised me and keeps me from implementing this into our radial proximity search, is that this singular, alternative query:

$sqlselect_in_radius_zip = pg_exec(&quot;SELECT * FROM zips_us_tbl 
WHERE (((acos(sin(($latitude*pi()/180)) * sin((lat*pi()/180))+cos(($latitude*pi()/180)) * cos((lat*pi()/180)) * cos((($longitude-lon)*pi()/180))))*180/pi())*60*1.1515) &lt;= $radius
GROUP BY zip,city,state,lat,lon&quot;) or die(pg_errormessage());

Executes 3-4 times faster for me and without the use of functions, even when I&#039;m using a huge proximity range and pulling in thousands of results.  I was hoping that by using PLPGSQL functions, I could cut query time and let Postgres do more of the &quot;speedy&quot; work but that just wasn&#039;t the case.

I like the method of math you are using in your calculations and also the fact that there&#039;s an option for passing miles VS kilometers as well.  Both methods seem to return very similar results and get the job done but for practical reasons,  I have to opt for speed and ditch the functions.

Just thought I&#039;d post that info in case you found it interesting or wanted to test it out.  Maybe there&#039;s a way to refine the process, pull it into one single function and get it optimized.

Thanks again for putting the work together, very easy to implement.</description>
		<content:encoded><![CDATA[<p>Hey TGC,</p>
<p>First I just want to say thanks for posting this code, worked flawlessly for me.  I was doing some testing with alternate methods (in Postgres), looking for the fastest execution speed when I found this post.</p>
<p>The thing that surprised me and keeps me from implementing this into our radial proximity search, is that this singular, alternative query:</p>
<p>$sqlselect_in_radius_zip = pg_exec(&#8220;SELECT * FROM zips_us_tbl<br />
WHERE (((acos(sin(($latitude*pi()/180)) * sin((lat*pi()/180))+cos(($latitude*pi()/180)) * cos((lat*pi()/180)) * cos((($longitude-lon)*pi()/180))))*180/pi())*60*1.1515) &lt;= $radius<br />
GROUP BY zip,city,state,lat,lon&quot;) or die(pg_errormessage());</p>
<p>Executes 3-4 times faster for me and without the use of functions, even when I&#039;m using a huge proximity range and pulling in thousands of results.  I was hoping that by using PLPGSQL functions, I could cut query time and let Postgres do more of the &quot;speedy&quot; work but that just wasn&#039;t the case.</p>
<p>I like the method of math you are using in your calculations and also the fact that there&#039;s an option for passing miles VS kilometers as well.  Both methods seem to return very similar results and get the job done but for practical reasons,  I have to opt for speed and ditch the functions.</p>
<p>Just thought I&#039;d post that info in case you found it interesting or wanted to test it out.  Maybe there&#039;s a way to refine the process, pull it into one single function and get it optimized.</p>
<p>Thanks again for putting the work together, very easy to implement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Implementing Zip Code Proximity Functions in MS SQL Server &#124; iamtgc</title>
		<link>http://iamtgc.com/2009/01/14/implementing-zip-code-proximity-functions-in-mysql-and-postgresql/comment-page-1/#comment-3145</link>
		<dc:creator>Implementing Zip Code Proximity Functions in MS SQL Server &#124; iamtgc</dc:creator>
		<pubDate>Tue, 02 Aug 2011 13:10:48 +0000</pubDate>
		<guid isPermaLink="false">http://iamtgc.com/?p=95#comment-3145</guid>
		<description>[...] Implementing Zip Code Proximity Functions in MS SQL Server   Posted on August 2, 2011 by tgc         This post is in the continuing series of articles on database functions, stored procedures, and implementing ZIP code proximity functionality. [...]</description>
		<content:encoded><![CDATA[<p>[...] Implementing Zip Code Proximity Functions in MS SQL Server   Posted on August 2, 2011 by tgc         This post is in the continuing series of articles on database functions, stored procedures, and implementing ZIP code proximity functionality. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Returning Composite Types in Postgres Stored Procedures &#124; iamtgc</title>
		<link>http://iamtgc.com/2009/01/14/implementing-zip-code-proximity-functions-in-mysql-and-postgresql/comment-page-1/#comment-2998</link>
		<dc:creator>Returning Composite Types in Postgres Stored Procedures &#124; iamtgc</dc:creator>
		<pubDate>Sat, 09 Jul 2011 16:52:53 +0000</pubDate>
		<guid isPermaLink="false">http://iamtgc.com/?p=95#comment-2998</guid>
		<description>[...] #BCCDF0; } input.gsc-search-button { border-color: #666666; background-color: #CECECE; }           &#8592; Implementing Zip Code Proximity Functions in MySQL and&#160;PostgreSQL Adventures in Windows Batch&#160;Scripting [...]</description>
		<content:encoded><![CDATA[<p>[...] #BCCDF0; } input.gsc-search-button { border-color: #666666; background-color: #CECECE; }           &larr; Implementing Zip Code Proximity Functions in MySQL and&nbsp;PostgreSQL Adventures in Windows Batch&nbsp;Scripting [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hari K T</title>
		<link>http://iamtgc.com/2009/01/14/implementing-zip-code-proximity-functions-in-mysql-and-postgresql/comment-page-1/#comment-1671</link>
		<dc:creator>Hari K T</dc:creator>
		<pubDate>Wed, 21 Jul 2010 11:43:03 +0000</pubDate>
		<guid isPermaLink="false">http://iamtgc.com/?p=95#comment-1671</guid>
		<description>Great ... 
You want to write in the top that , the function for MYSQL is given below . I was trying to convert from Postgre to MySQL :) .
Anyway I was forced to look and learn something in PostgreSQL :). 
Thanks once again .</description>
		<content:encoded><![CDATA[<p>Great &#8230;<br />
You want to write in the top that , the function for MYSQL is given below . I was trying to convert from Postgre to MySQL :) .<br />
Anyway I was forced to look and learn something in PostgreSQL :).<br />
Thanks once again .</p>
]]></content:encoded>
	</item>
</channel>
</rss>

