MapServer PostGIS connection: oids an gids to build a query

Paul Ramsey pramsey at REFRACTIONS.NET
Wed May 23 12:17:42 EDT 2007


Mapserver/PostGIS does require a unique integer identifier per row. It 
does not have to be oid, that was used for convenience back when oids 
were always present. Now it will default to the primary key, which are 
almost always integers, or you can tell it which unique key you want to 
use with the "USING UNIQUE" keywords.

This is just Mapserver showing its shapefile-is-my-data-source heritage, 
where the shape file row number was used as a unique key.

Geoserver/uDig also require a unique key for important things (editing 
mostly), they are just a little more general in terms of allowing things 
like strings and other non-integer types.

P.

Gregor Mosheh wrote:
>> I have imported some geographical data (POINT) and their alphanumeric 
>> information in PostgreSQL\PostGIS database. The structure of the 
>> database is WITHOUT OIDS and there are no GIDs in the tables. So PK 
>> and FK are not numerical keys: they are string type keys!.
> 
> Ouch! Mapserver does use the oid, and having an index on the oid is very 
> helpful for performance. (this was the case with 4.8 anyway, has it 
> changed in 4.10?)
> 
> 
>> So MapServer is able only to query data if they have integer ids in 
>> PostGIS structure. WHY ??
> 
> Mapserver/PostGIS queries by coordinate. "select where the_geom 
> intersects" blah blah blah. I don't know about the other GIS software, 
> but a unique identifier field, a primary key, is a pretty standard 
> expectation.
> 
> I'd say to always have numeric fields for both PKs and FKs, but that's 
> just me talking on general principle.
> 


-- 

   Paul Ramsey
   Refractions Research
   http://www.refractions.net
   pramsey at refractions.net
   Phone: 250-383-3022
   Cell: 250-885-0632



More information about the mapserver-users mailing list