As a possible alternative, Imposm creates a relation_member tables that make it fast and efficient to do whatever you want with routes (and even sites!) with a trivial JOIN: you know which elements belongs to which relation and which relation contains which element.<br>
It's a bit like the planet_osm_rels with an index on members ids.<br>
Something similar could be implemented in Osm2pgsql, more versatile than only focusing on routes.<br>
From the doc:<br>
<a href="https://imposm.org/docs/imposm3/latest/relations.html">https://imposm.org/docs/imposm3/latest/relations.html</a><br>
relation_member¶<br>
<br>
The relation_member table type inserts each member of the relation as a separate row. The relation_member has access to the role and type value of each member. You can also import tags from the relation and from the member node, way or relation.<br>
<br>
Yves <br>
<br>
Yves