Custom osm way priority by id on large scale

Hello! In our project, we are developing customized routing for biking and walking. Our clients provide us with a set of routes that need the highest priority. Currently, there are almost 40,000 ways (in OSM ID format) that we must prioritize.

Previously, I modified the OSM file using Osmosis to add a custom tag (e.g., clientWay:true) and then checked for it in the Access and Speed parsers. However, this approach was quite cumbersome, especially for large graphs (we are working with data for all of Europe).

Do you have any alternative ideas? Let’s assume I have all 40,000 way IDs stored in a database that is accessible by the parsers. I suspect that querying the database from the Access and Speed parsers would significantly slow down graph building, and keeping such a large amount of data in memory is not feasible (especially since this number may grow significantly in the future).

If you are willing to edit osm pbf or shape file and then convert it to your oen osm , osm.pbf. This is fastest way to do it if it is once a week process.

40k way IDs with 4bytes each would make 160kilo(!)Bytes, even if there were ten times more in the future the memory requirement would be less than 2MB. This should be no problem at all?