Hi Guys,
I've been hitting a Geoserver instance running PostGIS and noticed a strange behaviour. For a small bounding box (containing few features), I would expect a WMS and WFS request to behave very similarly, and be comparable in speed.
WMS:
/geoserver/wms?request=GetMap&layers=abc:parcel_centroids&bbox=-80.8047090939416,28.4612993732582,-80.80266313910633,28.462329430104333&width=500&height=500&srs=EPSG:4326&styles=default_point&Format=image/png
WFS:
/geoserver/wfs/GetFeature?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&BBOX=-80.8047090939416,28.4612993732582,-80.80266313910633,28.462329430104333&TYPENAME=abc:parcel_centroids
I'm watching the postgres statement log and see the following:
WMS:
DECLARE JDBC_CURS_72 CURSOR FOR SELECT "LPID", bytea(AsBinary(force_2d("geom"), 'XDR')) FROM "public"."parcel_centroids" WHERE "geom" && GeometryFromText('POLYGON ((-80.8047090939416 28.4612993732582, -80.8047090939416 28.462329430104333, -80.80266313910633 28.462329430104333, -80.80266313910633 28.4612993732582, -80.8047090939416 28.4612993732582))', 1);
FETCH FORWARD 200 FROM JDBC_CURS_72
(this is executed twice for some reason)
WFS:
DECLARE JDBC_CURS_74 CURSOR FOR SELECT "LPID", "NPID", "FIPS", bytea(AsBinary(force_2d("geom"), 'XDR')) FROM "public"."parcel_centroids";
FETCH FORWARD 200 FROM JDBC_CURS_74
For the WFS, the FETCH FORWARD statement repeats a few thousand times, while for WMS it only appears once. WMS takes 2 or 3 seconds while WFS takes closer to a minute (there are ~1 million features and the bounding box only contains about 12). The speed of the WMS is evidence that the database is well indexed. Why isn't the WFS query using a bounding box to filter its results the same way the WMS query does?
Thanks,
Cory.