Back

Database response time

  • 0
  • Databases
outrelouxhe
11 Apr, 2023, 14:26

Hi, using 1.2.1, I have a collection with more than 100k documents. The collection is with document security. I observe that when i make a simple request to get 100 documents unsorted with no queries, the server response is a lot slowerthan if I make a request with a query that narrows the found set to a few dozens of documents (5 to 10 seconds instead of 1 second) . Is it a normal behavior ? I would have expected that requests without query or sort, the response would be fast. Thank you.

TL;DR
The user is experiencing slower response times when making a request to retrieve 100 documents without any queries. They observe that the response is much faster when they include a query that narrows down the found set to a few dozen documents. They suspect that this slowdown is related to document security. They provide information about their server setup and request details. The response suggests checking the server's CPU and RAM and recommends creating indexes for querying. The user clarifies their concern about the slower response time for requests without queries and explains that even though 5 to 10 seconds may not seem long, it can be significant for their app's users. No solution
joeyouss
11 Apr, 2023, 14:28

It is a normal behaviour, because the load increases but depends on how much time are you getting the reply in - is it a lot of minutes? - querying is easier with indexing (and a lot faster)

joeyouss
11 Apr, 2023, 14:28
outrelouxhe
11 Apr, 2023, 14:53

Everythings is relative when time is under consideration. I'm talking here about 5 to 10 seconds of respons time which is not much in certain circonstances but can be very long when the user waits for an answer on this app. There are multiple indexes on that table. We can't anyway make a query without indexes. However, I just observe that a simple listDocuments request with NO query, is a lot slower than a query on the same collection with fields using indexes where the foundset is something like a few dozens of documents.

joeyouss
11 Apr, 2023, 15:18

I understand - yes we require indexes for querying.

outrelouxhe
11 Apr, 2023, 15:36

Thank you for your feedback. My english is certainly not good enough for me to be clear, but I feel that we miss the point here. This is understood that we require indexes for querying. But what about the request performances with more than 100k documents with document security when we DO NOT make a query on attributes. Something like : await databases.listDocuments(databaseId: databaseId,collectionId: collectionId, queries: [Query.limit(100)]). returns 100 documents but is a lot slower than the following request await databases.listDocuments(databaseId: databaseId,collectionId: collectionId, queries: [Query.limit(100), Query.search('search', searchFilter)]) when the filter on the search attribute reduces the found set to let's say about 100 documents. Is there something I miss about this topic? Thank you

joeyouss
11 Apr, 2023, 15:53

I understand this part surely clearly - listDocuments with no filter queries should use index for sorting and probably should give you newest first. When generating collection, we automatically create this index. We can't understand why such a query would be slower than same one with search filter πŸ€”

It might be related to your setup probably in some way? (taking a guess) Query on 100k documents should not take 2 seconds. Can you share details about your server? (To check for CPU and RAM)

outrelouxhe
11 Apr, 2023, 15:57

My setup is 4 CPUs and 4Gb of RAM and this is dev server so almost no other users

outrelouxhe
11 Apr, 2023, 15:59

I'm wondering if the issue comes from the document security. If I remove the document security and set the permission on the collection to all users then the response without attribute query is a lot faster

outrelouxhe
11 Apr, 2023, 16:15

This is definitely coming from the document permission.

outrelouxhe
11 Apr, 2023, 16:16

We go from 0.18 seconds for 100 records with no attribute query with collection permission to almost 13 seconds for 100 records with no attribute query with document permission activated.

outrelouxhe
11 Apr, 2023, 16:19

this is 70 times slower...

outrelouxhe
11 Apr, 2023, 16:26

But when I add a query on the 'search' attribute in such a way that it returns only 1 document, then the performances are very similar between collection permission (0.12 seconds) and document permission (0.16 seconds)

joeyouss
11 Apr, 2023, 16:32

Document security do make queries slower but.. not this much ..Might be worth to try to reproduce.. Spin up local instance, create 100k documents, enable documentSecurity and see how quick queries are compared to documentSecurity=false

joeyouss
11 Apr, 2023, 16:49

Also, can you try and share a bit more details about the kind of data you're dealing with and/or share the data with us via DMs (if not confidential) so we can try and reproduce it

outrelouxhe
12 Apr, 2023, 21:31

Thank you for your proposals. I'll work on this once I manage to free some time.

joeyouss
13 Apr, 2023, 14:52

ok sure, let us know!

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