When running osm2psql on an existing database I get an error
osm2pgsql -v -d gis -a -s -G --flat-nodes ./nodes.cache --number-processes 8 ./thailand.osm.pbf
Output is :
Allocating memory for dense node cache
Allocating dense node cache in one big chunk
Allocating memory for sparse node cache
Sharing dense sparse
Node-cache: cache=800MB, maxblocks=12800*65536, allocation method=11
Mid: loading persistent node cache from ./nodes.cache
Mid: pgsql, cache=800
SQL command failed: ERROR: relation "planet_osm_ways" does not exist
LINE 1: ...REPARE mark_ways_by_node(int8) AS SELECT id FROM planet_osm...
^
Full query: PREPARE mark_ways_by_node(int8) AS SELECT id FROM planet_osm_ways WHERE nodes && ARRAY[$1];
PREPARE mark_ways_by_rel(int8) AS SELECT id FROM planet_osm_ways WHERE id IN ( SELECT unnest(parts[way_off+1:rel_off]) FROM planet_osm_rels WHERE id = $1 );
node cache: stored: 0(0.00%), storage efficiency: 0.00% (dense blocks: 0, sparse nodes: 0), hit rate: 0.00%
Osm2pgsql failed due to ERROR: Executing SQL
Displaying current existing tables in postgres gives:
gis=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------------------+-------+-------
public | planet_osm_line | table | osm
public | planet_osm_point | table | osm
public | planet_osm_polygon | table | osm
public | planet_osm_roads | table | osm
public | spatial_ref_sys | table | osm
(5 rows)
As I understand it, the -s option (slim mode) is supposed to create 3 new tables : https://github.com/openstreetmap/osm2pgsql/blob/master/docs/pgsql.md#database-layout
planet_osm_nodes
planet_osm_ways
planet_osm_rels
It's like osm2psql tries to access those tables before creating them at first.
PS: I also tried without the flat-nodes option
osm2pgsql -v -d gis -a -s -G -C 40000 --number-processes 8 ./thailand.osm.pbf
with same result.