You would assume that it limits the amount of results returned from the DB, but instead it returns all the results with fetch before taking the first result out of it.
In our case, we simply wanted the most recent document out of a collection, and we noticed that it returned the entire collection from the DB!!
We noticed some serious performance issues because of how
Query.fetchOne
is implemented:https://github.com/cult-of-coders/grapher/blob/842dbb1ed313ecd1abdd7fc79378be673445df1b/lib/query/query.server.js#L26
You would assume that it limits the amount of results returned from the DB, but instead it returns all the results with
fetch
before taking the first result out of it.In our case, we simply wanted the most recent document out of a collection, and we noticed that it returned the entire collection from the DB!!