Skip to content

[BUG] Unused fetch sub phase processors initialized during fetch phase #12502

@jainankitk

Description

@jainankitk

Describe the bug

Opensearch initializes sub processors even if are not getting used during the fetch phase. Can be prevented by validating if size of fields is greater than zero in addition to it being non-null. Take below snippet from InnerHitsPhase class:

public FetchSubPhaseProcessor getProcessor(FetchContext searchContext) {
        if (searchContext.innerHits() == null) {
            return null;
        }

This should not get initialized if the innerHits count is 0

Related component

Search:Performance

To Reproduce

  1. Add data http_logs into Opensearch
  2. Run below query:
curl -XGET "http://localhost:9200/logs-241998/_search?pretty" -H 'Content-Type: application/json' -d'
{"size": 1000,
  "query": {
    "match_all": {}
  },"docvalue_fields":["clientip"],
 "sort": [{"size":"asc"}]
}'
  1. Attach debugger to above code reference

Expected behavior

Unnecessary initialization of fetch sub phase processor should be skipped

Additional Details

No response

Metadata

Metadata

Assignees

Labels

Search:PerformancebugSomething isn't workingv2.13.0Issues and PRs related to version 2.13.0v3.0.0Issues and PRs related to version 3.0.0

Type

No type

Projects

Status

✅ Done

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions