WITH RECURSIVE doesn't work properly for me
От
Jing Fan
Тема
WITH RECURSIVE doesn't work properly for me
Дата
Msg-id
CA+BectkZpJ_G6Ku-+bdAcRJSMKzmYfa9cy2fQFFG2EgraseoMg@mail.gmail.com
Список
Дерево обсуждения
WITH RECURSIVE doesn't work properly for me Jing Fan <fanjing09@gmail.com>
Re: WITH RECURSIVE doesn't work properly for me Albe Laurenz <laurenz.albe@wien.gv.at>
Re: WITH RECURSIVE doesn't work properly for me Jing Fan <fanjing09@gmail.com>
Re: WITH RECURSIVE doesn't work properly for me Albe Laurenz <laurenz.albe@wien.gv.at>
Re: WITH RECURSIVE doesn't work properly for me Jing Fan <fanjing09@gmail.com>
Re: WITH RECURSIVE doesn't work properly for me Albe Laurenz <laurenz.albe@wien.gv.at>
Re: WITH RECURSIVE doesn't work properly for me Jing Fan <fanjing09@gmail.com>
Re: WITH RECURSIVE doesn't work properly for me Albe Laurenz <laurenz.albe@wien.gv.at>
Re: WITH RECURSIVE doesn't work properly for me Jing Fan <fanjing09@gmail.com>
Re: WITH RECURSIVE doesn't work properly for me Albe Laurenz <laurenz.albe@wien.gv.at>
Re: WITH RECURSIVE doesn't work properly for me Jing Fan <fanjing09@gmail.com>
Re: WITH RECURSIVE doesn't work properly for me Albe Laurenz <laurenz.albe@wien.gv.at>
Re: WITH RECURSIVE doesn't work properly for me Jing Fan <fanjing09@gmail.com>
I use following command to get a shortest-path query:
with recursive paths( src_id, dest_id, dist) as(
select n1,n2,1
from nodes
union
select src_id, dest_id, min(dist)
from ( select paths.src_id as src_id, nodes.n2 as dest_id, paths.dist+1 as dist
from paths, nodes
where paths.dest_id=nodes.n1
and paths.src_id<>nodes.n2
) as Temp
group by src_id, dest_id
)
select paths.src_id, paths.dest_id, min(dist)
from paths
group by 1,2;
It seems that this query goes into infinite loops and finally run out of disk space. However, I testrf every iteration seperately and found that it will converge after 3-4 iterations. I wonder where is the problem. Could anyone help with it? The attatchment is the test data.
Thank you very much:)
В списке pgsql-general по дате отправления