Yeah, that can explain why it doesn't work.
Thank you very much:)
On Wed, Nov 6, 2013 at 8:40 AM, Albe Laurenz wrote:
> Jing Fan wrote:
> > On Wed, Nov 6, 2013 at 8:10 AM, Albe Laurenz
> wrote:
> >> Let's assume that we have three nodes A, B and C.
> >> Also, A points to B, B points to C and C
Jing Fan wrote:
> On Wed, Nov 6, 2013 at 8:10 AM, Albe Laurenz wrote:
>> Let's assume that we have three nodes A, B and C.
>> Also, A points to B, B points to C and C points to B.
>>
>> Let's assume that we already generated (A, B, 1) and (A, C, 2)
>> in previous iterations.
>>
>> Then the "recu
But after this iteration, the paths will be:
A B 1
B C 1
C B 1
A C 2
A B 3
in next iteration, the recursive statement will generate (A,C,2), (A,B,3),
and (A,C,4), after the group by, it will still be (A,C,2) and (A,B,3)
so I think it should stop after this iteration.
On Wed, Nov 6, 2013 at 8:10
Jing Fan wrote:
> I am sorry but I still don't understand why it doesn't work. Possibly I
> misunderstand how with
> recursive works?
> In my opinion,
> with recursive table as{
> seed statement
> union
> recursive statement
> }
> In every iteration, It will just generate results from
I am sorry but I still don't understand why it doesn't work. Possibly I
misunderstand how with recursive works?
In my opinion,
with recursive table as{
seed statement
union
recursive statement
}
In every iteration, It will just generate results from seed statement union
recursive statem
Jing Fan wrote:
> If the grouping inside CTE is executed, I don't think it would generate
> result like
>
> src_id | dest_id | dist
> +-+--
>3384 |6236 |1
>3384 |1739 |2
>3384 |6236 |3
>3384 |1739 |4
>3384 |6236 |5
>
If the grouping inside CTE is executed, I don't think it would generate
result like
src_id | dest_id | dist
+-+--
3384 |6236 |1
3384 |1739 |2
3384 |6236 |3
3384 |1739 |4
3384 |6236 |5
3384 |1739 |6
3384 |6
Jing Fan wrote:
> Why the one inside does not do anything? It won't be executed?
It is executed.
It might filter out the occasional row, but if you look at
the example I gave you, you'll see that it won't do anything
to keep it from recursing.
Yours,
Laurenz Albe
--
Sent via pgsql-general mail
Why the one inside does not do anything? It won't be executed?
Best,
Jing
On Tue, Nov 5, 2013 at 8:52 AM, Albe Laurenz wrote:
> Jing Fan wrote:
> > I have two group operations.
> >
> > One is inside the CTE ( union
> >select src_id, dest_id, min(dist) ),
>
Jing Fan wrote:
> I have two group operations.
>
> One is inside the CTE ( union
>select src_id, dest_id, min(dist) ),
> another is outside the CTE.
> Do you mean that even the grouping inside the CTE will be calculated only
> after the CTE has been
> calcula
I have two group operations.
One is inside the CTE ( union
select src_id, dest_id, min(dist) ),
another is outside the CTE.
Do you mean that even the grouping inside the CTE will be calculated only
after the CTE has been calculated?
Thank you very much:)
Best,
Jing Fan wrote:
> 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_i
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
13 matches
Mail list logo