Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EPIC] A collection of Sort + Limit / Top K optimizations #7195

Open
7 of 11 tasks
alamb opened this issue Aug 4, 2023 · 0 comments
Open
7 of 11 tasks

[EPIC] A collection of Sort + Limit / Top K optimizations #7195

alamb opened this issue Aug 4, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@alamb
Copy link
Contributor

alamb commented Aug 4, 2023

Is your feature request related to a problem or challenge?

This ticket has links a collection of various ways to make queries with LIMIT or various other variants (like row_number() predicates) both:

  1. Go faster
  2. Use less memory

These are typically called "Top K" style optimizations in databases and optimize the pattern of a sort followed by a limit

LIMIT(fetch = 10)
  SORT(x)
    INPUT...

The observation is that if the INPUT is much larger than the fetch (aka the K) it is much more efficient and less memory intensive to track the top 10 values rather than sort the entire input and discard everything except the top 10

Normally this done with special ExecutionPlan operators. What the operators do and behave depend on the exact query pattern.

Describe the solution you'd like

Describe alternatives you've considered

No response

Additional context

No response

@alamb alamb added the enhancement New feature or request label Aug 4, 2023
@alamb alamb changed the title [EPIC] A collection of Top K / LIMIT optimizations [EPIC] A collection of Sort + Limit / Top K optimizations Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant