[postgis-users] shp2pgsql -I option

Brent Wood pcreso at pcreso.com
Wed Apr 5 22:33:22 PDT 2006



--- Paul Ramsey <pramsey at refractions.net> wrote:

> I just ran using the -I option for the first time, and to my  
> surprise, the utility seemed to create the index *before* loading the  
> data...

Hi Paul,

Thanks for the pointer.

It only creates the primary key, which, being a unique index, should be in
place before any data is loaded, should it not?

I can see why this is not really necessary if you can otherwise guarantee the
uniqueness, but I think it is good practice to ensure any indices created to
ensure data integrity (primary & foreign keys) are in place before any data is
inserted.

Indices which are only created for performance reasons may well be generated
after the data is loaded, but I'm less comfortable about keys.

Which means I (for one) am not unhappy about the perfromance hit from creating
key indices before inserting data :-)  

Cheers,

  Brent

> 
> Bluejay:~/Desktop pramsey$ shp2pgsql -D -i -I dra_tsa_clip.shp  
> dra_tsa_clip | psql
> Shapefile type: Arc
> Postgis type: MULTILINESTRING[2]
> BEGIN
> NOTICE:  CREATE TABLE will create implicit sequence  
> "dra_tsa_clip_gid_seq" for serial column "dra_tsa_clip.gid"
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index  
> "dra_tsa_clip_pkey" for table "dra_tsa_clip"
> CREATE TABLE
>                           addgeometrycolumn
> --------------------------------------------------------------------
> public.dra_tsa_clip.the_geom SRID:-1 TYPE:MULTILINESTRING DIMS:2
> (1 row)
> 
> <... no pause here ...>
> CREATE INDEX
> <... long pause here while data loads ...>
> COMMIT
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 




More information about the postgis-users mailing list