bool > filter > bool vs bool > filter 쿼리 성능차이

개발새발·2022년 4월 23일
0

elasticsearch

목록 보기
19/54

결론부터 말하면, "query" : { "bool" : {"filter" : {"must" : {}} } } 보다 "query" : { "bool" : {"filter" : {"bool" : {"must" : {} } } } } 이 성능이 좋다.

서론

우리회사에서 운영하는 서버사양과는 다르겠지만, Esrally라는 프로그램으로 쿼리문을 가지고 테스트를 해본 결과 아래와 같이 나왔다. (이제보니 쿼리문에 지정해준 size가 다르다. 급하게 2번도 100으로 돌려보니 유사한 결과치로 나왔다.)


테스트

  1. "query" : { "bool" : {"filter" : {"must" : {}} } } 테스트

    Mean Throughput : 127.00 ops/s

    {
      "body": {
        "query": {
          "bool": {
            "must": [
              {
                "match": {
                  "text_type_field": 4_random_words
                 }
              }
            ],
            "filter": [
              {
                "term": {
                  "keyword_type_field": true
                }
              },
              {
                "term": {
                  "keyword_type_field": true
                }
              },
              {
                "term": {
                  "keyword_type_field": false
                }
              },
              {
                "term": {
                  "keyword_type_field": true
                }
              }
            ]
          }
        },
        "from": 0,
        "size": 100,
        "sort": {
          "text_type_field.keyword": "asc"
        }
      },
        "index": self._index_name,
        "type": self._type_name,
        "cache": self._cache,
    }

  1. "query" : { "bool" : {"filter" : {"bool" : {"must" : {} } } } } 테스트

    Mean Throughput : 315.99 ops/s

    {
       "query": {
           "bool": {
               "must": [
                         {
                            "match": {
                              "text_type_field": 4_random_words
                             }
                         }
                       ],
               "filter": {
                  "bool": {
                    "must":
                      [
                        {
                          "term": {
                            "keyword_type_field": true
                           }
                        },
                        {
                          "term": {
                            "keyword_type_field": true
                          }
                        },
                        {
                          "term": {
                            "keyword_type_field": false
                          }
                        },
                        {
                          "term": {
                            "keyword_type_field": true
                          }
                         }
                       ]
                     }
                   }
                  }
                 },
                 "from": 0,
                 "size": 10,
                 "sort": {
                    "text_type_field.keyword": "asc"
                 }
               },
              "index": self._index_name,
              "type": self._type_name,
              "cache": self._cache,
    }

Mean Throughput , 즉, 평균 처리량이 3배정도 안되게 차이가 났다.

profile
발새발개

0개의 댓글