diff pkg/octree/cache.go @ 1131:2e6b47cdb2ca

Store octrees along with sounding results The extra table with 1:1-relation to sounding results was a provisorial solution with the intention to make it easily removable.
author Tom Gottfried <tom@intevation.de>
date Wed, 07 Nov 2018 17:54:50 +0100
parents a244b18cb916
children 19a04b150b6c
line wrap: on
line diff
--- a/pkg/octree/cache.go	Wed Nov 07 17:54:31 2018 +0100
+++ b/pkg/octree/cache.go	Wed Nov 07 17:54:50 2018 +0100
@@ -45,19 +45,19 @@
 
 const (
 	fetchOctreeSQL = `
-SELECT checksum, octree_index
-FROM waterway.octrees ot
-JOIN waterway.sounding_results sr ON ot.sounding_result_id = sr.id
-WHERE sr.bottleneck_id = $1 AND sr.date_info = $2::date
+SELECT octree_checksum, octree_index
+FROM waterway.sounding_results
+WHERE bottleneck_id = $1 AND date_info = $2::date
+  AND octree_checksum NOT NULL AND octree_index NOT NULL
 `
 	checkOctreeSQL = `
 SELECT CASE
-  WHEN checksum = $3 THEN NULL
-  ELSE ot.octree_index
+  WHEN octree_checksum = $3 THEN NULL
+  ELSE octree_index
   END
-FROM waterway.octrees ot
-JOIN waterway.sounding_results sr ON ot.sounding_result_id = sr.id
-WHERE sr.bottleneck_id = $1 AND sr.date_info = $2::date
+FROM waterway.sounding_results
+WHERE bottleneck_id = $1 AND date_info = $2::date
+  AND octree_checksum NOT NULL AND octree_index NOT NULL
 `
 )