# Is there any limit in the number of results when querying the Data Storage Integration?

**URL:** <https://www.thethingsnetwork.org/forum/t/is-there-any-limit-in-the-number-of-results-when-querying-the-data-storage-integration/35430>\
**Category:** Application Development\
**Created:** [March 17, 2020, 12:49pm UTC](https://www.thethingsnetwork.org/forum/t/is-there-any-limit-in-the-number-of-results-when-querying-the-data-storage-integration/35430 "2020-03-17T12:49:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![elmagua90](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/elmagua90/32/25844_2.png) [@elmagua90](https://www.thethingsnetwork.org/forum/u/elmagua90)\
**Post date:** [March 17, 2020, 12:49pm UTC](https://www.thethingsnetwork.org/forum/t/is-there-any-limit-in-the-number-of-results-when-querying-the-data-storage-integration/35430/1 "2020-03-17T12:49:30Z")

</div>

Hi everyone,  
Is there any limitation to get the data stored through the Storage Integration? I mean any restriction with the amount of data or something like that. I have been storing some sensor data during 5 days and when I try to get the data with **query?last=5d** it just returns 1 and a half days of data. On the other hand if I try with **query?last=2d** it returns 1 and a half days of data too. So, it seems like a limitation related to the amount of data I am trying to get from the database. The data is stored in the server but it´s being truncated.  
Can someone help me to clarify this?

Thank you for your help,

Ernesto

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [March 17, 2020, 1:38pm UTC](https://www.thethingsnetwork.org/forum/t/is-there-any-limit-in-the-number-of-results-when-querying-the-data-storage-integration/35430/2 "2020-03-17T13:38:51Z")

</div>

How many items are you getting?

I’m not seeing an restrictions. Getting all data† gets me a bit over 1,500 readings for my most active device.

If you’re getting fewer results than that, then something odd is going on.

If you get the same number of results, or more, for a single device for just 1.5 days, then you’re exceeding [the Fair Access Policy](https://www.thethingsnetwork.org/forum/t/limitations-data-rate-packet-size-30-seconds-uplink-and-10-messages-downlink-per-day-fair-access-policy-guidelines/1300), which for the smallest payload in the best circumstances (1 byte on SF7) allows for at most 647 messages per day for EU868. Though that Fair Access Policy is not being enforced yet, **maybe** the Data Storage Integration implicitly limits storage to, say, 4,500 messages per week?

(Please don’t repost the same question when getting no answer, but edit the previous one to add more details. I’ve deleted your earlier post about the same thing.)

* * *

† The Data Storage integration keeps data for 7 days. It seems the data is truncated at midnight, so using `?last=7d` gets me data as of March 10, shortly after midnight, being 7.5 days worth of data.

---

<div class="post-metadata">

**Author:** ![elmagua90](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/elmagua90/32/25844_2.png) [@elmagua90](https://www.thethingsnetwork.org/forum/u/elmagua90)\
**Post date:** [March 18, 2020, 7:40am UTC](https://www.thethingsnetwork.org/forum/t/is-there-any-limit-in-the-number-of-results-when-querying-the-data-storage-integration/35430/3 "2020-03-18T07:40:22Z")

</div>

Thank you so much for your answer @arjanvanb. I will check the amount of data I am storing in 1 day. The strange thing is I am able to get the data if I change the period of time I can check the data is there.

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [March 18, 2020, 8:11am UTC](https://www.thethingsnetwork.org/forum/t/is-there-any-limit-in-the-number-of-results-when-querying-the-data-storage-integration/35430/4 "2020-03-18T08:11:40Z")

</div>

So how many items are returned when querying the integration? (A count for occurences of `},` will quickly give you a number.)

> [@elmagua90](#):
>
> The strange thing is I am able to get the data if I change the period of time I can check the data is there.

What do you mean by this? Ah, I see different details in your ~~deleted~~ [hidden post](https://www.thethingsnetwork.org/forum/t/problem-getting-data-from-storage-integration/35259). Is it related to not getting the most recent data? Emphasis mine:

> When I try e.g. to download data related to the 3 last days I am getting the information from the first and second day and then **just a few data from the present day**. On the other hand, if I download just the last day of data, the data is properly downloaded. So, I know the data is being properly stored but there is some problem when I try to get it.

So, the following returns **different** 1.5 days worth of data?

> [@elmagua90](#):
>
> when I try to get the data with **query?last=5d** it just returns 1 and a half days of data. On the other hand if I try with **query?last=2d** it returns 1 and a half days of data too.

---

<div class="post-metadata">

**Author:** ![elmagua90](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/elmagua90/32/25844_2.png) [@elmagua90](https://www.thethingsnetwork.org/forum/u/elmagua90)\
**Post date:** [March 18, 2020, 11:03am UTC](https://www.thethingsnetwork.org/forum/t/is-there-any-limit-in-the-number-of-results-when-querying-the-data-storage-integration/35430/5 "2020-03-18T11:03:15Z")

</div>

I am afraid I am exceding the amount of data permited by the Fair Access Policy cause a bad operation of my sensor. So I will do some change in my code to reduce this amount of data.  
Any way, I have checked again and all the data is being stored. The problem is when downloading it.

> [@arjanvanb](#):
>
> So, the following returns **different** 1.5 days worth of data?

Yes, when the query is **last=5** it returns e.g from 13/03 9:00 to 14/03 23:00, the rest of data is truncated;and when the query is **last=4** it returns e.g from 14/03 9:00 to 15/03 23:00. So the data truncated in the first case appears in the second case.

Is there some other query apart from last? Can I download just the 5th day ago of data?

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [March 18, 2020, 11:15am UTC](https://www.thethingsnetwork.org/forum/t/is-there-any-limit-in-the-number-of-results-when-querying-the-data-storage-integration/35430/6 "2020-03-18T11:15:21Z")

</div>

Third time… How many items does it return?

And:

> [@Get only the last data point from the Storage Integration](https://www.thethingsnetwork.org/forum/t/get-only-the-last-data-point-from-the-storage-integration/14636/2):
>
> you can only limit by timeframe

---

<div class="post-metadata">

**Author:** ![elmagua90](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/elmagua90/32/25844_2.png) [@elmagua90](https://www.thethingsnetwork.org/forum/u/elmagua90)\
**Post date:** [March 18, 2020, 12:29pm UTC](https://www.thethingsnetwork.org/forum/t/is-there-any-limit-in-the-number-of-results-when-querying-the-data-storage-integration/35430/7 "2020-03-18T12:29:05Z")

</div>

The number of items is variable because the application send the variation of a measurement just when it overpasses a pre-stablished threshold. For one day the number of results is near 1000 but with the proper operation of the sensor it should be less than half of this.

---

<div class="post-metadata">

**Author:** ![elmagua90](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/elmagua90/32/25844_2.png) [@elmagua90](https://www.thethingsnetwork.org/forum/u/elmagua90)\
**Post date:** [March 18, 2020, 12:36pm UTC](https://www.thethingsnetwork.org/forum/t/is-there-any-limit-in-the-number-of-results-when-querying-the-data-storage-integration/35430/8 "2020-03-18T12:36:09Z")

</div>

The average of the estimated airtime of my messages is 25,8 ms. Can I use this to calculate the aproximeted maximun of uploading messages per day?
