From 2999aea561d2fc84799df023d89fc0814d7b97c6 Mon Sep 17 00:00:00 2001 From: LB <78799392+lbam@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:27:35 +0200 Subject: [PATCH] Simplify query for layer meetbout_zaksnelheid (#527) Now two nested SELECTs instead of three. The left outer join is now an inner join, which doesn't matter because (1) each meetbout has some meting associated with it, and (2) if one didn't, it wouldn't match any of the classes defined for this layer. Also removed the manual version control comment. --- meetbouten.map | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/meetbouten.map b/meetbouten.map index 2dcc2864..2bf05b32 100644 --- a/meetbouten.map +++ b/meetbouten.map @@ -1,17 +1,3 @@ -#============================================================================== -# -# meetbouten.map -# doel: serveren van Meetbouten gegevens -# -#============================================================================== -# -# naam datum wijziging -# ------------------ ---------- ----------------------------------------- -# S. Zaat 28-01-2016 schepping -# S. Preeker 04-02-2016 bekeken -# -#============================================================================== - MAP NAME "Meetbouten" INCLUDE "header.inc" @@ -148,22 +134,18 @@ MAP GROUP "meetbouten_zaksnelheid" INCLUDE "connection/dataservices.inc" DATA "geometrie FROM ( - SELECT mbt.*, mtn.zakkingssnelheid - FROM public.meetbouten_meetbouten mbt - LEFT JOIN - (SELECT * - FROM public.meetbouten_metingen - WHERE - (datum, hoort_bij_meetbout_id) IN - ( - SELECT MAX(mt.datum) AS datum - , mt.hoort_bij_meetbout_id - FROM public.meetbouten_metingen mt - GROUP BY mt.hoort_bij_meetbout_id - ) - ) mtn - ON mtn.hoort_bij_meetbout_id=mbt.identificatie) - as subquery USING srid=28992 USING UNIQUE identificatie" + SELECT mbt.*, mtn.zakkingssnelheid FROM + public.meetbouten_meetbouten mbt, public.meetbouten_metingen mtn + WHERE + mtn.hoort_bij_meetbout_id = mbt.identificatie + AND + (mtn.datum, mtn.hoort_bij_meetbout_id) IN ( + SELECT max(datum), hoort_bij_meetbout_id FROM + public.meetbouten_metingen + GROUP BY hoort_bij_meetbout_id + ) + ) + AS subquery USING srid=28992 USING UNIQUE identificatie" TYPE POINT MINSCALEDENOM 100 MAXSCALEDENOM 5001