<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="Helvetica, Arial, sans-serif">Paul Ramsey's original
      example was, I would guess, intended to be the shortest, simplest
      example of using recursive functions. Adding more complexity to
      the example will just make it harder to understand.   It was never
      intended to be the basis for a full solution and has a
      fundamentally flawed architecture for that purpose; it confound
      toplogy extraction with network walking.<br>
      <br>
      I would suggest to the original poster that they switch over to
      pg_routing which already has robust solutions to the problems they
      are likely to encounter.  In particular, the network walking
      algorithms use the Boost Graph C++ library are likely to execute
      far faster than anything which can be written in PL/pgSQL or
      python.<br>
      <br>
      Ruven Brooks<br>
      <br>
      <br>
      <br>
    </font>
    <div class="moz-cite-prefix">On 5/8/2022 3:09 PM, Shaozhong SHI
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CA+i5Jwa1c-m5JhbZ7xyT6_zmoki8VRKK=10k5Ag6yZL+vMj25w@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <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"
              moz-do-not-send="true">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"
            moz-do-not-send="true" class="moz-txt-link-freetext">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" moz-do-not-send="true"
                class="moz-txt-link-freetext">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" moz-do-not-send="true"
                class="moz-txt-link-freetext">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"
                moz-do-not-send="true" class="moz-txt-link-freetext">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" moz-do-not-send="true"
                class="moz-txt-link-freetext">postgis-users@lists.osgeo.org</a><br>
              <a
                href="https://lists.osgeo.org/mailman/listinfo/postgis-users"
                rel="noreferrer" target="_blank" moz-do-not-send="true"
                class="moz-txt-link-freetext">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"
            moz-do-not-send="true" class="moz-txt-link-freetext">postgis-users@lists.osgeo.org</a><br>
          <a
            href="https://lists.osgeo.org/mailman/listinfo/postgis-users"
            rel="noreferrer" target="_blank" moz-do-not-send="true"
            class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
        </blockquote>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/postgis-users">https://lists.osgeo.org/mailman/listinfo/postgis-users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>