# Decay query Running very slow at a very small requestpersecond

**URL:** <https://discuss.elastic.co/t/decay-query-running-very-slow-at-a-very-small-requestpersecond/112892>\
**Category:** Elasticsearch\
**Created:** [December 21, 2017, 8:57pm UTC](https://discuss.elastic.co/t/decay-query-running-very-slow-at-a-very-small-requestpersecond/112892 "2017-12-21T20:57:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jalaj](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@jalaj](https://discuss.elastic.co/u/jalaj)\
**Post date:** [December 21, 2017, 8:57pm UTC](https://discuss.elastic.co/t/decay-query-running-very-slow-at-a-very-small-requestpersecond/112892/1 "2017-12-21T20:57:06Z")

</div>

Hi,

I have an index named discover in which I have have only 2 fields timestamp (ts) and another meta field(oid).

```
PUT discover
{
  "settings": {
    "number_of_shards": 6,
    "number_of_replicas": 2
  }, 
  "mappings": {
    "content": {
      "properties": {
        "ts": {
          "type": "date" 
        },
        "oid": {"type": "keyword","index": false}
      }
    }
  }
}

```

I have ingested around 10 million documents into this index. I have 6 machines (8 core 60 GB RAM ). ES process have 30 GB Xmx.

Now I ran a simple query to fetch documents decayed by [time.My](http://time.My) requirement is I want documents with recent documents first. Initially I am not doing any query so its a matchall but in future I might want to rank with some metadata and also decay by time.

My current search query is like this.

```
GET discover/content/_search?preference=_shards:1
{
  "_source": "{_id}", 
      "query": {
        "function_score": {
          "functions": [
            {
              "gauss": {
                "ts": {
                  "origin":1513887762 ,
                  "scale": "1m",
                  "decay": 0.5
                }
              }
            }
          ]
        }
      }
}

```

I am okay with getting data only from a single shard at a time.

I run the above query qith just 50-60 rps and load average of the cluster reaches 7-8 and mean\_99 latencies are in ~900 ms which is very slow.

Am I doing something wrong or is there a better way to achieve what I am trying ?

---

<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:** [January 18, 2018, 8:57pm UTC](https://discuss.elastic.co/t/decay-query-running-very-slow-at-a-very-small-requestpersecond/112892/2 "2018-01-18T20:57:30Z")

</div>

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