Skip to content

[Performance] Optimize num agg using quick select for topN #18703

Open
@vinaykpud

Description

@vinaykpud

Describe the bug

Problem: If the number of requested top-N buckets (N) often exceeded or was close to the maximum bucket ordinal, making the use of a PriorityQueue for top-N selection inefficient or redundant.

Solution: Introduced conditional logic to optimize bucket selection:
* If N > max bucket ordinal: No-op (return all buckets).
* If N < max bucket ordinal but N is bellow 10% of max bucket ordinal: Use quickselect for top-N.
* Otherwise: Use PriorityQueue for top-N.

Related component

Search:Performance

Additional Details

Plugins
NA

Screenshots
NA

Host/Environment (please complete the following information):

  • Tests using r5.xl host with EBS Gp3 16000 IOPS, 500Gb and 1000 throughput.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

🆕 New

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions