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>![category 
Performance](https://img.shields.io/badge/Performance-4f46e5)</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>
   
   [![Report a problem with this 
comment](https://img.shields.io/badge/Report%20a%20problem%20with%20this%20comment-gray.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNmNWVjMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10cmlhbmdsZS1hbGVydCI+PHBhdGggZD0ibTIxLjczIDE4LTgtMTRhMiAyIDAgMCAwLTMuNDggMGwtOCAxNEEyIDIgMCAwIDAgNCAyMWgxNmEyIDIgMCAwIDAgMS43My0zIi8+PHBhdGggZD0iTTEyIDl2NCIvPjxwYXRoIGQ9Ik0xMiAxN2guMDEiLz48L3N2Zz4=)](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]

Reply via email to