I have some geospatial data in a PostGIS database. I want to serve that data to a web map app with GeoServer. But every time I add a table as a layer in GeoServer, it creates a duplicate table in PostGIS. For example, when I try to add the table "district_boundary", I end up with a new table, named "district_boundary0" that contains all the data from the original table, duplicated for no apparent reason.

I don't want this! There's no reason to have multiple copies of the same data - and there are lots of reasons not to! So how can I make GeoServer use the table I tell it to and not make its own?

Thanks in advance!

Note: This is probably not a matter of my tables not having the correct structure to be served up. I added the GeoServer-created "district_boundary0" to check this, and just ended up with "district_boundary00"...

  • That's a rather weird situation, lots of people use GeoServer and we never saw this issue. How are you "add" the table? You are not using the "create new type" functionality are you? – Andrea Aime Dec 23 '12 at 14:47
  • Nope. I'm going through Import Data -> PostGIS, which seems like the dev-intended method. My PostGIS DB is a pre-existing install, though, and not the one supplied with the OpenGeo suite; perhaps that's relevant? – Xavier Holt Dec 23 '12 at 15:59
  • Ah, then you should ask on the OpenGeo support forums, the OpenGeo suite does not have a regular open source community, it's more of a commercial product. – Andrea Aime Dec 28 '12 at 10:13
  • @AndreaAime - Realized what I was doing wrong as I was literally in the middle of making a forum post begging for help. Import Data is not the dev-intended method; it's just oddly prominent in the UI. Anyway, thanks for the pointers! – Xavier Holt Jan 20 '13 at 16:40

Turns out "Import Data" doesn't do quite what I thought it did. It's intended for pulling in external data, which it intentionally copies. In short, it:

  1. Copies the data you import into a GeoServer Store, and
  2. Serves that new data from the Store as a Layer.

What I should have done - and the proper way of doing this, it seems - is to instead:

  1. Add the PostGIS DB you want to serve as a GeoServer Store (Stores -> Add New Store)
  2. Add new Layers from that Store (Layers -> Add a New Resource).
  3. *There might be a way to bulk-import your tables as layers when you add the store as well, but I can't confirm this, as I took a very roundabout path.

The reason I was seeing my tables getting copied was that I had already added my PostGIS DB as a store, but was then Import Data-ing into that store, essentially re-adding tables that already existed.

Hope this helps someone else someday!


I can't comment yet, so I have to post this seperately. Using the RESTful interface and Python or other scripting language you can automate that task, which is especially useful if you have hundreds of new layers to add, style, and set preferences for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.