From 01bc5319b1ead24505f6781cd4f30c2694ffe3a9 Mon Sep 17 00:00:00 2001 From: Francesco Frassinelli Date: Sat, 19 Oct 2024 19:43:48 +0200 Subject: [PATCH] Avoid COALESCE in WHERE clauses --- project.mml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/project.mml b/project.mml index 55975e712..48266f67e 100644 --- a/project.mml +++ b/project.mml @@ -1279,7 +1279,7 @@ Layer: COALESCE((tags->('name:it')), (tags->('name:en')), name, '') as name FROM planet_osm_polygon WHERE way && !bbox! - AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL + AND (((tags->('name:it')) IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND name IS NOT NULL) AND boundary = 'administrative' AND admin_level = '2' AND way_area > 100*POW(!scale_denominator!*0.001*0.28,2) @@ -1304,7 +1304,7 @@ Layer: round(ascii(md5(osm_id::text)) / 55) AS dir -- base direction factor on geometry to be consistent across metatiles FROM planet_osm_point WHERE place IN ('city', 'town', 'village', 'hamlet') - AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL + AND (((tags->('name:it')) IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND name IS NOT NULL) AND tags @> 'capital=>yes' ORDER BY population DESC ) AS capital_names @@ -1325,7 +1325,7 @@ Layer: ref FROM planet_osm_polygon WHERE ST_PointOnSurface(way) && !bbox! - AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL + AND (((tags->('name:it')) IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND name IS NOT NULL) AND boundary = 'administrative' AND admin_level = '4' AND way_area > 3000*POW(!scale_denominator!*0.001*0.28,2) @@ -1371,7 +1371,7 @@ Layer: ) AS score FROM planet_osm_point WHERE place IN ('city', 'town') - AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL + AND (((tags->('name:it')) IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND name IS NOT NULL) AND NOT (tags @> 'capital=>yes') ) as p ORDER BY score DESC, length(name) DESC, name @@ -1392,10 +1392,10 @@ Layer: COALESCE((tags->('name:it')), (tags->('name:en')), name, '') as name FROM planet_osm_point WHERE place IN ('village', 'hamlet') - AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL + AND (((tags->('name:it')) IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND name IS NOT NULL) AND NOT tags @> 'capital=>yes' OR (place IN ('suburb', 'quarter', 'neighbourhood', 'isolated_dwelling', 'farm') - ) AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL + ) AND (((tags->('name:it')) IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND name IS NOT NULL) ORDER BY CASE WHEN place = 'suburb' THEN 7 WHEN place = 'village' THEN 6 @@ -1507,7 +1507,7 @@ Layer: COALESCE((tags->('name:it')), (tags->('name:en')), name, '') as name FROM planet_osm_polygon WHERE ST_PointOnSurface(way) && !bbox! - AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL + AND (((tags->('name:it')) IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND name IS NOT NULL) AND man_made = 'bridge' AND way_area > 125*POW(!scale_denominator!*0.001*0.28,2) AND way_area < 768000*POW(!scale_denominator!*0.001*0.28,2) @@ -1528,7 +1528,7 @@ Layer: admin_level FROM planet_osm_polygon WHERE ST_PointOnSurface(way) && !bbox! - AND COALESCE((tags->('name:it')), (tags->('name:en')), name, NULL) IS NOT NULL + AND (((tags->('name:it')) IS NOT NULL AND (tags->('name:en')) IS NOT NULL AND name IS NOT NULL) AND boundary = 'administrative' AND admin_level IN ('5', '6') AND way_area > 12000*POW(!scale_denominator!*0.001*0.28,2)