# Inline Script with Parameters and Stored Script performance

**URL:** <https://discuss.elastic.co/t/inline-script-with-parameters-and-stored-script-performance/204070>\
**Category:** Elasticsearch\
**Created:** [October 17, 2019, 1:50pm UTC](https://discuss.elastic.co/t/inline-script-with-parameters-and-stored-script-performance/204070 "2019-10-17T13:50:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aadishj02](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@aadishj02](https://discuss.elastic.co/u/aadishj02)\
**Post date:** [October 17, 2019, 1:50pm UTC](https://discuss.elastic.co/t/inline-script-with-parameters-and-stored-script-performance/204070/1 "2019-10-17T13:50:45Z")

</div>

Hi,

Is there any performance difference between the inline script with parameters and stored script? And also how is elasticsearch not compiling the script if I use the same inline script with parameters multiple times?

Thanks

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [October 25, 2019, 8:58pm UTC](https://discuss.elastic.co/t/inline-script-with-parameters-and-stored-script-performance/204070/2 "2019-10-25T20:58:35Z")

</div>

Whether a script is stored or inline does not change if the script needs to be recompiled. The same inline script with different parameters should be cached, just like a stored script would be. The cache key is always the content of the script itself. Params are not part of this because they are runtime input to the script and do not change the compilation.

There should not be any performance difference between the two. The reason for stored scripts is to simplify reusing the same script without needing to store it client side.

---

<div class="post-metadata">

**Author:** ![aadishj02](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@aadishj02](https://discuss.elastic.co/u/aadishj02)\
**Post date:** [October 30, 2019, 5:33am UTC](https://discuss.elastic.co/t/inline-script-with-parameters-and-stored-script-performance/204070/3 "2019-10-30T05:33:32Z")

</div>

Thank You. That was helpful.

---

<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:** [November 27, 2019, 5:33am UTC](https://discuss.elastic.co/t/inline-script-with-parameters-and-stored-script-performance/204070/4 "2019-11-27T05:33:39Z")

</div>

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