178 | | |
| 181 | For France |
| 182 | {{{ |
| 183 | #!sql |
| 184 | drop table if exists rht.rht_150; |
| 185 | create table rht.rht_150 as select id_drain, gid, st_buffer(the_geom,150) as the_geom from rht.rht_bretagne; ---12578 ms |
| 186 | CREATE INDEX indexrht_150 ON rht.rht_150 |
| 187 | USING GIST ( the_geom GIST_GEOMETRY_OPS ); |
| 188 | CREATE INDEX indexrht150 |
| 189 | ON rht.rht_150 |
| 190 | USING btree (id_drain); |
| 191 | |
| 192 | drop table if exists rht.rht_bdcarthage; |
| 193 | create table rht.rht_bdcarthage as |
| 194 | select distinct on (id_bdcarth) id_bdcarth, min(distance) as distance, id_drain from ( |
| 195 | select r.id_drain, |
| 196 | id_bdcarth, |
| 197 | ST_Distance(r.the_geom,bdc.the_geom) as distance |
| 198 | from rht.rht r join rht.rht_150 rht150 on r.id_drain=rht150.id_drain |
| 199 | join bd_carthage2011.troncon_hydrographique bdc on st_intersects(bdc.the_geom,rht150.the_geom) |
| 200 | where nature !='Aqueduc, conduite forcée' and num_superp !=1 ) as toto |
| 201 | group by id_bdcarth, distance, id_drain |
| 202 | order by id_bdcarth ; ---22519 lines 86526ms |
| 203 | |
| 204 | select count(*) from bd_carthage2011.troncon_hydrographique ---528422 lines |
| 205 | select count(*) from rht.rht ---114601 lines |
| 206 | select count(*) from rht.rht_bdcarthage --- 22519 lines |
| 207 | }}} |