DEV Community

Discussion on: Why does writing code for DynamoDb get my spidey senses tingling?

Collapse
rimutaka profile image
Max

I had the same love/hate relationship with DynamoDB because I treated it like an SQL DB.

It is a key-value store with maybe an additional index.
The only retrieval I do now is by key. No scans, minimal filtering. Loving it!

I maintain the relationships and integrity in Postgres. It has only the keys to keep the SQL DB small. All the payload lives in DDB. So far I am very happy with this arrangement.

Collapse
conorw profile image
Conor Woods Author

Very interested to understand the Postgres bit and how it works Max.
How do you keep the keys updated and what does querying looks like?

Collapse
rimutaka profile image
Max • Edited on
  • Reads if ID is known Vue - Appsyn - DDB
  • Reads if ID is not known or related IDs are required: Vue - Appsync - Lambda - get IDs from Postgres - Lambda - DDB batch read - pack it up for Appsync - back to Vue.
  • Search by IDs, relations, dates, numeric, order - same as above
  • Search by text or complex relations: add ElasticSearch to the pic
  • Writes / deletes: Vue - Appsync - Lambda - full record incl IDs into DDB - IDs only into PG

You need to denormalize and partition your data.

This architecture does not work well for anything transactional, but then I would not use DDB for anything transactional either.

You may be better off using Postgres alone if your project is within the size of a single DB server.

Feel free to message me if you want to know more.