bito-code-review[bot] commented on PR #42203:
URL: https://github.com/apache/superset/pull/42203#issuecomment-5011939656
<!-- Bito Reply -->
The flagged performance issue is correct. Unconditionally calling
`list(data)` creates a full copy of the result set in memory, which can lead to
memory spikes or OOM errors for large queries. To resolve this, you should only
convert `data` to a list if it is not already a mutable sequence (e.g., if it
is a tuple).
Here is the proposed fix for `superset/db_engine_specs/base.py`:
```python
if column_mutators:
if not isinstance(data, list):
data = list(data)
indexes = {row[0]: idx for idx, row in
enumerate(description)}
```
This change ensures that if `fetchall()` already returns a list (as is
common with many DB drivers), the memory-intensive copy is avoided. I have
checked the other comments on this PR, and there are no other actionable review
comments to address. Would you like me to proceed with any other changes?
**superset/db_engine_specs/base.py**
```
if column_mutators:
if not isinstance(data, list):
data = list(data)
indexes = {row[0]: idx for idx, row in
enumerate(description)}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]