DATA "the_geom from the_table"Very simple, but: how does Mapserver know what primary key to use in queries? And what SRID to use when creating the bounding box selection for drawing maps? The answer is, it asks the database for that information. With two extra queries. Every time it processes the layer.
However, if you are explicit about your unique key and SRID in configuration, Mapserver can, and does, skip querying the back-end for that information.
DATA "the_geom from the_table using unique gid using srid=4326"Also, if you have more than one PostGIS layer in your map file, you should turn on the Mapserver connection pool, even if you're not running in FastCGI mode. That's because the pool will allow all the layers to reuse the same connection. If you have have seven PostGIS layers, at 15ms per connection, that's 90ms saved (you still pay 15ms for the first connection).
Add this line at the end of each PostGIS layer to tell Mapserver to leave the connection open for future layers:
PROCESSING "CLOSE_CONNECTION=DEFER"Go fast, fast, fast!

8 comments:
Interesting, hopefully you'll take into account a patch you wrote for making sure maxfeatures is sent to the database backend :-) . I was wondering lately how difficult it would be to have Mapserver do paging for WFS requests using a vendor-specific parameter e.g. startposition next to maxfeatures (like the OGC catalog interface). I often limit my requests for OpenLayers to 100 featurses, but every user asks how do I get the next 100 records .... and now I have to disappoint them.
Hey Paul, another question for you as a PostGIS/Mapserver expert, today I was using a PropertyIsLike filter with only a wildcard in it (pretty dumb I must admit :-) ), and PostgreSQL would not return any rows which had null strings in them. Is that normal behaviour, can it be influenced somehow?
So SELECT * FROM VIEW WHERE MYCOLUMN1 LIKE 'Bla%' AND MYCOLUMN2 LIKE '%' would not return any of the rows which had a null value for MYCOLUMN2.
I ended up rewriting my WFS request not to include a PropertyIsLike filter if it contained only a wildcard.
I can see why it would fail. LIKE '%" implies you'll take any string. But null isn't a string. It's the absence of a string. You could "update mytable set mycolumn = '' where mycolumn is null" if you like.
Hmm, I don't like updating NULL values to empty strings ...
Would something like this work?
SELECT * FROM VIEW WHERE MYCOLUMN1 LIKE 'Bla%' AND COALESCE(MYCOLUMN2, '') LIKE '%'
@bart: the next WFS revision (1.2, or 2.0, I can't remember offhand), which will be a joint OGC/ISO IS, will support paging of results.
For now, I agree that a vendor specific parameter would be the way to go in MapServer...filing a ticket is welcome!
@Tom: yeah I've heard something similar about the next WFS release, good news, finally I would say, ticket filed, http://trac.osgeo.org/mapserver/ticket/2799
But I wonder how difficult it would be to implement this in the Mapserver codebase, seeing how weak the current support for maxfeatures is.
Also, we've asked ESRI if there is any way with the ArcSDE API to specify that you're only interested in X records (maxfeatures) and they say there is no such thing ..... how weird.
Bart, we have implemented limited paging support in GeoServer using maxFeatures and offset. It works for PostGIS only atm, and I'm not sure it's hooked with WFS as well (it was for KML generation, so it's certainly hooked with WFS), anyways, if you ask on the users like certainly someone will be able to give you a better overview.
Hey Paul, interesting on the tips, but if i can take you back, i dont know if i should be doing this on your blog coz the mailing lists are not helping, i am having trouble connecting mapserver with postgis using the
CONNECTIONTYPE postgis
NAME "kenya_shape"
CONNECTION "user=postgres password=postgres dbname=postgis host=localhost"
nothing is being displayed on the chameleon client but when reading DATA directly from a shapefile everything is displayed ok :( any help? great work on ua blog :)
Post a Comment