Is searches faster with more match queries?

I have two queries. And in the index all of the data have collectHour as 10.
if I request both queries, the one with more match statements was faster....

I am curious, if all fields are inspected as columns that are in indexes in mysql DBs.

if I ever need fast searches, is it recommended to add more match fields that share the same values in all documents?

GET indexname/_count
{
    "query": {
        "bool": {
            "must": [
              {
                "match": {
                  "collectDate": "2021-10-27"
                }
              }
             ]
        }
    }
}



GET indexname/_count
{
    "query": {
        "bool": {
            "must": [
              {
                "match": {
                  "collectHour": "10"
                }
              },
              {
                "match": {
                  "collectDate": "2021-10-27"
                }
              }
             ]
        }
    }
}

Yes. All fields are, by default, indexed.

Adding more filters, or matches, will improve performance.

1 Like

Adding more clauses can speed up queries as there are likely to be fewer matches that need to be scored and sorted. At some point the number of clauses, especially if you have large sets of OR clauses, might reduce performance.

2 Likes

Well, like I was aware....
it sure makes sense with experts that confirm this basic fact...

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.