# Custom \_id for new user profile documents

**URL:** <https://discuss.elastic.co/t/custom-id-for-new-user-profile-documents/271745>\
**Category:** Elasticsearch\
**Created:** [April 30, 2021, 8:05am UTC](https://discuss.elastic.co/t/custom-id-for-new-user-profile-documents/271745 "2021-04-30T08:05:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukas\_Smilek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_smilek/32/87425_2.png) [@Lukas\_Smilek](https://discuss.elastic.co/u/Lukas_Smilek)\
**Post date:** [April 30, 2021, 8:05am UTC](https://discuss.elastic.co/t/custom-id-for-new-user-profile-documents/271745/1 "2021-04-30T08:05:27Z")

</div>

Hello,

I went through the topics here and did some research and I am aware of the fact that specifying an custom `_id` when indexing new document can slow down the performance. But I could not find how drastically it would behave in following case:

1. In a mobile app, user will create and account that generated `Profile` document in the MongoDB database and this is also directly being indexed in elastic search
2. on each update on his profile the document in ElasticSearch gets re-indexed

Now my two questions would be:

1. as the document in the ElasticSearch is created only once the user sign-up, can I safely use a 10 character String generated in the app server as a custom `_id`?\*\* I believe the frequency of creating new profiles would be slow enough even the user base would grow into millions.

2. I found in other discussions that client.index({ }) and client.index({ }) for any following changes in that above created document would not make any performance difference. Is that correct? Update could safe some traffic if I would not have offline-first mobile app and would have to first fetch current state from database before saving new values.

Assuming the two questions are also a correct answers I should be fine with using strings like `QDbCIeqVWt`, `dNHXPlSY1U`, `eqspyeRmUw` for the custom \_id field.

Or do I miss anything that could break in future while scaling everything up (sharding, ...)?

Thanks for inputs!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 30, 2021, 8:37am UTC](https://discuss.elastic.co/t/custom-id-for-new-user-profile-documents/271745/2 "2021-04-30T08:37:40Z")

</div>

Everything should be fine.

I'd recommend using the same `_id` for elasticsearch as the one you are using in MongoDB.

---

<div class="post-metadata">

**Author:** ![Lukas\_Smilek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_smilek/32/87425_2.png) [@Lukas\_Smilek](https://discuss.elastic.co/u/Lukas_Smilek)\
**Post date:** [April 30, 2021, 8:56am UTC](https://discuss.elastic.co/t/custom-id-for-new-user-profile-documents/271745/3 "2021-04-30T08:56:35Z")

</div>

Thank you for confirmation, David! This simplifies the black-end logic noticeably, but I was not sure if I would build up some time bomb.

---

<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:** [May 28, 2021, 8:56am UTC](https://discuss.elastic.co/t/custom-id-for-new-user-profile-documents/271745/4 "2021-05-28T08:56:56Z")

</div>

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