I have a Solidity smart contract to run on the Ethereum network, that has a public mapping which stores a struct with several attributes. I must loop through all of those stored structs looking for a specific attribute value that may or may not be unique, (i.e. users['Joe'].age == "30"). Those might add to over 1000 structs, each having about 6 attributes.
What should I do, in terms of cost versus performance? Run an internal loop inside the contract and get only the results I want, or make a loop to call all of the structs individually, then run a loop outside of the blockchain to find them?
I'm kind of lost, here. Thank you.