[Geoserver-devel] Geoserver 1.3.0 + PostGIS

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.

This works for me:

http://localhost:8080/geoserver/wfs/GetFeature?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&BBOX=-80.8047090939416,28.4612993732582,-80.80266313910633,28.462329430104333&TYPENAME=topp:major_roads

(this table has 3 geometry columns in it)

What is your "loosebbox" setting on your datastore?

SELECT "oid", "state", encode(AsBinary(force_2d("gen_full"), 'XDR'),'base64'), encode(AsBinary(force_2d("gen_1"), 'XDR'),'base64'), encode(AsBinary(force_2d("gen_2"), 'XDR'),'base64'), encode(AsBinary(force_2d("gen_3"), 'XDR'),'base64'), "interstate", "ushighway", "statehighway", "othername" FROM "public"."major_roads" WHERE "gen_full" && GeometryFromText('POLYGON ((-80.8047090939416 28.4612993732582, -80.8047090939416 28.462329430104333, -80.80266313910633 28.462329430104333, -80.80266313910633 28.4612993732582, -80.8047090939416 28.4612993732582))', 1) AND intersects("gen_full", GeometryFromText('POLYGON ((-80.8047090939416 28.4612993732582, -80.8047090939416 28.462329430104333, -80.80266313910633 28.462329430104333, -80.80266313910633 28.4612993732582, -80.8047090939416 28.4612993732582))', 1))

Quoting David Blasby <dblasby@anonymised.com>:

This works for me:

http://localhost:8080/geoserver/wfs/GetFeature?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&BBOX=-80.8047090939416,28.4612993732582,-80.80266313910633,28.462329430104333&TYPENAME=topp:major_roads

(this table has 3 geometry columns in it)

What is your "loosebbox" setting on your datastore?

loosebbox=true
wkb=true

The WMS and WFS queries should be more or less identical, should they not?
I'll try to replicate this behaviour with different data, but I suspect the WFS
method has a small hole in its logic. Where does the code live that builds the
query?

Thanks,
Cory.

chorner@anonymised.com wrote:

loosebbox=true
wkb=true

The WMS and WFS queries should be more or less identical, should they not? I'll try to replicate this behaviour with different data, but I suspect the WFS
method has a small hole in its logic. Where does the code live that builds the
query?
  

In a number of places, we do have to "backproject" into the data CRS in order to make the query, and we use dave's bbox to 10 sided polygon JTS method
to do it.(so it is a polygon check not a bbox check). Note there was a request recently about a wfs-patch jar in uDig, you may also be tripped up on that, try removing it and then confirm that all the patches have been applied or denied.

Jody