11# Using Update Mode
22
3- Running in experimental Update mode enables using osm2pgsql's ` --append `
4- option.
3+ Running with ` --update ` enables using osm2pgsql's ` --append ` option to load a second
4+ input file. The PgOSM Flex functionality uses ` --update create ` and ` --update append ` .
5+ See the discussion in [ #275 ] ( https://github.com/rustprooflabs/pgosm-flex/issues/275 )
6+ for more context behind the intent for this feature.
7+
8+ Using ` --update append ` requires the initial import used ` --update create ` . Attempting
9+ to use ` --update append ` without first using ` --update create ` results in the error:
10+ "ERROR: This database is not updatable. To create an updatable database use --slim (without --drop)."
11+
12+
13+ If your goal is to easily refresh the data for a single, standard region/sub-region
14+ you should investigate the [ ` --replication ` feature] ( /replication.md ) . Using
15+ replication is the easier and more efficient way to maintain data.
16+
517
618> Note: This is ** not** the ` --append ` option that existed in PgOSM Flex 0.6.3 and prior.
719
20+ ## Example
21+
822The following command uses ` --update create ` to load the ` district-of-columbia `
9- sub-region.
23+ sub-region. This example assumes you have set the environment variables and
24+ have ran the docker container as shown in the [ Quick Start] ( quick-start.md ) section.
1025
1126``` bash
1227docker exec -it \
1328 pgosm python3 docker/pgosm_flex.py \
1429 --ram=8 \
1530 --region=north-america/us \
1631 --subregion=district-of-columbia \
17- --skip-nested \
1832 --update create
1933```
2034
21- The following loads a second sub-region (` new-hampshire ` ) using ` --update append ` .
35+ The following loads a second sub-region (` maryland ` ) using ` --update append ` .
2236
2337``` bash
2438time docker exec -it \
2539 pgosm python3 docker/pgosm_flex.py \
2640 --ram=8 \
2741 --region=north-america/us \
28- --subregion=new-hampshire \
29- --skip-nested --skip-dump \
42+ --subregion=maryland \
3043 --update append
31-
32- ...
33-
34- 2022-12-27 10:14:26,792:INFO:pgosm-flex:helpers:2022-12-27 10:14:26 osm2pgsql took 1420s (23m 40s) overall.
35- 2022-12-27 10:14:26,832:INFO:pgosm-flex:pgosm_flex:osm2pgsql completed
36- 2022-12-27 10:14:26,832:INFO:pgosm-flex:pgosm_flex:Running with --update append: Skipping post-processing SQL
37- 2022-12-27 10:14:26,832:INFO:pgosm-flex:pgosm_flex:Skipping pg_dump
38- 2022-12-27 10:14:26,832:INFO:pgosm-flex:pgosm_flex:PgOSM Flex complete!
39-
40- real 23m47.564s
41- user 0m0.083s
42- sys 0m0.025s
43-
4444```
4545
46- It seems to work, new output at the end: ` Skipping post-processing SQL ` .
47-
48- Verified that both New Hampshire and D.C. regions were loaded in ` osm.place_polygon ` .
4946
5047
5148## Smaller test
5249
53- Put the following into ` ~/pgosm-data/extracts/colorado-extract.json ` :
50+ > This section has notes that probably belong elsewhere but I'm leaving them here for now.
51+ > They were initially helpful for testing the logic for this functionality.
52+
53+ Put the following into ` ~/pgosm-data/extracts/colorado-extract.json ` .
5454
5555``` json
5656{
@@ -81,14 +81,14 @@ Put the following into `~/pgosm-data/extracts/colorado-extract.json`:
8181```
8282
8383
84- Create Boulder and Longmont extracts.
84+ Create Boulder and Longmont extracts using ` osmium extract ` .
8585
86- ```
86+ ``` bash
8787osmium extract -c extracts/colorado-extracts.json colorado-2022-12-27.osm.pbf
8888```
8989
9090
91- ```
91+ ``` bash
9292ryanlambert@tag201:~ /pgosm-data$ ls -alh | grep boulder
9393-rw-rw-r-- 1 ryanlambert ryanlambert 2.4M Dec 27 14:31 colorado-boulder-latest.osm.pbf
9494ryanlambert@tag201:~ /pgosm-data$ ls -alh | grep longmont
@@ -97,24 +97,24 @@ ryanlambert@tag201:~/pgosm-data$ ls -alh | grep longmont
9797
9898Takes 11 seconds.
9999
100- ```
101- time docker exec -it \
100+ ``` bash
101+ docker exec -it \
102102 pgosm python3 docker/pgosm_flex.py \
103103 --ram=8 \
104104 --region=north-america/us \
105105 --subregion=colorado-longmont --input-file colorado-longmont-latest.osm.pbf \
106- --skip-dump -- update create
106+ --update create
107107```
108108
109109Takes 2 minutes.
110110
111111
112- ```
113- time docker exec -it \
112+ ``` bash
113+ docker exec -it \
114114 pgosm python3 docker/pgosm_flex.py \
115115 --ram=8 \
116116 --region=north-america/us \
117117 --subregion=colorado-boulder --input-file colorado-boulder-latest.osm.pbf \
118- --skip-dump -- update append
118+ --update append
119119```
120120
0 commit comments