Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a GetFeature WFS query in Geoserver (looking for features within a polygon) but all I actually want is the total number of features. Is there a way of just returning this info (in the hope that the query will run a little faster) rather than all the records?

The query is returning over 10,000 features so I hope it would make a difference if possible.

Many thanks, Steve

share|improve this question
up vote 7 down vote accepted

You can set the parameter resultType to "hits" and you will get the number of features in the query similar to the count() function in SQL.

HTTP Get request example:


HTTP Post request example with a filter:

<wfs:GetFeature service="WFS" version="1.1.0"
  <wfs:Query typeName="topp:states">
       <ogc:FeatureId fid="states.3"/>
share|improve this answer
Thanks taudorf - that worked a treat. Interestingly, the search time (running the search directly in geoserver) took 18 seconds - as oppose to 41 seconds when returning just one field per feature. – user8262 Jan 7 '13 at 13:50

Provided you are using WFS 1.1 you can set resultype=hits and this will return just the number of records that match your query.

I can't recall if GeoServer has back ported this to 1.0 but the standard doesn't support it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.