April 2019
Beginner to intermediate
244 pages
6h 34m
English
Embedded schemas have some advantages over associations. Since the child records are stored with the parent, you don’t have to use joins or Repo.preload to fetch them. This can help with performance, because you can avoid extra round-trips to the database. It also means the data is stored closely together on disk and in memory, reducing expensive disk seeks and increasing caching efficiency.
Another consideration is that with schemas, every time you make changes you also have to create an accompanying migration. Embeds use unstructured JSON, so you only need to change your schema definition and leave the database alone. This is more flexible and can lead to more efficient iteration.
But embeds ...
Read now
Unlock full access