Hi,
While I think @idi527 ’ s answer was really good (especially anything pointing to io lists), and would add http://erlang.org/doc/efficiency_guide/binaryhandling.html .
I’m a bit worried that it might lead you to a less than optimal path :
First you’re talking about setting values, and, well, generally speaking in erlang or elixir you can’t set values. Values are immutable. That doesn’t mean that there are no ways to optimise here (as per @idi527 's comment) but, it is generally not the same framework.
Second, and mainly (granted I might be wrong, I don’t know where your project stands right now), you might be optimising for the wrong thing. Don’t get me wrong, I believe in local optimisation, I even love to do it, but the way you design your application will probably have much more impact.
Now, I don’t know much about mutliplayer game server (if it’s your actual use case), but I would assume that you would have to handle state for each player, and a global state for the world. So I would assume something like genserver (or channel) for each player, and a global state (backed by maybe a genserver, maybe a set of ets tables, that would communicate with pg ?). I don’t know exactly, but I would focus on this general design first, way before I tried to optimise locally.
Again, you may have done all that, in which case I’m sorry to point to that, but keep in mind that elixir/erlang is somewhat high level, is mostly immutable, and while local optimisation is very much possible and desirable, it should probably come last (while keeping it in mind while designing).
Hope it makes sense.