<div dir="ltr">Hi all, I asked this question in <a href="http://gis.stackexchange.com/questions/171817/can-we-limit-the-search-range-of-geocode-function-in-postgis-tiger-geocoder" target="_blank">gis stackexchange here already</a>. I'm also posting the question in the mailing list to make sure the experts can see the question.<div>

<p>I found the server with only 2 states data loaded is much faster than
 the server with all states loaded. My theory is bad formatted address 
that don't have a exact hit at first will cost much more time when the 
geocoder checked all states. With only 2 states this search is limited 
and stopped much early. </p>

<p>There is a <code>restrict_region</code> parameter in <code>geocode</code>
 function looks promising if it can limit the search range, since I have
 enough information or reason to believe the state information in my 
addresses input are correct. </p><p>I wrote a query trying to use one state's 
geometry as the limiting parameter:</p>

<pre><code>SELECT geocode('501 Fairmount DR , Annapolis, MD 20137', 1, the_geom) 
    FROM tiger.state WHERE statefp = '24';<br> </code></pre>

<p>and compared the performance with the simple version</p>

<pre><code>SELECT geocode('501 Fairmount DR , Annapolis, MD 20137',1);<br> </code></pre>

<p>I didn't find performance gain with the parameter. Instead it lost 
the performance gain from caching, which usually came from running same 
query immediately again because all the needed data have been cached in 
RAM. </p>

<p>Maybe my usage is not proper, or this parameter is not intended to 
work as I expected. </p><p>However if the search range can be limited, the 
performance gain could be substantial, since it's the bad formatted 
addresses took the most time to geocode, and they also often mess up the
 already cached data because the geocoder need to search for states, 
even all my input are in one state and all data can be cached in RAM.</p><p>Thanks!</p><p>By the way, I wrote about my <a href="http://dracodoc.github.io/2015/11/17/Geocoding/" target="_blank">system setup</a> and <a href="http://dracodoc.github.io/2015/11/19/Script-workflow/" target="_blank">work flow</a> in my blog. Wish it can help other novices in geocoding.</p></div></div>