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

[FEATURE] Improve query performance for IN clause with long value list #3117

Open
dai-chen opened this issue Oct 24, 2024 · 0 comments
Open
Labels
enhancement New feature or request performance Make it fast!

Comments

@dai-chen
Copy link
Collaborator

Is your feature request related to a problem?

Currently, long IN value lists are handled recursively and translated into deeply nested term queries, which can lead to performance issues. This approach is inefficient for handling large sets of values in SQL translations.

What solution would you like?

The solution needs further exploration, but the key steps should include:

  1. Optimizing the recursion in the Analyzer and FilterQueryBuilder.
  2. Replacing the deeply nested Term queries with the OpenSearch Terms query which seems better suited for handling large collections of values.

What alternatives have you considered?

N/A

Do you have any additional context?

Example:

... WHERE src_ip IN ('192.168.0.1', '192.168.0.2', '192.168.0.3' ...)

{
  ...
   "query":{
      "bool":{
         "should":[
            {
               "term":{
                  "src_ip":{
                     "value":"192.168.0.1",
                     "boost":1.0
                  }
               }
            },
            {
               "bool":{
                  "should":[
                     {
                        "term":{
                           "src_ip":{
                              "value":"192.168.0.2",
                              "boost":1.0
                           }
                        }
                     },
                     {
                        "bool":{
                           "should":[
                              {
                                 "term":{
                                    "src_ip":{
                                       "value":"192.168.0.3",
                                       "boost":1.0
                                    }
                                 }
                              },
                              {
                                 "bool":{
                                    "should":[
                                       {
                                          "term":{
                                             "src_ip":{
                                                "value":"192.168.0.4",
                                                "boost":1.0
                                             }
                                          }
                                       },
                                       {
                                          ...
@dai-chen dai-chen added enhancement New feature or request untriaged performance Make it fast! and removed untriaged labels Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Make it fast!
Projects
None yet
Development

No branches or pull requests

1 participant