In this example, we will use an example of a routable shapefile downloaded from GeoFabrik.de - https://www.geofabrik.de/data/shapefiles_routable_vienna.zip. A routable shapefile, as GeoFabrik describes it, is a standard shapefile that contains OSM data preprocessed with routing in mind. This means it contains only road data with lines split at intersections, with some speed limits information, road line lengths, and so on.
We have already addressed importing shapefiles to PostGIS, so you can use a tool of your choice; in this case, I am using osm2pgsql:
shp2pgsql -s 4326 roads pgr.shp_roads | psql -h localhost -p 5434 -U postgres -d mastering_postgis
Once our vector makes it to the database, we need to do some further ...