[mapserver-users] Class maxscaledenom performance

Jeff McKenna jmckenna at gatewaygeomatics.com
Wed May 31 13:40:45 PDT 2017


Hi Pierre,

This is tricky to debug over email without access to the data, but I'll 
give you some points as to how I normally tackle such problems:

- verify that the issue isn't only limited to WMS, by testing with the 
shp2img commandline utility
(http://mapserver.org/utilities/shp2img.html)

- pass it the problem layername, and also the problem extent (I often 
zoom into the problem area in QGIS, and then click on the "Toggle 
Extents" button below the map and copy the extent values)

   shp2img -m my.map -o ttt.png -all_debug 5 -l layername -e minx miny 
maxx maxy

- analyze the response, and look for a "msPostGISLayerWhichShapes query" 
line, which is actually the query sent to PostGIS by MapServer, such as:

select encode(ST_AsBinary(ST_Force2D("wkb_geometry"),'NDR'),'hex') as 
geom,"ogc_fid" from "layername" where wkb_geometry && 
ST_GeomFromText('POLYGON((-151.4 57.2675406758448,-151.4 
57.4624593241552,-151.14 57.4624593241552,-151.14 
57.2675406758448,-151.4 57.2675406758448))',4326)

- run that same query directly into PostGIS, through the psql 
commandline utility.  It should return a list of geometries at that 
exact extent.

- also run shp2img to see draw speeds for that layer, such as:

   shp2img -m my.map -o ttt.png -map_debug 3 -l layername -e minx miny 
maxx maxy


Some other notes:

- if you need to debug the WMS command generated by QGIS, get the exact 
GetMap problem request, and open it in your browser, and analyze the 
parameters visually in the url : 
https://github.com/mapserver/mapserver/wiki/Get-the-Raw-WMS-Request-Generated-by-QGIS

- follow general good practices:
    - include an EXTENT parameter for each LAYER (this is often helpful 
for WMS requests, to database layers)

    - be sure to set for all database layers:  PROCESSING 
"CLOSE_CONNECTION=DEFER"

    - be sure to have PostGIS create OIDs by default in your databases 
(see the "default_with_oids" setting in postgresql.conf)

    - verify that a "gist" index is set on the geometry column of your 
problem table in PostGIS (view this by describing that table, in psql 
command)

    - verify that the speed issue is not due to a reprojection

- maybe also turn off any labels for that layer/class and re-test

There are likely other points/tips that I follow, but this a start (it's 
hard when I don't have access to your data).  Hope this helps a little 
though.

-jeff


-- 
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/




On 2017-05-31 1:41 PM, pe_lord wrote:
> I have a large dataset (7 500 000 polygons) published in a WMS service stored
> in a PostGIS table (spatial index and attribute index on classitem field). I
> render this layer between 1 and 100 001. I'm trying to manage my scale by
> class as    Mapfile maxscaledenom
> <http://mapserver.gis.umn.edu/es/optimization/mapfile.html#layers>   to show
> between 1: 15 000 000 and 1:100 001 the footprint of data (classitem='BBOX')
> and the data between 1:100 000 and 1:1
> 
> Everything working properly. Except for performance. I have tested with a
> DEBUG 5 to know which element has been evaluated and every element in map
> has been "checked". Causing this lack of performance.
> 
> I have also tried union layers but I find it too much time expensive to
> maintain over a large number of layers.
> 
> Any hints to solve this problem?
> 
> Pierre
> 
> 
> 
> 



More information about the mapserver-users mailing list