So I know that in solidity for larger data we wouldn't use contract to save the data but rather we'd use some kind of external database. But I'm not sure how large is too large and what would happen if we do save large amount of data just for the sake of user view.
So for for example a mapping mapping(uint256 => uint256) public Vals
with a thousand uint256
values. would that be too much of data to save just for users view? How should i know if it actually is too much data or not?
Saving a 10k long mapping values just for the sake of users view.
You can save as much data as you want, but you should know it's exorbitantly expensive.
Quick breakdown:
1 uint256 = 1 storage slot.
1 fresh storage slot write = 20,000 gas.
Now, 20,000 gas is about 25 cents on Ethereum Mainnet.
For 10,000 slots? That's $2,500. I did not even mention storage read costs (at some point you will read them, right?). Is it feasible? Maybe. You need to analyze whether the costs outweigh the benefits.
Want to explore cheaper networks? Check out: CryptoNeur's Gas Fees Calculator.
Finally, consider storing big data on IPFS and storing the IPFS path on the blockchain.