From 36b7533d3b9cce99052241066618667ee661d362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Rodrigo?= Date: Thu, 8 Oct 2020 15:57:16 +0200 Subject: [PATCH] Add timers to trigger function (#1006) Add timer to all trigger refresh functions to help point where the time is spend on update. --- layers/aerodrome_label/update_aerodrome_label_point.sql | 4 ++++ layers/building/update_building.sql | 4 ++++ layers/housenumber/housenumber_centroid.sql | 4 ++++ layers/mountain_peak/update_peak_point.sql | 4 ++++ layers/place/update_city_point.sql | 4 ++++ layers/place/update_continent_point.sql | 4 ++++ layers/place/update_country_point.sql | 4 ++++ layers/place/update_island_point.sql | 4 ++++ layers/place/update_island_polygon.sql | 4 ++++ layers/place/update_state_point.sql | 4 ++++ layers/poi/update_poi_point.sql | 4 ++++ layers/poi/update_poi_polygon.sql | 4 ++++ layers/transportation/update_transportation_merge.sql | 6 +++++- layers/transportation_name/update_transportation_name.sql | 8 ++++++++ layers/water_name/update_marine_point.sql | 4 ++++ layers/waterway/update_important_waterway.sql | 3 +++ 16 files changed, 68 insertions(+), 1 deletion(-) diff --git a/layers/aerodrome_label/update_aerodrome_label_point.sql b/layers/aerodrome_label/update_aerodrome_label_point.sql index b32bfd3..01cea05 100644 --- a/layers/aerodrome_label/update_aerodrome_label_point.sql +++ b/layers/aerodrome_label/update_aerodrome_label_point.sql @@ -56,6 +56,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION aerodrome_label.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh aerodrome_label'; PERFORM update_aerodrome_label_point(false); @@ -63,6 +65,8 @@ BEGIN DELETE FROM aerodrome_label.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM aerodrome_label.updates; + + RAISE LOG 'Refresh aerodrome_label done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/building/update_building.sql b/layers/building/update_building.sql index 99292ca..97d9eb3 100644 --- a/layers/building/update_building.sql +++ b/layers/building/update_building.sql @@ -102,11 +102,15 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION buildings.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh buildings block'; REFRESH MATERIALIZED VIEW osm_building_block_gen1; -- noinspection SqlWithoutWhere DELETE FROM buildings.updates; + + RAISE LOG 'Update buildings block done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/housenumber/housenumber_centroid.sql b/layers/housenumber/housenumber_centroid.sql index f123b4b..aaa70fc 100644 --- a/layers/housenumber/housenumber_centroid.sql +++ b/layers/housenumber/housenumber_centroid.sql @@ -69,6 +69,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION housenumber.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh housenumber'; PERFORM convert_housenumber_point(false); @@ -76,6 +78,8 @@ BEGIN DELETE FROM housenumber.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM housenumber.updates; + + RAISE LOG 'Refresh housenumber done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/mountain_peak/update_peak_point.sql b/layers/mountain_peak/update_peak_point.sql index 67f8e3c..cda77f3 100644 --- a/layers/mountain_peak/update_peak_point.sql +++ b/layers/mountain_peak/update_peak_point.sql @@ -51,6 +51,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION mountain_peak_point.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh mountain_peak_point'; PERFORM update_osm_peak_point(false); @@ -58,6 +60,8 @@ BEGIN DELETE FROM mountain_peak_point.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM mountain_peak_point.updates; + + RAISE LOG 'Refresh mountain_peak_point done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/place/update_city_point.sql b/layers/place/update_city_point.sql index 5c6d9af..6a7ec2a 100644 --- a/layers/place/update_city_point.sql +++ b/layers/place/update_city_point.sql @@ -81,6 +81,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION place_city.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh place_city rank'; PERFORM update_osm_city_point(false); @@ -88,6 +90,8 @@ BEGIN DELETE FROM place_city.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM place_city.updates; + + RAISE LOG 'Refresh place_city done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/place/update_continent_point.sql b/layers/place/update_continent_point.sql index e8875c1..5e944a2 100644 --- a/layers/place/update_continent_point.sql +++ b/layers/place/update_continent_point.sql @@ -51,6 +51,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION place_continent_point.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh place_continent_point'; PERFORM update_osm_continent_point(false); @@ -58,6 +60,8 @@ BEGIN DELETE FROM place_continent_point.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM place_continent_point.updates; + + RAISE LOG 'Refresh place_continent_point done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/place/update_country_point.sql b/layers/place/update_country_point.sql index 2f90ab7..a4cc79d 100644 --- a/layers/place/update_country_point.sql +++ b/layers/place/update_country_point.sql @@ -130,6 +130,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION place_country.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh place_country rank'; PERFORM update_osm_country_point(false); @@ -137,6 +139,8 @@ BEGIN DELETE FROM place_country.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM place_country.updates; + + RAISE LOG 'Refresh place_country done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/place/update_island_point.sql b/layers/place/update_island_point.sql index 4353ddb..7f57d32 100644 --- a/layers/place/update_island_point.sql +++ b/layers/place/update_island_point.sql @@ -51,6 +51,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION place_island_point.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh place_island_point'; PERFORM update_osm_island_point(false); @@ -58,6 +60,8 @@ BEGIN DELETE FROM place_island_point.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM place_island_point.updates; + + RAISE LOG 'Refresh place_island_point done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/place/update_island_polygon.sql b/layers/place/update_island_polygon.sql index e272137..9176674 100644 --- a/layers/place/update_island_polygon.sql +++ b/layers/place/update_island_polygon.sql @@ -57,6 +57,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION place_island_polygon.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh place_island_polygon'; PERFORM update_osm_island_polygon(false); @@ -64,6 +66,8 @@ BEGIN DELETE FROM place_island_polygon.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM place_island_polygon.updates; + + RAISE LOG 'Refresh place_island_polygon done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/place/update_state_point.sql b/layers/place/update_state_point.sql index 49ec303..d1ba1bd 100644 --- a/layers/place/update_state_point.sql +++ b/layers/place/update_state_point.sql @@ -92,6 +92,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION place_state.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh place_state rank'; PERFORM update_osm_state_point(false); @@ -99,6 +101,8 @@ BEGIN DELETE FROM place_state.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM place_state.updates; + + RAISE LOG 'Refresh place_state done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/poi/update_poi_point.sql b/layers/poi/update_poi_point.sql index f266080..b692ece 100644 --- a/layers/poi/update_poi_point.sql +++ b/layers/poi/update_poi_point.sql @@ -70,6 +70,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION poi_point.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh poi_point'; PERFORM update_osm_poi_point(); @@ -78,6 +80,8 @@ BEGIN PERFORM update_osm_poi_point_agg(); -- noinspection SqlWithoutWhere DELETE FROM poi_point.updates; + + RAISE LOG 'Refresh poi_point done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/poi/update_poi_polygon.sql b/layers/poi/update_poi_polygon.sql index 5f02bc6..01cbf1c 100644 --- a/layers/poi/update_poi_polygon.sql +++ b/layers/poi/update_poi_polygon.sql @@ -75,6 +75,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION poi_polygon.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh poi_polygon'; PERFORM update_poi_polygon(false); @@ -82,6 +84,8 @@ BEGIN DELETE FROM poi_polygon.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM poi_polygon.updates; + + RAISE LOG 'Refresh poi_polygon done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/transportation/update_transportation_merge.sql b/layers/transportation/update_transportation_merge.sql index 4691289..0815f05 100644 --- a/layers/transportation/update_transportation_merge.sql +++ b/layers/transportation/update_transportation_merge.sql @@ -135,8 +135,10 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION transportation.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN - RAISE NOTICE 'Refresh transportation'; + RAISE LOG 'Refresh transportation'; REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring; REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen3; REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen4; @@ -145,6 +147,8 @@ BEGIN REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen7; -- noinspection SqlWithoutWhere DELETE FROM transportation.updates; + + RAISE LOG 'Refresh transportation done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/transportation_name/update_transportation_name.sql b/layers/transportation_name/update_transportation_name.sql index 6ae7e97..35cc236 100644 --- a/layers/transportation_name/update_transportation_name.sql +++ b/layers/transportation_name/update_transportation_name.sql @@ -251,6 +251,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION transportation_name.refresh_network() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh transportation_name_network'; PERFORM update_osm_route_member(); @@ -313,6 +315,8 @@ BEGIN DELETE FROM transportation_name.network_changes; -- noinspection SqlWithoutWhere DELETE FROM transportation_name.updates_network; + + RAISE LOG 'Refresh transportation_name network done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; @@ -399,6 +403,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION transportation_name.refresh_name() RETURNS trigger AS $BODY$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh transportation_name'; @@ -553,6 +559,8 @@ BEGIN DROP TABLE name_changes_compact; DELETE FROM transportation_name.name_changes; DELETE FROM transportation_name.updates_name; + + RAISE LOG 'Refresh transportation_name done in %', age(clock_timestamp(), t); RETURN NULL; END; $BODY$ diff --git a/layers/water_name/update_marine_point.sql b/layers/water_name/update_marine_point.sql index ef03cca..5fdbc7a 100644 --- a/layers/water_name/update_marine_point.sql +++ b/layers/water_name/update_marine_point.sql @@ -70,6 +70,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION water_name_marine.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh water_name_marine rank'; PERFORM update_osm_marine_point(false); @@ -77,6 +79,8 @@ BEGIN DELETE FROM water_name_marine.osm_ids; -- noinspection SqlWithoutWhere DELETE FROM water_name_marine.updates; + + RAISE LOG 'Refresh water_name_marine done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql; diff --git a/layers/waterway/update_important_waterway.sql b/layers/waterway/update_important_waterway.sql index d3d8d6f..f608834 100644 --- a/layers/waterway/update_important_waterway.sql +++ b/layers/waterway/update_important_waterway.sql @@ -117,6 +117,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION waterway_important.refresh() RETURNS trigger AS $$ +DECLARE + t TIMESTAMP WITH TIME ZONE := clock_timestamp(); BEGIN RAISE LOG 'Refresh waterway'; @@ -224,6 +226,7 @@ BEGIN -- noinspection SqlWithoutWhere DELETE FROM waterway_important.updates; + RAISE LOG 'Refresh waterway done in %', age(clock_timestamp(), t); RETURN NULL; END; $$ LANGUAGE plpgsql;