<div dir="ltr"><div>> encountered more than 2 answers/outputs.</div><div>> It may get confused and cannot finish. <br></div><div><br></div>You can find a very good SQL "graph" tutorial/basics - with examples.<br><a href="https://docs.yugabyte.com/preview/api/ysql/the-sql-language/with-clause/traversing-general-graphs/">https://docs.yugabyte.com/preview/api/ysql/the-sql-language/with-clause/traversing-general-graphs/</a><br><br>So you have to decide - what type of graph you have<br>- Undirected cyclic graph<br>- Directed cyclic graph<br>- Directed acyclic graph<br>- Rooted tree ( a specialization of the directed acyclic graph. )<br><br>If you know the "type of your graph network" ( and the name of your problem ) Then it will be easier to find an algorithm.<div>You can ask your DB team - or You can search the internet.</div><div><br></div><div>But without minimal example data - not so easy to help you.</div><div>IMHO: Your link ["Network Walking in PostGIS"(2010)] is a very simple "Rooted tree" example.<br></div><div><br></div><div>Regards,</div><div> Imre</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Shaozhong SHI <<a href="mailto:shishaozhong@gmail.com">shishaozhong@gmail.com</a>> ezt írta (időpont: 2022. máj. 8., V, 22:10):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi, Imre,<div><br></div><div>There is a possibility that the Walk the Network (<a href="http://blog.cleverelephant.ca/2010/07/network-walking-in-postgis.html?m=1&msclkid=5cf8409ecf0a11ecbbe2896397a25c2b" target="_blank">Network Walking in PostGIS · Paul Ramsey (cleverelephant.ca)</a>) encountered more than 2 answers/outputs.</div><div><br></div><div>It may get confused and cannot finish. </div><div><br></div><div>Can we build something in the script to report these and should there be an exception, allow it to complete the task?</div><div><br></div><div>Regards,</div><div><br></div><div>David</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 8 May 2022 at 00:59, Imre Samu <<a href="mailto:pella.samu@gmail.com" target="_blank">pella.samu@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi David,</div><div>> There is a loop of recursive query. It runs at a point where it stops.</div><div>>Can anyone provide pointers how to solve this problem or work around?<br></div><div><br></div><div>Please share "this" recursive query;</div><div><br></div><div>My guess: Probably you have a "forever/endless loop" in your data; <b><font color="#0000ff">so you have to LIMIT the recursive part ;</font></b></div><div><br></div><div>related links :</div><div>1.) with limiting "<span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">depth</span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">" ( </span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">where</span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit"> depth </span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit"><</span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit"> </span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1000 )</span></div><div>"Prevent infinite loop in recursive query in Postgresql"</div><div><a href="https://stackoverflow.com/questions/51025607/prevent-infinite-loop-in-recursive-query-in-postgresql" target="_blank">https://stackoverflow.com/questions/51025607/prevent-infinite-loop-in-recursive-query-in-postgresql</a><br></div><div>2.) with LIMITING clause</div><div><a href="https://www.cybertec-postgresql.com/en/recursive-queries-postgresql/" target="_blank">https://www.cybertec-postgresql.com/en/recursive-queries-postgresql/</a> <br></div><i>"This example also demonstrates how <font color="#0000ff">an endless loop can be avoided with a LIMIT clause </font>on the parent query."</i><div><br></div><div>Regards,</div><div> Imre</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Shaozhong SHI <<a href="mailto:shishaozhong@gmail.com" target="_blank">shishaozhong@gmail.com</a>> ezt írta (időpont: 2022. máj. 7., Szo, 15:23):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">There is a loop of recursive query. It runs at a point where it stops.<div><br></div><div>This error turned up.- ERROR: invalid memory alloc request size 1073741824</div><div><br></div><div>Can anyone provide pointers how to solve this problem or work around?</div><div><br></div><div>Regards,</div><div><br></div><div>David</div></div></div>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
</blockquote></div>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
</blockquote></div>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
</blockquote></div>