Some of the `update_osm_${LAYER}`-functions, which are executed by triggers on updates, execute an UPDATE statement on the same tables that have these triggers. This causes the trigger functions `flag` and `store` to run multiple times for one record.
For instance, if I add log in the trigger functions and run an INSERT on `osm_housenumber_point`, this output is generated:
```
NOTICE: Store
NOTICE: Flag
NOTICE: Refresh housenumber
NOTICE: Flag
NOTICE: Store
NOTICE: Flag
INSERT 0 1
```
If we limit the triggers from executing if they are called from another trigger using `pg_trigger_depth() < 1`, the triggers will only be triggered once per record:
```
NOTICE: Store
NOTICE: Flag
NOTICE: Refresh housenumber
INSERT 0 1
```
This will prevent redunant executions and might improve update performance.
Co-authored-by: Patrik Sylve <patrik.sylve@t-kartor.com>
Improved update performance of water_name layer
- Implemented diff updates for update_water_lakeline.sql and update_water_point.sql
- Unified update_water_lakeline.sql and update_water_point.sql to update_water_name.sql
- Refactored IDs to be unique in water_name_marine.osm_ids
- Restricted updates to INSERT and UPDATE operations during water_name_marine.refresh
- Added analyze statements before update queries during water_name_marine.refresh