1

I have two approaches to save data on blockchain, but I don't know which one is the best from time as well as space complexity perspectives. I want to store key value pairs in a table.

  • First Approach: save each key value pair in their own respective rows in the table and iterate over them for updating.

  • Second Approach: create only one row in the table, which holds a hash map containing the key value pairs.

assume that the data being stored is relatively big (may exceed 10000 key value pairs).

thanks in advance.

  • Depends really your testing would have to see what works for you. EOSIO mainnet has a 30ms execution time for a transaction before it expires/cancels. If your work of iterating can be done in less than 30ms, you should be fine. You can also look into deferred transactions but they aren't super reliable. General approach I've seen is for the first option. If your table is too large to iterate in a single transaction, maybe break it into pieces and store the last updated record in a table for restarting. – netuoso - EOS Titan Aug 20 '19 at 14:44
  • thank you for your response. I have another question if I may. Is there a limit for the size of a row in a given table? – Karim Elghamry Aug 20 '19 at 15:07
  • Heh haven't tested that. I'm sure its whatever you have the RAM to pay for and can write to in the allotted time allowed. – netuoso - EOS Titan Aug 20 '19 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.