Your description implies a misunderstanding of how it works.
The gas-fee is a function of two variables:
- The number of gas units required for the transaction to execute
- The price (in wei-ether) of each gas unit
The first variable derives solely from the number of machine operations (opcodes) executed during the transaction, and the types of those operations (different types consume different amounts of gas).
The second variable is configured by you before sending the transaction, and it is therefore the only "gambling factor" in the process, which impacts how fast your transaction will be executed.
It is true that before sending the transaction you also configure the gas-limit, but that's just an extra precautionary measure provided in order for you to protect yourself from executing some inefficient contract function which consumes a lot more gas units than what you're willing to spend.
This parameter is NOT the first variable mentioned above.
It just has to be equal to or higher than that variable, otherwise the transaction will not be executed.
Furthermore, you will not "lose it all when it gets rejected":
- When you configure a gas-limit lower than the number of gas units required for the transaction to execute, the transaction will be rejected and your account will not be charged anything
- When you configure a gas-limit equal to or higher than than the number of gas units required for executing the transaction, the transaction will be executed and your account will be charged by your gas-price times the number of gas units which were actually used, even if your gas-limit was higher than that number