Changes between Version 55 and Version 56 of Noeud - parcours RHT
- Timestamp:
- Jan 9, 2012 5:41:13 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Noeud - parcours RHT
v55 v56 286 286 }}} 287 287 288 Mise à jour de la table rht _topology288 Mise à jour de la table rhtvs2 289 289 {{{ 290 290 #!sql … … 329 329 CREATE INDEX chemin_btee_indexvs2 ON rht.rhtvs2 USING btree(chemin); --27688 ms 330 330 VACUUM ANALYSE rht.rhtvs2; 331 CREATE INDEX chemin_gist_index ON rht.rht _topologyUSING GIST (chemin); -- fait planter mon serveur....331 CREATE INDEX chemin_gist_index ON rht.rhtvs2 USING GIST (chemin); -- fait planter mon serveur.... 332 332 SELECT * from rht.rhtvs2 where chemin <@ '212340'; -- tronçon source de la Vilaine -- 35641 333 333 SELECT chemin from rht.rhtvs2 where chemin <@ '212340' limit 1 334 334 -- La distance source est la distance mer maximale de tous les chemins possibles en ne prenant que le dernier tronçon du chemin. 335 335 Select max(dmer) from rht.rhtvs2 where id_drain in ( 336 Select cast(ltree2text(subpath(chemin, -1, 1))as integer) as chenin_id_drain from rht.rht _topologywhere chemin ~ '*.212340.*');336 Select cast(ltree2text(subpath(chemin, -1, 1))as integer) as chenin_id_drain from rht.rhtvs2 where chemin ~ '*.212340.*'); 337 337 -- travail sur les noeuds source et le recalcul des distances mer et source (voir fichier doc joint) 338 338 -- en pratique les distances sont calculées a partir du milieu de chaque tronçon, elles prennent par contre toute la distance des tronçons autre que le tronçon considéré. … … 346 346 ); 347 347 348 alter table rht.rht _topologyadd column dsource numeric;348 alter table rht.rhtvs2 add column dsource numeric; 349 349 -- voir schéma pour explications 350 350 … … 384 384 -- pour essai pour voir ce qui se passe dans la requête 385 385 -- je l'ai pas lancé ! 386 SELECT 212340, MAX(dmer+length/2) as dmer FROM rht.rht _topologyWHERE id_drain IN (387 SELECT CAST(ltree2text(subpath(chemin, -1, 1))as integer) FROM rht.rht _topologywhere chemin ~ '*.212340.*' )386 SELECT 212340, MAX(dmer+length/2) as dmer FROM rht.rhtvs2 WHERE id_drain IN ( 387 SELECT CAST(ltree2text(subpath(chemin, -1, 1))as integer) FROM rht.rhtvs2 where chemin ~ '*.212340.*' ) 388 388 -- il faudra enlever la dmer de 212340 389 389 … … 401 401 -- pour essai pour voir ce qui se passe dans la requête 402 402 403 SELECT 212340, MAX(dmer+length/2) as dmer FROM rht.rht _topologyWHERE id_drain IN (404 SELECT CAST(ltree2text(subpath(chemin, -1, 1))as integer) FROM rht.rht _topologywhere chemin ~ '*.212340.*' )405 406 407 select * from rht.rht _topologyt join rht.distance_source s on s.id_drain=t.id_drain where distance is null; --323403 SELECT 212340, MAX(dmer+length/2) as dmer FROM rht.rhtvs2 WHERE id_drain IN ( 404 SELECT CAST(ltree2text(subpath(chemin, -1, 1))as integer) FROM rht.rhtvs2 where chemin ~ '*.212340.*' ) 405 406 407 select * from rht.rhtvs2 t join rht.distance_source s on s.id_drain=t.id_drain where distance is null; --323 408 408 409 409 -- il faudra enlever la dmer de 212340 … … 415 415 -- mise à jour des distances source dans la table distance source (il faut encore enlever dmer) 416 416 update rht.distance_source d set distance_source = sub.distance_source from ( 417 select t.id_drain, distance-dmer as distance_source from rht.distance_source s join rht.rht _topologyt on s.id_drain=t.id_drain) as sub417 select t.id_drain, distance-dmer as distance_source from rht.distance_source s join rht.rhtvs2 t on s.id_drain=t.id_drain) as sub 418 418 where sub.id_drain=d.id_drain; --57067 419 419 420 -- copie des valeurs de distance_source dans dsource de la table rht.rht _topology421 update rht.rht _topologyt set dsource=distance_source420 -- copie des valeurs de distance_source dans dsource de la table rht.rhtvs2 421 update rht.rhtvs2 t set dsource=distance_source 422 422 from rht.distance_source d where d.id_drain=t.id_drain; --57067 423 423 424 424 -- mise à jour des distances_source (pour l'instant valeurs = null) pour les noeuds source (pour les derniers c'est la moitié de la longueur du segment) 425 update rht.rht _topologyt set dsource=length/2 where noeudsource;425 update rht.rhtvs2 t set dsource=length/2 where noeudsource; 426 426 -- nombre de 427 select count(*)as count, noeudsource from rht.rht _topologywhere dsource is null group by noeudsource;427 select count(*)as count, noeudsource from rht.rhtvs2 where dsource is null group by noeudsource; 428 428 }}} 429 429 … … 440 440 SELECT regexp_split_to_array('hello.world', E'\\.+'); 441 441 */ 442 SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') from rht.rht _topologywhere chemin <@ '212340';442 SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') from rht.rhtvs2 where chemin <@ '212340'; 443 443 444 444 /* … … 460 460 -- pour convertir un vecteur en table 461 461 select unpack(vecteurchemin) from 462 (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rht _topologywhere chemin <@ '212340' limit 1) as sub462 (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rhtvs2 where chemin <@ '212340' limit 1) as sub 463 463 -- j'avais pas vu il y a déjà une fonction magique unest... 464 464 select cast(unnest(vecteurchemin) as integer) as chemin_id_drain from 465 (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rht _topologywhere chemin <@ '212340' limit 1) as sub465 (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rhtvs2 where chemin <@ '212340' limit 1) as sub 466 466 -- Fonction qui renvoit les identifiants uniques des tronçons en amont d'un ouvrage 467 467 … … 470 470 RETURNS SETOF integer AS $$ 471 471 select cast(unnest(vecteurchemin) as integer) as chemin_id_drain from 472 (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rht _topologywhere chemin <@ text2ltree(cast ($1 as text)) limit 1) as sub;472 (SELECT regexp_split_to_array(ltree2text(chemin),E'\\.+') as vecteurchemin from rht.rhtvs2 where chemin <@ text2ltree(cast ($1 as text)) limit 1) as sub; 473 473 $$ LANGUAGE sql STRICT IMMUTABLE; 474 474