Hi all,
I am loading data from an external vendor API and mapping it into an internal schema. The external data has the ability to change without notifying me, so I must constantly check incoming data versus my internal schema to check whether it is new entirely, unchanged or needs updating. This has the potential for a lot of database reads, so I'm wondering what the best way of dealing with this in in Ecto. I have a Postgresql database.
There are two routes I see, but I'm not sure which is more expensive (or whether there is a third, better option).
1. Load the existing values into a variable, then enumerate the incoming external data versus the variable to identify the correct action (insert, update, nothing).
2. Enumerate the incoming external data calling the database with each record to determine the correct action (insert, update, nothing).
I sense #1 is more efficient, but I'm new to Elixir so I'm hoping for another opinion.
Thanks!
Will