Back

[SOLVED] offset and limit issue

  • 0
  • Databases
  • Flutter
frankenstein
2 Mar, 2023, 17:06

Hello I'm trying to create a pagination of my documents. My pagination is set to 10 as limit. But a function like; Var res = database.listdocuments(query.limit = 10); When I check res.total gives me the total documents of the query.

I have no issue with this. I just want to know internally has the query fetched all docs.? Can I use it to get total docs in a collection.?

TL;DR
The user is asking about an issue with offset and limit when trying to fetch more than 5000 records. The response suggests using cursor-based pagination and creating a new post instead of reviving an old one. There is no solution provided for increasing the offset value.
Drake
2 Mar, 2023, 18:38

When I check res.total gives me the total documents of the query.

total is the total documents in the database ignoring any such limit, up to 5000.

I just want to know internally has the query fetched all docs.?

I'm not sure what you mean

frankenstein
2 Mar, 2023, 18:38

Internally has fetched only the limit which is 10

frankenstein
2 Mar, 2023, 18:40

So can I use this to count documents.?

Drake
2 Mar, 2023, 18:47

im sorry, i don't quite understand

frankenstein
2 Mar, 2023, 18:49

I'm saying internally the query is okay I get the first 10 documents. But res.total is the total documents without the query.limit

Drake
2 Mar, 2023, 18:50

But res.total is the total documents without the query.limit This is expected

frankenstein
2 Mar, 2023, 18:51

So if I want to get the total number of documents can I use this while limit it to 1

Drake
2 Mar, 2023, 18:51

sure...but the maximum total will be 5000. so if you had more than 5000, it will still only show 5000

frankenstein
2 Mar, 2023, 18:53

So technically I'm not overloading the database with this query when I query and limit to 1 and get total right.?

Drake
2 Mar, 2023, 18:54

Correct. We have that 5000 cap so that the database isn't overloaded.

Drake
7 Mar, 2023, 19:41

[SOLVED] offset and limit issue

conqueror
29 May, 2023, 20:42

( offset limit error ) if i am trying to fetch more then 5k record, is there is any way to increase offset value.

Drake
29 May, 2023, 22:59

use cursor-based pagination...also, it's best to create a new post instead of reviving an old post like this

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more