# Denormalized Data vs. Joins

**URL:** <https://discuss.elastic.co/t/denormalized-data-vs-joins/181041>\
**Category:** Elasticsearch\
**Created:** [May 14, 2019, 4:29pm UTC](https://discuss.elastic.co/t/denormalized-data-vs-joins/181041 "2019-05-14T16:29:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![donnie](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@donnie](https://discuss.elastic.co/u/donnie)\
**Post date:** [May 14, 2019, 4:29pm UTC](https://discuss.elastic.co/t/denormalized-data-vs-joins/181041/1 "2019-05-14T16:29:18Z")

</div>

If I have many posts that belong to a particular user, is it better to do a parent/child relationship or denormalize the data by putting the user in every post document.

In my use-case, the user is regularly being updated, and may have thousands of posts.

I would need to update\_by\_query all posts that have that user in order to keep the user data accurate.

I would potentially need to update a million or more documents whenever we process new posts (thousands of users with thousands of posts).

With my situation, would it be better to use the join datatype and take a hit on query performance?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 15, 2019, 5:53am UTC](https://discuss.elastic.co/t/denormalized-data-vs-joins/181041/2 "2019-05-15T05:53:51Z")

</div>

If you are updating the users infrequently, updating a million documents per day will not necessarily take a lot of time or resources from the cluster. Doing this denormalization typically leads to simpler queries and better performance. If you are updating users more frequently the balance may change. I do not think anyone but you can determine what the balance is for your particular use case.

---

<div class="post-metadata">

**Author:** ![donnie](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@donnie](https://discuss.elastic.co/u/donnie)\
**Post date:** [May 15, 2019, 12:51pm UTC](https://discuss.elastic.co/t/denormalized-data-vs-joins/181041/3 "2019-05-15T12:51:21Z")

</div>

The updates happen by a scheduled job, so I could be updating a million users every 10min or so.

parent/child is preferred since I would be able to query for a single parent that matches many child conditions. For example, must [post.type = "tech", post.type = "finance"], to find the profile with both. In the denormalized example this won't match. We have a UI in front of a query builder that enforces some of these scenarios, and searching becomes difficult with denormalized documents.

If you have experience with parent/child joins, how much of a hit performance-wise should I expect?

I can see that the documentation warns against it, but I feel like my use case calls for it.

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 12, 2019, 12:51pm UTC](https://discuss.elastic.co/t/denormalized-data-vs-joins/181041/4 "2019-06-12T12:51:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
