conditional/regular expressions are slow

Paul Ramsey pramsey at REFRACTIONS.NET
Sat Aug 6 08:21:39 PDT 2005


Douglas,

Sounds like you are trying to draw *just* the big highways at certain  
scales.  Using the feature code as a filter.  This is not mapserver  
being slow, this is mapserver processing a huge amount of data.  You  
need to think about how mapserver has to answer your request (use  
this shape file and show me the big highways).  Since it has no  
attribute indexes, it has to open the file and for every shape in the  
current view (it does have spatial indexes) it reads the shape and  
checks the feature code.  It probably examines 100 ordinary road  
shapes for every 1 highway shape it draws for you.  Not efficient at  
all.

The answer is your open 2 below.  Pre-process your data so that  
mapserver can do the bare minimum of work for each rendering pass.   
There is no point in having mapserver read 100000 features that it is  
not even going to draw.

Paul


On 5-Aug-05, at 5:48 PM, Dylan Keon wrote:

> On 08/05/2005 05:07 PM, Douglass Davis wrote:
>
>> Also, the highways are numbered A1.* and A2.* for the big highways  
>> A3.* for the smaller highways etc.  So, What I do is use regular  
>> expressions like:
>>      EXPRESSION /A[12].*/
>>      EXPRESSION /A[3].*/
>> This appears to be slowing things down.  What's the best way to  
>> handle this?
>>
>
> I haven't tested this, but I wonder if /^A[12]/ and /^A3/ would be  
> any faster.
>
>
>> Three ideas I have for speeding this up are:
>> 1. Export the shapefile to PostGIS where it can be indexed correctly
>> 2. Separate the shapefile into multiple shapefiles somehow.  One  
>> file would have big cities, the next file would have medium size  
>> cities and big cities etc.
>> 3. Somehow add more indexing to the shapefile.
>>
>
> Try creating spatial indexes on your shapefiles if you haven't done  
> so already.  Use the shptree utility that is packaged with MapServer.
>
> --Dylan
>



More information about the MapServer-users mailing list