faster obs_meta generation, use better formatting and handle NULL boundary_id
This commit is contained in:
parent
56fa19118b
commit
ebc27dbbb7
@ -397,16 +397,17 @@ DECLARE
|
||||
BEGIN
|
||||
|
||||
EXECUTE
|
||||
format('SELECT numer_colname, numer_geomref_colname, numer_tablename
|
||||
FROM observatory.obs_meta
|
||||
WHERE geom_id = %L
|
||||
AND numer_id = %L
|
||||
AND (numer_timespan = %L OR (%L = ''''))
|
||||
ORDER BY numer_timespan DESC
|
||||
LIMIT 1 ',
|
||||
boundary_id, measure_id, coalesce(time_span, ''), coalesce(time_span, ''))
|
||||
|
||||
INTO colname, data_geoid_colname, target_table;
|
||||
$query$
|
||||
SELECT numer_colname, numer_geomref_colname, numer_tablename
|
||||
FROM observatory.obs_meta
|
||||
WHERE (geom_id = $1 OR ($1 = ''))
|
||||
AND numer_id = $2
|
||||
AND (numer_timespan = $3 OR ($3 = ''))
|
||||
ORDER BY geom_weight DESC, numer_timespan DESC
|
||||
LIMIT 1
|
||||
$query$
|
||||
INTO colname, data_geoid_colname, target_table
|
||||
USING COALESCE(boundary_id, ''), measure_id, COALESCE(time_span, '');
|
||||
|
||||
RAISE DEBUG 'target_table %, colname %', target_table, colname;
|
||||
|
||||
|
4
src/pg/test/fixtures/load_fixtures.sql
vendored
4
src/pg/test/fixtures/load_fixtures.sql
vendored
@ -25303,8 +25303,8 @@ WHERE numer_c.id = numer_data_ct.column_id
|
||||
AND geom_geomref_ct.table_id = geom_t.id
|
||||
AND geom_geom_ct.column_id = geom_c.id
|
||||
AND geom_geom_ct.table_id = geom_t.id
|
||||
AND geom_c.type ILIKE 'geometry'
|
||||
AND numer_c.type NOT ILIKE 'geometry'
|
||||
AND geom_c.type LIKE 'Geometry'
|
||||
AND numer_c.type NOT LIKE 'Geometry'
|
||||
AND numer_t.id != geom_t.id
|
||||
AND numer_c.id != geomref_c.id
|
||||
AND unit_tag.type = 'unit'
|
||||
|
Loading…
Reference in New Issue
Block a user