From 7f08414f201b00c9964ca7fd6a5848a6db63fcdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20La=C5=BEa?= Date: Fri, 4 Feb 2022 15:25:47 +0100 Subject: [PATCH] Use equal operator in combination with coalesce() function instead of IS NOT DISTINCT FROM operator. (#1344) Updates on `transporation_name` layer take much more time than before. In 3.13 there had been introduced highway concurrency into `transportation` and `transportation_name` so I expected the update process will take more time but not that much. Because of this it's impossible to use updates on larger areas because the process takes too long. The issue is caused by `IS NOT DISTINCT FROM` operator over `tags` (hstore) columns. I replaced it with `=` operator in combination with `coalesce()` function which returns the same results but in shorter time. --- .../update_transportation_name.sql | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/layers/transportation_name/update_transportation_name.sql b/layers/transportation_name/update_transportation_name.sql index 472ac9b..d04d149 100644 --- a/layers/transportation_name/update_transportation_name.sql +++ b/layers/transportation_name/update_transportation_name.sql @@ -475,7 +475,7 @@ BEGIN FROM osm_transportation_name_linestring AS n USING name_changes_compact AS c WHERE coalesce(n.ref, '') = coalesce(c.ref, '') - AND n.tags IS NOT DISTINCT FROM c.tags + AND coalesce(n.tags, '') = coalesce(c.tags, '') AND n.highway IS NOT DISTINCT FROM c.highway AND n.subclass IS NOT DISTINCT FROM c.subclass AND n.brunnel IS NOT DISTINCT FROM c.brunnel @@ -522,7 +522,7 @@ BEGIN FROM osm_transportation_name_network AS n JOIN name_changes_compact AS c ON coalesce(n.ref, '') = coalesce(c.ref, '') - AND n.tags IS NOT DISTINCT FROM c.tags + AND coalesce(n.tags, '') = coalesce(c.tags, '') AND n.highway IS NOT DISTINCT FROM c.highway AND n.subclass IS NOT DISTINCT FROM c.subclass AND n.brunnel IS NOT DISTINCT FROM c.brunnel @@ -546,7 +546,7 @@ BEGIN USING name_changes_compact AS c WHERE coalesce(n.tags->'name', n.ref) = c.name_ref - AND n.tags IS NOT DISTINCT FROM c.tags + AND coalesce(n.tags, '') = coalesce(c.tags, '') AND n.ref IS NOT DISTINCT FROM c.ref AND n.highway IS NOT DISTINCT FROM c.highway AND n.subclass IS NOT DISTINCT FROM c.subclass @@ -564,7 +564,7 @@ BEGIN FROM osm_transportation_name_linestring_gen1_view AS n JOIN name_changes_compact AS c ON coalesce(n.tags->'name', n.ref) = c.name_ref - AND n.tags IS NOT DISTINCT FROM c.tags + AND coalesce(n.tags, '') = coalesce(c.tags, '') AND n.ref IS NOT DISTINCT FROM c.ref AND n.highway IS NOT DISTINCT FROM c.highway AND n.subclass IS NOT DISTINCT FROM c.subclass @@ -582,7 +582,7 @@ BEGIN USING name_changes_compact AS c WHERE coalesce(n.tags->'name', n.ref) = c.name_ref - AND n.tags IS NOT DISTINCT FROM c.tags + AND coalesce(n.tags, '') = coalesce(c.tags, '') AND n.ref IS NOT DISTINCT FROM c.ref AND n.highway IS NOT DISTINCT FROM c.highway AND n.subclass IS NOT DISTINCT FROM c.subclass @@ -600,7 +600,7 @@ BEGIN FROM osm_transportation_name_linestring_gen2_view AS n JOIN name_changes_compact AS c ON coalesce(n.tags->'name', n.ref) = c.name_ref - AND n.tags IS NOT DISTINCT FROM c.tags + AND coalesce(n.tags, '') = coalesce(c.tags, '') AND n.ref IS NOT DISTINCT FROM c.ref AND n.highway IS NOT DISTINCT FROM c.highway AND n.subclass IS NOT DISTINCT FROM c.subclass @@ -618,7 +618,7 @@ BEGIN USING name_changes_compact AS c WHERE coalesce(n.tags->'name', n.ref) = c.name_ref - AND n.tags IS NOT DISTINCT FROM c.tags + AND coalesce(n.tags, '') = coalesce(c.tags, '') AND n.ref IS NOT DISTINCT FROM c.ref AND n.highway IS NOT DISTINCT FROM c.highway AND n.subclass IS NOT DISTINCT FROM c.subclass @@ -636,7 +636,7 @@ BEGIN FROM osm_transportation_name_linestring_gen3_view AS n JOIN name_changes_compact AS c ON coalesce(n.tags->'name', n.ref) = c.name_ref - AND n.tags IS NOT DISTINCT FROM c.tags + AND coalesce(n.tags, '') = coalesce(c.tags, '') AND n.ref IS NOT DISTINCT FROM c.ref AND n.highway IS NOT DISTINCT FROM c.highway AND n.subclass IS NOT DISTINCT FROM c.subclass @@ -654,7 +654,7 @@ BEGIN USING name_changes_compact AS c WHERE coalesce(n.tags->'name', n.ref) = c.name_ref - AND n.tags IS NOT DISTINCT FROM c.tags + AND coalesce(n.tags, '') = coalesce(c.tags, '') AND n.ref IS NOT DISTINCT FROM c.ref AND n.highway IS NOT DISTINCT FROM c.highway AND n.subclass IS NOT DISTINCT FROM c.subclass @@ -672,7 +672,7 @@ BEGIN FROM osm_transportation_name_linestring_gen4_view AS n JOIN name_changes_compact AS c ON coalesce(n.tags->'name', n.ref) = c.name_ref - AND n.tags IS NOT DISTINCT FROM c.tags + AND coalesce(n.tags, '') = coalesce(c.tags, '') AND n.ref IS NOT DISTINCT FROM c.ref AND n.highway IS NOT DISTINCT FROM c.highway AND n.subclass IS NOT DISTINCT FROM c.subclass