Back

Reading is too slow with only 17 documents on a collection

  • 0
  • Databases
  • Flutter
HiMaNameIs
24 Nov, 2023, 18:01

What am i doing wrong here, reading takes up to 6 secs to get the data there are 27 attributes, 3 of theme are relationships I have tried with multiple combinations of indexes (as i need searching) i also tried with only one index ,an $updatedAt key index It's pretty much inusable at this point, cause it's meant to be used for thousands of documents

TL;DR
User is experiencing slow reading time on a collection with 17 documents. Initially used IDs to load data quickly. Replacing relationships with a simple string (document ID) improved loading time to under 1 second. User suspects that the presence of relationships in the collection is causing the slowdown. The search feature might also be slowing down the reading process. User provides code for fetching the list and applying queries. User has tried different combinations of indexes and is still experiencing slow reading times. Looking for help to optimize reading speed. Solution: 1. Replace relationships in the collection with simple string values (document IDs) to improve loading time. 2.
Drake
24 Nov, 2023, 18:36

what's your code?

HiMaNameIs
24 Nov, 2023, 19:02

This is how i get my list, i only get 12 elements at a time also search on an attribute on demand

TypeScript
ClientDatabase.database!.listDocuments(
            databaseId: databaseId,
            collectionId: vehiculeid,
            queries: [

              if(i==2)
                Query.equal('annee_util', int.tryParse(searchKey)??9999),
              if(i!=2)
              Query.search(getAttributeForSearch(i), searchKey),
              if(filters.containsKey('yearmin'))
                Query.greaterThanEqual('annee_util', int.tryParse(filters['yearmin']!)),
              if(filters.containsKey('yearmax'))
                Query.lessThanEqual('annee_util', int.tryParse(filters['yearmax']!)),
              if(filters.containsKey('genre'))
                Query.equal('genre', filters['genre']),
              if(filters.containsKey('marque'))
                Query.equal('marque', filters['marque']),
              Query.limit(count),
              Query.offset(startingAt),
              getQuery(sortedBy, sortedAsc),
            ]);
HiMaNameIs
25 Nov, 2023, 17:56

Anything ?

Drake
25 Nov, 2023, 18:07

Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting

Drake
25 Nov, 2023, 18:10

Hmm the search might be slowing things down a lot 😕

HiMaNameIs
25 Nov, 2023, 18:28

But the search is only used if there is something typed in the TextBox, by default it's not My problem here is the default reading By default, it's only 3 queries :

TypeScript
Query.limit(count),
Query.offset(startingAt),
Query.orderAsc('\$id'),

(order depending on the column clicked by the user)

Sorry about the code

HiMaNameIs
25 Nov, 2023, 18:56

Is it not the presence of the 3 relationships in the Collection ? 2 of those collection have relationships with other tables themeselves. Maybe the fact that it's downloading those values in addition can be slow ? should i change those relationships into a simple String value ?

HiMaNameIs
25 Nov, 2023, 21:06

Well, after replacing the relationships with a simple String (document id), it's now loading under 1s

I guess relationships are not meant to be used with a list of data that is meant to be read multiple times

Drake
25 Nov, 2023, 21:18

Oh ya possibly then

Drake
25 Nov, 2023, 21:20

Maybe it's fetching more data than you need and that's making it slower. Hopefully, when we add queries on relationships, you can add queries to optimize this

HiMaNameIs
26 Nov, 2023, 18:25

Can't wait for query yeah, but for now, i'll stick with the IDs

Thank you for your time

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