# Duration request influx sometimes takes a lot of time

**URL:** <https://community.influxdata.com/t/duration-request-influx-sometimes-takes-a-lot-of-time/15898>\
**Category:** Systems\
**Created:** [September 8, 2020, 2:04pm UTC](https://community.influxdata.com/t/duration-request-influx-sometimes-takes-a-lot-of-time/15898 "2020-09-08T14:04:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spyfox](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@spyfox](https://community.influxdata.com/u/spyfox)\
**Post date:** [September 8, 2020, 2:04pm UTC](https://community.influxdata.com/t/duration-request-influx-sometimes-takes-a-lot-of-time/15898/1 "2020-09-08T14:04:05Z")

</div>

hello, I have a problem that I would like to understand, sometimes an influx reading request takes a lot of time.  
I developed this little code to explain my problem, but I have this problem in productions with my real data

```
db_name = 'testBase'
inf_client = DataFrameClient(database=db_name)
inf_client.drop_database(db_name)
inf_client.create_database(db_name)
df = pd.DataFrame(data=list(range(100)),
                  index=pd.date_range(start='2014-11-16',
                                      periods=100, freq='H'), columns=['0'])
inf_client.write_points(df, db_name)
duration_data = {}
for i in range(0, 50):
    start_time = time.time()
    data = inf_client.query("select * from testBase where time>='2014-11-16 00:00:00' and time<='2014-11-16 10:00:00'")
    duration = time.time() - start_time
    duration_data[i] = duration

data_df = pd.DataFrame(duration_data.items(), columns=["index", "duration"])
del data_df['index']
data_df.plot()

```

![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/f/f6dd01a82cbfee7bda326f09b4746f8ffc0e20df.png)

---

<div class="post-metadata">

**Author:** ![philjb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philjb/32/5405_2.png) [@philjb](https://community.influxdata.com/u/philjb)\
**Post date:** [September 9, 2020, 8:24pm UTC](https://community.influxdata.com/t/duration-request-influx-sometimes-takes-a-lot-of-time/15898/2 "2020-09-09T20:24:36Z")

</div>

Hi @spyfox - welcome to the community! It is hard to give a specific response without much more detail, but in general, InfluxDB needs to load memory mapped files. It takes time for the OS to pull these in, but once resident accessing the same data again is faster. There’s no promise the OS keeps the data resident either because of other demands. It is odd that iteration ~4 is the slow one; how consistent is your graph if you run it 100s of times? I assume the y-axis units are seconds? ~50ms for the slowest example? While this example query is interesting, I think we would be better served trying to optimize your production query if you’re willing to share it.

---

<div class="post-metadata">

**Author:** ![spyfox](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@spyfox](https://community.influxdata.com/u/spyfox)\
**Post date:** [September 10, 2020, 11:59am UTC](https://community.influxdata.com/t/duration-request-influx-sometimes-takes-a-lot-of-time/15898/3 "2020-09-10T11:59:44Z")

</div>

thanks for your answer, yes, the y axis is second and x axis is iteration number  
i try with 200 iteration and i have this:  
 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/8/8f329920c5dfc1c5ce7705306ca60f8c1fa48854.png)

i have the same situation

---

<div class="post-metadata">

**Author:** ![philjb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philjb/32/5405_2.png) [@philjb](https://community.influxdata.com/u/philjb)\
**Post date:** [September 30, 2020, 7:26pm UTC](https://community.influxdata.com/t/duration-request-influx-sometimes-takes-a-lot-of-time/15898/4 "2020-09-30T19:26:54Z")

</div>

Sorry- I meant if you run ~25 iterations quickly and then wait say 60 minutes and run 25 iterations of the query again, how consistent is it that the 4th query in particular is the slowest one? Not 200 iterations quickly.
