-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#884 create latest mat view for intersection layer as well
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
gis/centreline/sql/create_matview_centreline_intersection_point_latest.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE MATERIALIZED VIEW gis_core.centreline_intersection_point_latest AS | ||
|
||
SELECT * | ||
FROM gis_core.centreline_intersection_point | ||
WHERE version_date = (SELECT MAX(version_date) FROM gis_core.centreline_intersection_point); | ||
|
||
CREATE TRIGGER refresh_trigger | ||
AFTER INSERT OR UPDATE OR DELETE | ||
ON gis_core.centreline_intersection_point | ||
FOR EACH STATEMENT | ||
EXECUTE PROCEDURE gis_core.centreline_intersection_point_latest_trigger(); | ||
|
||
CREATE INDEX gis_core_centreline_intersection_point_latest_geom ON gis_core.centreline_intersection_point_latest USING gist (geom); | ||
|
||
ALTER MATERIALIZED VIEW gis_core.centreline_intersection_point_latest OWNER TO gis_admins; | ||
|
||
GRANT SELECT ON gis_core.centreline_intersection_point_latest TO bdit_humans; | ||
|
||
COMMENT ON MATERIALIZED VIEW gis_core.centreline_intersection_point_latest IS 'Materialized view containing the latest version of centreline intersection point, derived from gis_core.centreline_intersection_point.' | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE MATERIALIZED VIEW gis_core.intersection_latest AS | ||
|
||
SELECT * | ||
FROM gis_core.intersection | ||
WHERE version_date = (SELECT MAX(version_date) FROM gis_core.intersection); | ||
|
||
CREATE TRIGGER refresh_trigger | ||
AFTER INSERT OR UPDATE OR DELETE | ||
ON gis_core.intersection | ||
FOR EACH STATEMENT | ||
EXECUTE PROCEDURE gis_core.intersection_latest_trigger(); | ||
|
||
CREATE INDEX gis_core_intersection_latest_geom ON gis_core.intersection_latest USING gist (geom); | ||
|
||
ALTER MATERIALIZED VIEW gis_core.intersection_latest OWNER TO gis_admins; | ||
|
||
GRANT SELECT ON gis_core.intersection_latest TO bdit_humans; | ||
|
||
COMMENT ON MATERIALIZED VIEW gis_core.intersection_latest IS 'Materialized view containing the latest version of intersection , derived from gis_core.intersection.' | ||
17 changes: 17 additions & 0 deletions
17
gis/centreline/sql/create_trigger_centreline_intersection_point_latest.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CREATE OR REPLACE FUNCTION gis_core.centreline_intersection_point_latest_trigger() | ||
RETURNS trigger | ||
LANGUAGE 'plpgsql' | ||
COST 100 | ||
VOLATILE NOT LEAKPROOF SECURITY DEFINER | ||
AS $BODY$ | ||
BEGIN | ||
|
||
REFRESH MATERIALIZED VIEW gis_core.centreline_intersection_point_latest; | ||
RETURN NULL; | ||
|
||
END; | ||
$BODY$; | ||
|
||
ALTER FUNCTION gis_core.centreline_intersection_point_latest_trigger() OWNER TO gis_admins; | ||
|
||
COMMENT ON FUNCTION gis_core.centreline_intersection_point_latest_trigger() IS 'Trigger fuction that refreshes the centreline_intersection_point_latest mat view after an update.'; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CREATE OR REPLACE FUNCTION gis_core.intersection_latest_trigger() | ||
RETURNS trigger | ||
LANGUAGE 'plpgsql' | ||
COST 100 | ||
VOLATILE NOT LEAKPROOF SECURITY DEFINER | ||
AS $BODY$ | ||
BEGIN | ||
|
||
REFRESH MATERIALIZED VIEW gis_core.intersection_latest; | ||
RETURN NULL; | ||
|
||
END; | ||
$BODY$; | ||
|
||
ALTER FUNCTION gis_core.intersection_latest_trigger() OWNER TO gis_admins; | ||
|
||
COMMENT ON FUNCTION gis_core.intersection_latest_trigger() IS 'Trigger fuction that refreshes the intersection_latest mat view after an update.'; | ||