I use GeoServer and PostGIS and OpenLayers to show the data.<br>For one page I&#39;m using a WFS layer. and I filter on address.<br><br>The user first need to select an address. This is done with an AJAX call and the adresID and the location (X, Y) are returned.<br>

I zoom to that location and change my filter.<br>This is my initial set-up of my layer, an addressID of -1 doesn&#39;t exists so it starts with just the baselayer:<br><pre style="font-family:courier new,monospace" id="line1">

<span>var myLayer = new OpenLayers.Layer.Vector(&quot;tmp&quot;, { 
<span id="line16"></span>  displayInLayerSwitcher: true,
<span id="line17"></span>  strategies: [new OpenLayers.Strategy.BBOX()],
<span id="line18"></span>  filter: new OpenLayers.Filter.Comparison({ 
<span id="line19"></span>          type: OpenLayers.Filter.Comparison.EQUAL_TO,
<span id="line20"></span>          property: &quot;_adresid&quot;,
<span id="line21"></span>          value: &quot;-1&quot;}),
<span id="line22"></span>  styleMap: new OpenLayers.StyleMap(),
<span id="line23"></span>  protocol: new OpenLayers.Protocol.WFS({ 
<span id="line24"></span>    url: &quot;.../wfs&quot;,
<span id="line25"></span>    featureType: &quot;myName&quot;,
<span id="line26"></span>    srsName: &quot;EPSG:3857&quot;,
<span id="line27"></span>    geometryName: &quot;geomgoogle&quot;
<span id="line28"></span>  })
<span id="line29"></span>});</span></pre>And this is the method I call after the user selects an address:<br><pre id="line1"><font style="font-family:courier new,monospace" size="2">function changeFilter(newValue, x, y)
<span id="line109"></span>{ 
<span id="line110"></span>  myLayer.destroyFeatures();
<span id="line111"></span>  filter = new OpenLayers.Filter.Logical({ 
<span id="line114"></span>    type: OpenLayers.Filter.Logical.AND, 
<span id="line115"></span>    filters: [ 
<span id="line116"></span>      new OpenLayers.Filter.Comparison({ 
<span id="line117"></span>          type: OpenLayers.Filter.Comparison.EQUAL_TO, 
<span id="line118"></span>          property: &quot;_adresid&quot;, 
<span id="line119"></span>          value: newValue 
<span id="line120"></span>      }), 
<span id="line121"></span>      new OpenLayers.Filter.Spatial({ 
<span id="line122"></span>          type: OpenLayers.Filter.Spatial.BBOX, 
<span id="line123"></span>          value: new OpenLayers.Bounds(x-50, y-50, x+50, y+50), 
<span id="line124"></span>          projection: &quot;EPSG:3857&quot; 
<span id="line125"></span>      }) 
<span id="line126"></span>  ] 
<span id="line127"></span>}); 
<span id="line128"></span>  myLayer.filter = filter;
<span id="line129"></span>  </font><font style="font-family:courier new,monospace" size="2">myLayer</font><font style="font-family:courier new,monospace" size="2">.refresh({force: true});<br>  showAttributes();<br></font><span><font style="font-family:courier new,monospace" size="2">}<br>

</font><br></span></pre>This is working great, but is does take a very long time: about 7-10 seconds.<br>The result are just a few features: 3-10<br><br>Of course I have an index in the database on _adresid and a spatial index.<br>

<br>What else can I do to speed up this filter?<br><br>Thanks,<br>
<br>
Paul<br><br>--<br>Organizing the International Open Source GIS conference 2012 in The Netherlands:<br><a href="http://www.mapwindow.org/conference/2012/" target="_blank">http://www.mapwindow.org/conference/2012/</a>