[postgis-users] MapServer dies when trying to view a layergenerated with PostGIS

Markus Schaber schabi at logix-tt.com
Fri Nov 25 02:22:05 PST 2005


Hi, Mark/Nicolas/Carlo,

Mark Cave-Ayland wrote:

> Bear in mind that OID columns have been removed from tables for a reason;
> mainly because they take up extra space on your hard disk but also because
> OIDs are limited to 32 bits and PostgreSQL must be able to use them
> internally otherwise a lot of things will break.
> 
> Instead of reloading the database, the easiest option is to modify your
> mapserver DATA clause to read "the_geom from bc_voting_areas using unique
> <id>" where <id> is the name of your primary key column.

Another possibility (that works without reloading) is to emulate the oid
column either als SERIAL or BIGSERIAL (depending on the estimated table
size:

test=# alter table blubb add column oid BIGSERIAL UNIQUE;
NOTICE:  ALTER TABLE will create implicit sequence "blubb_oid_seq" for
serial column "blubb.oid"
NOTICE:  ALTER TABLE / ADD UNIQUE will create implicit index
"blubb_oid_key" for table "blubb"
ALTER TABLE
test=# update  blubb set oid=nextval('blubb_oid_seq') where oid is null;
UPDATE 42
test=# ALTER TABLE blubb ALTER oid SET not null;
ALTER TABLE

This gives you an unique column that serves as a primary key oid
replacement including an appropriate index.

As soon as you have "fixed" all your applications, you can remove the
column including sequence and index with another single command:

ALTER TABLE blubb drop column oid;

HTH,
Markus



More information about the postgis-users mailing list