# Performance Benefits to using Stored Scripts?

**URL:** <https://discuss.elastic.co/t/performance-benefits-to-using-stored-scripts/242556>\
**Category:** Elasticsearch\
**Created:** [July 24, 2020, 6:20pm UTC](https://discuss.elastic.co/t/performance-benefits-to-using-stored-scripts/242556 "2020-07-24T18:20:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![micah.williamson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/micah.williamson/32/72718_2.png) [@micah.williamson](https://discuss.elastic.co/u/micah.williamson)\
**Post date:** [July 24, 2020, 6:20pm UTC](https://discuss.elastic.co/t/performance-benefits-to-using-stored-scripts/242556/1 "2020-07-24T18:20:26Z")

</div>

I haven't seen anything in the documentation that would suggest using stored scripts are better for performance, but intuitively I'd think running a stored script many times would perform better than running an inline script many times, as the stored script could be parsed and cached.

I was going to spend the next couple hours testing this, but thought I might as well check here first if there was a quick "yes or no" to this question.

If I plan to run the same exact script millions of times across different requests, would there be a performance gain from storing this script first and calling it by it's ID, or is it all the same and I can just use inline scripts?

If it makes a difference, the script is an update script.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [July 24, 2020, 7:29pm UTC](https://discuss.elastic.co/t/performance-benefits-to-using-stored-scripts/242556/2 "2020-07-24T19:29:40Z")

</div>

A stored script isn't faster. We cache the compilation of inline scripts as well as stored scripts. We don't precompile stored scripts because we don't know what they'll be used for.

---

<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:** [August 21, 2020, 7:34pm UTC](https://discuss.elastic.co/t/performance-benefits-to-using-stored-scripts/242556/3 "2020-08-21T19:34:40Z")

</div>

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