In SQL query workspaces, the result cap limit (_resultMaxRows) is applied after the client drivers fetch the entire result set into Dart memory:
- postgres_sql_workspace.dart
- mysql_sql_workspace.dart
If a user executes a query matching millions of rows without a SQL LIMIT clause, the database driver loads all matching records into memory first. This can trigger thread-blocking CPU spikes or Out of Memory (OOM) app crashes.
Steps to fix:
- Transition query execution to use streaming/cursors (e.g. portals in PostgreSQL or streaming API in MySQL) to only pull up to
_resultMaxRows rows from the network socket.
- Alternatively, dynamically append/inject a SQL
LIMIT clause during execution if the query doesn't already contain one.
In SQL query workspaces, the result cap limit (
_resultMaxRows) is applied after the client drivers fetch the entire result set into Dart memory:If a user executes a query matching millions of rows without a SQL
LIMITclause, the database driver loads all matching records into memory first. This can trigger thread-blocking CPU spikes or Out of Memory (OOM) app crashes.Steps to fix:
_resultMaxRowsrows from the network socket.LIMITclause during execution if the query doesn't already contain one.