# Time Difference with "took" and python timer

**URL:** <https://discuss.elastic.co/t/time-difference-with-took-and-python-timer/290445>\
**Category:** Elasticsearch\
**Created:** [November 29, 2021, 2:32pm UTC](https://discuss.elastic.co/t/time-difference-with-took-and-python-timer/290445 "2021-11-29T14:32:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![icgncl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icgncl/32/97769_2.png) [@icgncl](https://discuss.elastic.co/u/icgncl)\
**Post date:** [November 29, 2021, 2:32pm UTC](https://discuss.elastic.co/t/time-difference-with-took-and-python-timer/290445/1 "2021-11-29T14:32:41Z")

</div>

Hello everyone, I am very new in Elasticsearch and also in forum. I have created an index, then I have created some queries. When I checked the "took" time from kibana for my queries, it is between 7 and 10ms. However, when I check it with :

```auto
start_time = time.time()
response = requests.post(url=search_url, headers=headers, data=payload, auth=HTTPBasicAuth(ElasticConfig.ELASTIC_USERNAME, ElasticConfig.ELASTIC_PASSWORD))
Logger.info(f"Taken time by elasticsearch is {time.time()-start_time}")

```

It shows nearly 50 ms. I know that serialization and deserializations are not involved in "took". I use "JSON" for serialization and deserialization. Actually, I don't know what should I do next to speed up my queries . Thank you for your comments.

---

<div class="post-metadata">

**Author:** ![icgncl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icgncl/32/97769_2.png) [@icgncl](https://discuss.elastic.co/u/icgncl)\
**Post date:** [November 29, 2021, 6:08pm UTC](https://discuss.elastic.co/t/time-difference-with-took-and-python-timer/290445/3 "2021-11-29T18:08:42Z")

</div>

Version is Elasticsearch 7.9.1

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 30, 2021, 12:22am UTC](https://discuss.elastic.co/t/time-difference-with-took-and-python-timer/290445/4 "2021-11-30T00:22:49Z")

</div>

Welcome to our community! 😃

Is 50ms too slow?

---

<div class="post-metadata">

**Author:** ![icgncl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icgncl/32/97769_2.png) [@icgncl](https://discuss.elastic.co/u/icgncl)\
**Post date:** [November 30, 2021, 6:12am UTC](https://discuss.elastic.co/t/time-difference-with-took-and-python-timer/290445/5 "2021-11-30T06:12:22Z")

</div>

Hi @warkolm , actually we are planning to use it for production; therefore, 20-25 ms would be perfect.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 30, 2021, 7:40am UTC](https://discuss.elastic.co/t/time-difference-with-took-and-python-timer/290445/6 "2021-11-30T07:40:45Z")

</div>

Ok, well what's the query you are running?

---

<div class="post-metadata">

**Author:** ![icgncl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/icgncl/32/97769_2.png) [@icgncl](https://discuss.elastic.co/u/icgncl)\
**Post date:** [November 30, 2021, 8:07am UTC](https://discuss.elastic.co/t/time-difference-with-took-and-python-timer/290445/7 "2021-11-30T08:07:10Z")

</div>

```auto

  "size": 100,
  "from": 0,
  "min_score": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "match": {
            "country_code": country.upper()
          }
        }
      ],
      "must": [
        {
          "multi_match": {
            "query": keyword,
            "fuzziness": 1,
            "prefix_length": 1,
            "fields": [
              "product_name_en.productName^1",
              "product_name_en.productName_wo_autocomplete^2",
              "product_name_en.productName_multiple^0.4",
              "subcategory_name_en^1",
              "category_name_en^0.4",
              "total_name_adj_en^1",
              "product_name_tr.productName^0.2",
              "product_name_tr.productName_wo_autocomplete^0.4",
              "product_name_tr.productName_multiple^0.1",
              "subcategory_name_tr^0.2",
              "category_name_tr^0.1",
              "total_name_adj_tr^0.2",
              "product_name_fr.productName^0.2",
              "product_name_fr.productName_wo_autocomplete^0.4",
              "product_name_fr.productName_multiple^0.1",
              "subcategory_name_fr^0.2",
              "category_name_fr^0.1",
              "total_name_adj_fr^0.2",
              "product_name_nl.productName^0.2",
              "product_name_nl.productName_wo_autocomplete^0.4",
              "product_name_nl.productName_multiple^0.1",
              "subcategory_name_nl^0.2",
              "category_name_nl^0.1",
              "total_name_adj_nl^0.2",
              "product_name_de.productName^0.2",
              "product_name_de.productName_wo_autocomplete^0.4",
              "product_name_de.productName_multiple^0.1",
              "subcategory_name_de^0.2",
              "category_name_de^0.1",
              "total_name_adj_de^0.2",
              "product_name_es.productName^0.2",
              "product_name_es.productName_wo_autocomplete^0.4",
              "product_name_es.productName_multiple^0.1",
              "subcategory_name_es^0.2",
              "category_name_es^0.1",
              "total_name_adj_es^0.2",
              "product_name_it.productName^0.2",
              "product_name_it.productName_wo_autocomplete^0.4",
              "product_name_it.productName_multiple^0.1",
              "subcategory_name_it^0.2",
              "category_name_it^0.1",
              "total_name_adj_it^0.2",
              "product_name_pt.productName^0.2",
              "product_name_pt.productName_wo_autocomplete^0.4",
              "product_name_pt.productName_multiple^0.1",
              "subcategory_name_pt^0.2",
              "category_name_pt^0.1",
              "total_name_adj_pt^0.2"
            ]
          }
        }
      ]
    }
  }

```

Also, the first queries are slower, when they are compared to following queries.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 28, 2021, 8:07am UTC](https://discuss.elastic.co/t/time-difference-with-took-and-python-timer/290445/8 "2021-12-28T08:07:44Z")

</div>

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