Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to import OSM road data using an SQL file generated by OSM2PO. However I keep getting the following error:

ERROR: out of memory
SQL state: 53200
Detail: Failed on request of size 1048576.

This would suggest there is some memory limit set in the config file to only 1MB. However, I have set my work_mem to 16MB and my shared_mem to 500MB in the config file and reloaded it, plus completely restarted the server. I have also tried manually setting the work_mem for the session.

The really annoying thing is that I have used this process to import a much larger dataset into PostGIS on a Netbook computer with considerably less physical memory. I vaguely remember having to tweak some setting to do it but for the life of me I can't remember what it was and the config file looks like the original factory settings!

So, if it is not the work_mem that is at fault, which setting should I adjust? (I'm using PostGIS 2 and Postgresql 9.1 on Windows 7 32 bit).

Many thanks!

share|improve this question
up vote 4 down vote accepted

Just an assumption:

osm2po builds blocks of 25 data rows per insert for performance reasons and to avoid memory issues. Do you import it in one single Transaction (parameter -1 or --single-transaction)?

share|improve this answer
I just loaded the SQL into pgAdmin and pressed 'Go', so I guess that counts as a single transaction. My inference from your comment its that I should do it from the command line as multiple transactions. – MappaGnosis Sep 16 '12 at 7:20
This is the reason. You had better used the psql commandline tool. – Carsten Sep 16 '12 at 7:21
Just did (well, psql from cmd actually) and it was mind-blowingly fast! Job done. Thanks. – MappaGnosis Sep 16 '12 at 7:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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