-
Notifications
You must be signed in to change notification settings - Fork 189
[Core] Add database query class to represent the results of a DB query #9334
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
|
@driusan It passed the manual tests. |
kongtiaowang
approved these changes
Sep 12, 2024
Contributor
kongtiaowang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
maximemulder
pushed a commit
to maximemulder/Loris
that referenced
this pull request
Sep 25, 2024
aces#9334) This adds `\LORIS\Database\Query` class which is both an iterator an countable to replace the return value of `Database->pselect()`. This improves the memory consumption of large datasets, because the iterator only needs to load the row that is being foreach'd over, instead of loading the entire query result into memory. Places that currently depend on it being an array are wrapped in `iterator_to_array` (They are mostly queries returning small results, so this isn't expensive. The optimization is mostly useful for places like the dataquery module which iterate over large amounts of data.)
ZhichGaming
pushed a commit
to ZhichGaming/Loris
that referenced
this pull request
Nov 25, 2024
aces#9334) This adds `\LORIS\Database\Query` class which is both an iterator an countable to replace the return value of `Database->pselect()`. This improves the memory consumption of large datasets, because the iterator only needs to load the row that is being foreach'd over, instead of loading the entire query result into memory. Places that currently depend on it being an array are wrapped in `iterator_to_array` (They are mostly queries returning small results, so this isn't expensive. The optimization is mostly useful for places like the dataquery module which iterate over large amounts of data.)
driusan
added a commit
that referenced
this pull request
Feb 3, 2025
This updates DBRowProvisioner to remove the strval (and fixes #9335). After doing that, it became clear that the inner class could be replaced by a generator while still fulfilling the contract of returning a `\Traversable`. Doing this made it more obvious that since #9334, pselect could be used directly while maintaining the lazy evaluation instead of bypassing the Database object to use the PDO directly. However this required injecting a `LorisInstance` object to the constructor to get the database connection. With access to the `LorisInstance` object, the `DBRowProvisioner` can also get a new database connection and disable query buffering to lazily retrieve rows since PR #9344. This may theoretically improve performance and memory usage on large provisioners but has not been tested. (Performance did not decrease in raisinbread but it is not a large dataset where it would be noticeable.)
1 task
driusan
pushed a commit
that referenced
this pull request
Apr 11, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds
\LORIS\Database\Queryclass which is both an iterator an countable to replace the return value ofDatabase->pselect(). This improves the memory consumption of large datasets, because the iterator only needs to load the row that is being foreach'd over, instead of loading the entire query result into memory.Places that currently depend on it being an array are wrapped in
iterator_to_array(They are mostly queries returning small results, so this isn't expensive. The optimization is mostly useful for places like the dataquery module which iterate over large amounts of data.)