-
-
Notifications
You must be signed in to change notification settings - Fork 509
Move reference priming to Cursor #1068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Nice. Looks good to me! 👍 |
👍 Thanks for the improvement! Scott |
Could this PR have caused #1108 ? |
@blockjon: I just looked at this PR diff and I suspect that the new call to Even considering the original priming code, I don't see any reason that this should be re-executing the cursor for each primer. There is no guarantee that the query is going to return the same results on successive executions. Although it would come at an expense of memory, I think that priming would best be restricted to EagerCursors, where all of the documents are cached in an array and no re-execution takes place ( |
@jmikola sounds reasonable. So in |
I think it'd be reasonable to say that:
|
This PR moves reference priming from the
Query::execute
method to the cursor which iterates over the results (as described in #1065). This increases performance when iterating over part of a large query result (e.g. by settingskip
andlimit
on the returned cursor before iterating) as it will not prime references for the entire result set.Note that using
prime
forfindAndUpdate
andfindAndRemove
will prime references when executing the query since it will not return a cursor.This also fixes a side effect of #520 where using
getSingleResult()
on a query withoutlimit
in combination withprime
would prime references for all documents returned in the query instead of just the one returned bygetSingleResult()
.Feedback is greatly appreciated, I'd really appreciate it if some people using reference priming could run their test suite against the branch and post some results.
NB: I'm not too happy with having to duplicate functionality in
Cursor
andEagerCursor
, unfortunately I can't think of another way since the two classes don't share an interface.