Skip to content

Performance: Post-Fetch SQL Result Capping Memory Spike Risk (PostgreSQL / MySQL) #184

Description

@ZhuchkaTriplesix

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:

  1. 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.
  2. Alternatively, dynamically append/inject a SQL LIMIT clause during execution if the query doesn't already contain one.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions