modules/interconnectroute: optimised sql calls for orig and term