mapserver postgis connection

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Thu Oct 27 11:23:23 PDT 2005


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