korbit-ai[bot] commented on code in PR #32500:
URL: https://github.com/apache/superset/pull/32500#discussion_r1980247237
##########
superset/commands/dataset/importers/v1/utils.py:
##########
@@ -113,10 +113,18 @@ def import_dataset( # noqa: C901
"Dataset",
)
existing =
db.session.query(SqlaTable).filter_by(uuid=config["uuid"]).first()
Review Comment:
### Redundant Database Queries <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
Multiple database queries are made for the same UUID lookup - one in
import_dataset() and another in the exception handler for MultipleResultsFound.
###### Why this matters
This creates unnecessary database round-trips that impact performance,
especially when importing multiple datasets.
###### Suggested change ∙ *Feature Preview*
Cache the initial query result and reuse it in the exception handler:
```python
query = db.session.query(SqlaTable).filter_by(uuid=config["uuid"])
existing = query.first()
# ... later in except MultipleResultsFound
dataset = query
```
</details>
<sub>
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/13a5d6ff-4084-4286-aaa1-af97f7a09a1e?suggestedFixEnabled=true)
💬 Chat with Korbit by mentioning @korbit-ai.
</sub>
<!--- korbi internal id:f0fb64e7-3336-4735-adea-e5f3888ac22e -->
--
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]