From OpenStreetMap Wiki
Jump to navigation Jump to search

This page summarizes the structure of the PostgreSQL/PostGIS database produced by osm2pgsql, that is the main and most used back-end structure in OSM applications and spatial analysis.

The complete and updated documentation is spread in the following sources:

The basic tables are expressed in this simplifyed UML class diagram of the default import style:


There are no explicit reference (no SQL-expressed foreign key) between tables. Tables of the <<main>> datatype have a way field with the geometry, <<slim>> tables don't. The <<dup>> tables are duplicates with enforced type of geometry (roads are enforced to be LineStrings).

A dataflow (production) diagram. The default style is the main answer for  "What does osm2pgsql do?"

Each import style changes tables and fields. Today --slim option is so recommended (not only for performance but also for updates) that we can use it as part of the default.

Dependencies packaging status: repology.org/badge/versions-matrix.

Database analysis