Skip to content

Commit

Permalink
Add timers to trigger function (#1006)
Browse files Browse the repository at this point in the history
Add timer to all trigger refresh functions to help point where the time is spend on update.
  • Loading branch information
frodrigo committed Oct 8, 2020
1 parent e8bf4aa commit 36b7533
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 1 deletion.
4 changes: 4 additions & 0 deletions layers/aerodrome_label/update_aerodrome_label_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
4 changes: 4 additions & 0 deletions layers/building/update_building.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions layers/housenumber/housenumber_centroid.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
4 changes: 4 additions & 0 deletions layers/mountain_peak/update_peak_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
4 changes: 4 additions & 0 deletions layers/place/update_city_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
4 changes: 4 additions & 0 deletions layers/place/update_continent_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
4 changes: 4 additions & 0 deletions layers/place/update_country_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
4 changes: 4 additions & 0 deletions layers/place/update_island_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
4 changes: 4 additions & 0 deletions layers/place/update_island_polygon.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
4 changes: 4 additions & 0 deletions layers/place/update_state_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
4 changes: 4 additions & 0 deletions layers/poi/update_poi_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions layers/poi/update_poi_polygon.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
6 changes: 5 additions & 1 deletion layers/transportation/update_transportation_merge.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions layers/transportation_name/update_transportation_name.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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$
Expand Down
4 changes: 4 additions & 0 deletions layers/water_name/update_marine_point.sql
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ $$ 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);
-- noinspection SqlWithoutWhere
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;
Expand Down
3 changes: 3 additions & 0 deletions layers/waterway/update_important_waterway.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 36b7533

Please sign in to comment.