uranusjr commented on issue #18050:
URL: https://github.com/apache/airflow/issues/18050#issuecomment-917664028


   The problem with a partial match is that `LIKE` queries (which is what I 
imagine `startswith()` would produce) can easily end up producing a table scan, 
so I’d be extremely wary to the proposal unless someone carefully analyses the 
situations for all database backends we support. A practical 0-9 (or 1-10, 
don’t remember what scheme we’re using right now) would work though since we 
can simply flatten the query as a series of `OR`s instead. That’s guaranteed to 
be quite efficient, so I’d be fine with that. The logic would be like
   
   1. When duplicating a connection, generate up to 10 possible ids for the 
duplication and query the db to find an empty slot by querying the 10 ids all 
at once.
   2. Loop through the query result to find the lowerest-numbered empty slot to 
use.
   3. If the query returns 10 results (i.e. no empty slots available), emit an 
error asking the user to rename one of the existing connections first.


-- 
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]


Reply via email to