You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when the GetDocuments API endpoint is called and the response needs to include a snapshot, an N+1 issue occurs. This problem arises because packs.BuildDocumentForServerSeq() is called internally N times.
Within packs.BuildDocumentForServerSeq(), two database queries are executed, leading to the N+1 problem. To resolve this issue, the database query within this method should be converted to a bulk version.
If there is a need for a snapshot preview when displaying documents in CodePair, resolving this issue could result in performance improvements.
The attached commit is the code for a bulk query implementation I've worked on before.
In the case of FindClosestSnapshotInfo() bulk, the required query is rather complicated, so I configured the query by configuring the Aggregate pipeline.
When sorting and grouping in the pipeline, it would be good to consider the DB Index applied to the Snapshot Collection.
For the bulk of FindChangesBetweenServerSeqs(), there is a high probability of memory related issues, as it is looking for a very large number of Changes if a Snapshot is missing, and we need to be aware of this issue.
What would you like to be added:
Currently, when the GetDocuments API endpoint is called and the response needs to include a snapshot, an N+1 issue occurs. This problem arises because
packs.BuildDocumentForServerSeq()
is called internally N times.Within
packs.BuildDocumentForServerSeq()
, two database queries are executed, leading to the N+1 problem. To resolve this issue, the database query within this method should be converted to a bulk version.If there is a need for a snapshot preview when displaying documents in CodePair, resolving this issue could result in performance improvements.
yorkie/server/documents/documents.go
Lines 136 to 144 in a4ce314
Why is this needed:
To address the N+1 problem in the GetDocuments API response to enhance performance.
The text was updated successfully, but these errors were encountered: