diff --git a/data/atlas/13.atlas.vm_observations_mailles.sql b/data/atlas/13.atlas.vm_observations_mailles.sql index 659744fb4..06a3a953e 100644 --- a/data/atlas/13.atlas.vm_observations_mailles.sql +++ b/data/atlas/13.atlas.vm_observations_mailles.sql @@ -1,13 +1,17 @@ CREATE MATERIALIZED VIEW atlas.vm_observations_mailles -AS SELECT obs.cd_ref, -obs.id_observation, -m.id_maille, -m.geojson_maille, -date_part('year', dateobs) as annee -FROM atlas.vm_observations obs -JOIN atlas.t_mailles_territoire m ON st_intersects(obs.the_geom_point, m.the_geom) +AS + SELECT obs.cd_ref, + obs.id_observation, + m.id_maille, + m.geojson_maille, + date_part('year', dateobs) as annee + FROM atlas.vm_observations obs + JOIN atlas.t_mailles_territoire m ON st_intersects(obs.the_geom_point, m.the_geom) WITH DATA; -create unique index on atlas.vm_observations_mailles (id_observation); -create index on atlas.vm_observations_mailles (id_maille); -create index on atlas.vm_observations_mailles (cd_ref); \ No newline at end of file +CREATE UNIQUE INDEX ON atlas.vm_observations_mailles (id_observation); +CREATE INDEX ON atlas.vm_observations_mailles (id_maille); +CREATE INDEX ON atlas.vm_observations_mailles (cd_ref); +CREATE INDEX ON atlas.vm_observations_mailles (geojson_maille); +CREATE INDEX ON atlas.vm_observations_mailles (annee); +CREATE UNIQUE INDEX ON atlas.vm_observations_mailles USING btree(id_observation, geojson_maille) ; \ No newline at end of file diff --git a/data/update/update_vm_index.sql b/data/update/update_vm_index.sql new file mode 100644 index 000000000..2fea70aff --- /dev/null +++ b/data/update/update_vm_index.sql @@ -0,0 +1,7 @@ +BEGIN; + +CREATE INDEX ON atlas.vm_observations_mailles (geojson_maille); +CREATE INDEX ON atlas.vm_observations_mailles (annee); +CREATE UNIQUE INDEX ON atlas.vm_observations_mailles USING btree(id_observation, geojson_maille) ; + +COMMIT; \ No newline at end of file