-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#24346) (#24562) * feat: `frappe.db.sql` results `as_iterator` (backport #19810) (#24346) * feat: `frappe.db.sql` results as iterator - Also avoid self.last_result that holds on to large result set reference. (cherry picked from commit 588157d) # Conflicts: # frappe/database/database.py * perf: avoid duplicate copies of result set When as_list, as_dict is done we hold on to original result set until next query is performed. This can be HUGE for large queries. (cherry picked from commit d5b2706) * test: add perf test for references (cherry picked from commit 03b6d8a) * chore: conflict * perf: Unbuffered cursors for large result sets (#24365) If you're reading 1000s of rows from MySQL, the default behaviour is to read all of them in memory at once. One of the use case for reading large rows is reporting where a lot of data is read and then processed in Python. The read row is hoever not used again but still consumes memory until entire function exits. SSCursor (Server Side Cursor) allows fetching one row at a time. Note: This is slower than fetching everything at once AND has risk of connection loss. So, don't use this as a crutch. If possible rewrite code so processing is done in SQL. --------- Co-authored-by: Ankush Menat <ankush@frappe.io> (cherry picked from commit 99a3a35) # Conflicts: # frappe/database/database.py # frappe/database/mariadb/database.py # pyproject.toml * chore: conflicts * chore: remove test for dead functionality --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Ankush Menat <ankush@frappe.io>
- Loading branch information
1 parent
41d2fe2
commit 7f3a12b
Showing
5 changed files
with
148 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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