<div dir="ltr">Any further information on source and target?<div><br></div><div>Can I understand that source means startpoint of a line, and target means an endpoint of a line?</div><div><br></div><div>Regards,</div><div><br></div><div>David</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 23 Apr 2022 at 13:29, Shaozhong SHI <<a href="mailto:shishaozhong@gmail.com">shishaozhong@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 dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 22 Apr 2022 at 22:14, 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>> as St_intersects or recursive query used,</div><div><br></div>The other alternative ( ~ less efficient ) is using a “noded” network table ( "edge_table" ) <div>in the recursive query. ( and don't forget to add indexes to the "source" and "target" columns )</div><div><div><br></div><div><font face="monospace">WITH RECURSIVE walk_network(id, source, target, targetPoint) AS <br> (SELECT <a href="http://et.id" target="_blank">et.id</a>,et.source,et.target,ST_EndPoint(the_geom) as targetPoint <br> FROM edge_table et WHERE <a href="http://et.id" target="_blank">et.id</a> = <b><font color="#0000ff">12</font></b><br> UNION ALL<br> SELECT <a href="http://e.id" target="_blank">e.id</a>, e.source, e.target ,ST_EndPoint(the_geom) as targetPoint<br> FROM edge_table e<br> , walk_network w<br> WHERE w.target = e.source<br> )<br>SELECT ST_AsText(ST_MakeLine(targetPoint))<br>FROM walk_network<br>;<br>+---------------------------------+<br>| st_astext |<br>+---------------------------------+<br>| LINESTRING(4 2,3 2,2 1,1 1,0 0) |<br>+---------------------------------+<br>(1 row)</font><br></div></div><div><font face="monospace"><br></font></div><div><font face="monospace">regards,</font></div><div><font face="monospace"> Imre</font></div></div></blockquote><div><br></div><div>I will have a close look.</div><div><br></div><div>With the use of <span style="font-family:monospace"> </span><span style="font-family:monospace">WHERE w.target = e.source, it probably avoided time consuming computation of ST_DWithin.</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Would </span><span style="font-family:monospace">WHERE w.target = e.source force the Postgres to use index-scan?</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">If so, that might well be a more efficient way to do it.</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">Regards,</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">David</span></div></div></div></div></div>
</blockquote></div>