mapserver postgis connection
Stephen Woodbridge
woodbri at SWOODBRIDGE.COM
Fri Oct 28 07:37:02 PDT 2005
Frans Knibbe wrote:
> An interesting thread.
> Shouldn't the connection step go faster if you have FastCGI enabled in
> the MapServer?
I'm not an "expert" on this but it seems from previous posts that the
connection for postGIS/postgres is very small and does not benefit
significantly from FastCGI which adds a lot of complexity to the
infrastructure.
> Also, I wonder if PostGIS would improve relative to shapefile if you
> have many concurrent users requesting the same data...
Both postGIS and shapefiles have to access disk files, both (assuming
they are setup correctly) have spatial indexes. shapefiles just have
less overhead so if the application is just straight get the data from
the stores and render it, shapefiles will be faster.
As soon as you need to do joins and spatial operations or more
complicated stuff in postGIS you get an advantage. In many cases you
just can NOT do it with shapefiles, like thematic rendering based on a
join. So a hybrid approach works best for me. Most of my layers are in
shapefiles for speed and a few are in postGIS for functional features of
that environment.
The best thing to do is make some tests based on your application. You
should do that anyway to check the performance tuning and identify the
bottle necks to performance so you can tune those for better performance.
-Steve W.
> Regards,
>
> Frans
>
> Stephen Woodbridge wrote:
>
>> Frances Collier wrote:
>>
>>> Hello,
>>>
>>>
>>>
>>> I’ve been trying to find out what exactly Mapserver gets back from
>>> Postgis when querying the tables. I haven’t found this to be
>>> documented anywhere. Does Postgis return a shape file, layer, or
>>> simply data rows? The reason I’m asking is that I noticed a huge time
>>> difference between connecting to Postgis and simply calling the shape
>>> files – with the Postgis being significantly slower
>>>
>>>
>>>
>>> I’d appreciate any knowledge, advice, and/or direction.
>>
>>
>>
>> Frances,
>>
>> PostGIS IS slower than shapefiles because:
>>
>> 1) You have to make a network of local connection to the database
>> which include some kind of authentication.
>> 2) You have to do a query to fetch some data
>> 3) The data needs to be transformed from its native PostGIS format
>> into whatever mapserver uses internally
>> 4) all the data has to packaged up into packets to transfer from the
>> server to the client (mapserver)
>> 5) probably other stuff too
>>
>> So why would anyone want to use it?
>>
>> Well you can do lots of cool GIS like things with it. You data might
>> be stored there for other purposes, like it is bing dynamically
>> updated by other process. You need to do thematic mapping, etc, etc
>>
>> Should you put all or any of your data in PostGIS?
>>
>> Depends on your need. If all you data is static data and you are only
>> display maps of it then probably not. Use shapefiles as they are most
>> efficient. You can take a hybrid approach of having some static layer
>> in shapefiles and some other layers in postGIS.
>>
>> If you are doing queries the only look at a small percentage of the
>> data then postGIS queries can be optimized maybe to speed things up.
>> If you are just recalling all you data when zoomed out maybe you need
>> another layer where the data in simplified for that.
>>
>> -Steve W.
>> http://imaptools.com
>>
>>
>
More information about the MapServer-users
mailing list