Skip to content
Back

Slow query due to relations

  • 0
  • Databases
  • Flutter
  • Cloud
Rienkk
18 Dec, 2024, 22:13

I make this simple query:

''' databases.listDocuments( databaseId: AuthenticationState.databaseId, collectionId: BalanceCollectionId, queries: [ Query.equal('user_id', localUser.$id), ], ); '''

The balance collection is a simple collection with 600 entries. However it has relations to other collections, which had relations to others etc.

My assumption is that it is being slowed down because of nested relations. If all relations are called, a lot of data is requested.

This single call does take 10 seconds however, which seems excessive.

Does someone have a direction to solve this? Remove the relations and fetch them myself?

TL;DR
Developers experiencing slow query performance due to nested relations in their database. They are considering using 'Query.select' to retrieve only necessary data but it's not officially supported. The error 'cloud.appwrite.io | 524: A timeout occurred' is also mentioned. **Solution:** To speed up the query, developers can remove the relations and fetch them manually when needed. Relations are noted to be in beta and may lead to performance issues.
Rienkk
18 Dec, 2024, 22:15

In my Appwrite console I also get this error all the time: 'cloud.appwrite.io | 524: A timeout occurred'

Kenny
18 Dec, 2024, 22:27

Remove the relations and do it yourself when necessary. Relations are in beta and may lead to performance issues.

Kenny
18 Dec, 2024, 22:28

Otherwise, if you don't need that data and want to leave the relations you can use query select and select everything but the related attribute, but if you do need that related data there isn't a way of speeding it up right now.

Rienkk
18 Dec, 2024, 22:38

@Kenny thanks for the reply. Is is possible to query select in such a way that you get the relation id however not all data behind that relation. E.g for a balance relation, I just want the balance ID, not all balance data

Kenny
18 Dec, 2024, 22:39

You may be able to do Query.select('related_item.$id') but know this isn't an officially supported functionality.

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