I have a tiny little index (~100MB). The mapping is simple and naive - with no nested objects whatsoever. There's one field (an array of objects) which is kind of big, and sometimes I'd like to exclude that from the resulting response.
The thing is, if either "excludes" or "includes" is applied - the overall execution time (took) becomes twice higher.
Here's an easier way to reproduce the issue:
'_source' => ['includes' => ['id']] => 30ms
Without any includes/excludes => 15ms
What's the reason of it? Take into account that the whole index is loaded into RAM ( 'index.store.preload' => ['nvd', 'dvd', 'tim', 'doc', 'dim']), for the sake of better performance.
What's the mechanism behind that? I understand that in case of no includes/excludes ES can just map the entire index memory to the response without any additional processing. But why does it take that long to exclude/include unnecessary fields since all the data is in RAM already?
It seems to be a very quick O(n) operation. Thanks for your work!