clojure-gamedev

2021-02-22T18:53:56.012800Z

why not edn in a text field?

Fabim 2021-02-22T21:09:37.012900Z

how would you persist ‘a text field’?

2021-02-22T21:36:28.014500Z

Postgres is highly optimized for indexing and searching data at a granular level. If you do JSONB, you get all the indexing and search stuff for free. If you do EDN in a text field, it’s just an opaque blob as far as Postgres is concerned, so you can’t look inside it and search on / index its constituents.

Fabim 2021-02-23T13:48:53.016100Z

@paul.legato What are lib are you using to convert the edn game state into JSONB before saving it into Postgres?

2021-02-23T17:34:37.016300Z

JSONB just means ‘JSON binary’; it’s an optimized storage format used internally by Postgres. You can put any standard JSON in there. I use Cheshire, but any JSON will work.

2021-02-22T21:37:39.015700Z

you will wind up adding redundant metadata to the row that allows you to find, say, “inventory for player 1234” or “all players who have item XYZ”, which will eventually drift out of alignment with what it says in the EDN blob. Synchronizing two sources of truth is a hard problem.