It depends on what the facility is, and how long it will take to get the next level. If you hit the upgrade all button, it upgrades all facilities that are in the queue. So, you can put them on hold for a turn or two at 1 turn left waiting on a tech level, and then save the upgrade costs.
Research path is entirely dependant on the game settings and conditions.