Why would a map ever need 5,000 upgrades?! Sounds like a major design flaw.
Consider other methods of player scaling such as automatically over time, with hero level, or fewer but larger increments.
Scaling over time or with hero level can be done by using some form of trigger add property system. These work by either using a bug with some item abilities that add properties or by giving various item abilities from a set of item abilities with binary property values (each ability acting as a bit of a binary word). This saves the player issuing orders to research upgrades as well as the data needed for 5,000 upgrades as the triggers can do it all for them.
Larger increments is pretty straight forward. Summate gain and costs of upgrades so as to reduce the number needed. A good rate is every 60 seconds odd which would be 60-100 upgrades for an average long session in this day and age.