From 2ef6a19149c492fe29904c41899cc668b625bb73 Mon Sep 17 00:00:00 2001 From: stirringhalo Date: Wed, 4 Jan 2017 01:03:00 -0500 Subject: [PATCH] when create materialized do so without data, better logging --- layers/transportation_name/merge_highways.sql | 9 +++++---- layers/water_name/water_lakeline.sql | 3 ++- layers/water_name/water_point.sql | 3 ++- layers/waterway/merge_waterway.sql | 9 +++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/layers/transportation_name/merge_highways.sql b/layers/transportation_name/merge_highways.sql index 76debce7..59b75f81 100644 --- a/layers/transportation_name/merge_highways.sql +++ b/layers/transportation_name/merge_highways.sql @@ -29,7 +29,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring AS ( WHERE (name <> '' OR ref <> '') AND NULLIF(highway, '') IS NOT NULL GROUP BY name, highway, ref ) AS highway_union -); +) WITH NO DATA; CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_geometry_idx ON osm_transportation_name_linestring USING gist(geometry); -- etldoc: osm_transportation_name_linestring -> osm_transportation_name_linestring_gen1 @@ -37,7 +37,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen1 AS ( SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order FROM osm_transportation_name_linestring WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 8000 -); +) WITH NO DATA; CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_geometry_idx ON osm_transportation_name_linestring_gen1 USING gist(geometry); -- etldoc: osm_transportation_name_linestring_gen1 -> osm_transportation_name_linestring_gen2 @@ -45,7 +45,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen2 AS ( SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order FROM osm_transportation_name_linestring_gen1 WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 14000 -); +) WITH NO DATA; CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_geometry_idx ON osm_transportation_name_linestring_gen2 USING gist(geometry); -- etldoc: osm_transportation_name_linestring_gen2 -> osm_transportation_name_linestring_gen3 @@ -53,7 +53,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_linestring_gen3 AS ( SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order FROM osm_transportation_name_linestring_gen2 WHERE highway = 'motorway' AND ST_Length(geometry) > 20000 -); +) WITH NO DATA; CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_geometry_idx ON osm_transportation_name_linestring_gen3 USING gist(geometry); --- Triggers @@ -61,6 +61,7 @@ CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_geometry_idx CREATE OR REPLACE FUNCTION refresh_osm_transportation_name_linestring() RETURNS trigger AS $BODY$ BEGIN + RAISE LOG 'Refresh osm_highway_linestring based tables'; REFRESH MATERIALIZED VIEW osm_transportation_name_linestring; REFRESH MATERIALIZED VIEW osm_transportation_name_linestring_gen1; REFRESH MATERIALIZED VIEW osm_transportation_name_linestring_gen2; diff --git a/layers/water_name/water_lakeline.sql b/layers/water_name/water_lakeline.sql index dcc96e91..bf45b89d 100644 --- a/layers/water_name/water_lakeline.sql +++ b/layers/water_name/water_lakeline.sql @@ -8,7 +8,7 @@ CREATE MATERIALIZED VIEW osm_water_lakeline AS ( FROM osm_water_polygon AS wp INNER JOIN lake_centerline ll ON wp.osm_id = ll.osm_id WHERE wp.name <> '' -); +) WITH NO DATA; CREATE INDEX IF NOT EXISTS osm_water_lakeline_geometry_idx ON osm_water_lakeline USING gist(geometry); -- Triggers @@ -16,6 +16,7 @@ CREATE INDEX IF NOT EXISTS osm_water_lakeline_geometry_idx ON osm_water_lakeline CREATE OR REPLACE FUNCTION refresh_osm_water_lakeline() RETURNS trigger AS $BODY$ BEGIN + RAISE LOG 'Refresh osm_water_lakeline based tables'; REFRESH MATERIALIZED VIEW osm_water_lakeline; RETURN null; END; diff --git a/layers/water_name/water_point.sql b/layers/water_name/water_point.sql index f736dc94..4d84ae92 100644 --- a/layers/water_name/water_point.sql +++ b/layers/water_name/water_point.sql @@ -8,7 +8,7 @@ CREATE MATERIALIZED VIEW osm_water_point AS ( FROM osm_water_polygon AS wp LEFT JOIN lake_centerline ll ON wp.osm_id = ll.osm_id WHERE ll.osm_id IS NULL AND wp.name <> '' -); +) WITH NO DATA; CREATE INDEX IF NOT EXISTS osm_water_point_geometry_idx ON osm_water_point USING gist (geometry); -- Triggers @@ -16,6 +16,7 @@ CREATE INDEX IF NOT EXISTS osm_water_point_geometry_idx ON osm_water_point USING CREATE OR REPLACE FUNCTION refresh_osm_water_point() RETURNS trigger AS $BODY$ BEGIN + RAISE LOG 'Refresh osm_water polygon based tables'; REFRESH MATERIALIZED VIEW osm_water_point; RETURN null; END; diff --git a/layers/waterway/merge_waterway.sql b/layers/waterway/merge_waterway.sql index 7b3c5dbc..efb2d718 100644 --- a/layers/waterway/merge_waterway.sql +++ b/layers/waterway/merge_waterway.sql @@ -16,7 +16,7 @@ CREATE MATERIALIZED VIEW osm_important_waterway_linestring AS ( WHERE name <> '' AND waterway = 'river' GROUP BY name ) AS waterway_union -); +) WITH NO DATA; CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_geometry_idx ON osm_important_waterway_linestring USING gist(geometry); -- etldoc: osm_important_waterway_linestring -> osm_important_waterway_linestring_gen1 @@ -24,7 +24,7 @@ CREATE MATERIALIZED VIEW osm_important_waterway_linestring_gen1 AS ( SELECT ST_Simplify(geometry, 60) AS geometry, name FROM osm_important_waterway_linestring WHERE ST_Length(geometry) > 1000 -); +) WITH NO DATA; CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_gen1_geometry_idx ON osm_important_waterway_linestring_gen1 USING gist(geometry); -- etldoc: osm_important_waterway_linestring_gen1 -> osm_important_waterway_linestring_gen2 @@ -32,7 +32,7 @@ CREATE MATERIALIZED VIEW osm_important_waterway_linestring_gen2 AS ( SELECT ST_Simplify(geometry, 100) AS geometry, name FROM osm_important_waterway_linestring_gen1 WHERE ST_Length(geometry) > 4000 -); +) WITH NO DATA; CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_gen2_geometry_idx ON osm_important_waterway_linestring_gen2 USING gist(geometry); -- etldoc: osm_important_waterway_linestring_gen2 -> osm_important_waterway_linestring_gen3 @@ -40,7 +40,7 @@ CREATE MATERIALIZED VIEW osm_important_waterway_linestring_gen3 AS ( SELECT ST_Simplify(geometry, 200) AS geometry, name FROM osm_important_waterway_linestring_gen2 WHERE ST_Length(geometry) > 8000 -); +) WITH NO DATA; CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_gen3_geometry_idx ON osm_important_waterway_linestring_gen3 USING gist(geometry); --- Triggers @@ -48,6 +48,7 @@ CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_gen3_geometry_idx O CREATE OR REPLACE FUNCTION refresh_osm_important_waterway_linestring() RETURNS trigger AS $BODY$ BEGIN + RAISE LOG 'Refresh osm_waterway_linestring based tables'; REFRESH MATERIALIZED VIEW osm_important_waterway_linestring; REFRESH MATERIALIZED VIEW osm_important_waterway_linestring_gen1; REFRESH MATERIALIZED VIEW osm_important_waterway_linestring_gen2;