You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "PolitePp (via GitHub)" <gi...@apache.org> on 2026/09/01 05:04:24 UTC

[I] ti.get_previous_ti method is not optimized [airflow]

PolitePp opened a new issue, #72358:
URL: https://github.com/apache/airflow/issues/72358

   ### Under which category would you file this issue?
   
   Airflow Core
   
   ### Apache Airflow version
   
   3.3.0
   
   ### What happened and how to reproduce it?
   
   When we execute `ti.get_previous_ti(state='success')` airflow collects all task instances from the database and then gets the latest on api side. It's not effective, because the query itself already has sorting by the date
   
   ### What you think should happen instead?
   
   We can add limit 1 to the query and prevent api load
   
   ### Operating System
   
   _No response_
   
   ### Deployment
   
   None
   
   ### Apache Airflow Provider(s)
   
   _No response_
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   _No response_
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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: commits-unsubscribe@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] ti.get_previous_ti method is not optimized [airflow]

Posted by "shahar1 (via GitHub) via commits" <co...@airflow.apache.org>.
shahar1 commented on issue #72358:
URL: https://github.com/apache/airflow/issues/72358#issuecomment-6687119350

   Solved by https://github.com/apache/airflow/pull/72699


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] ti.get_previous_ti method is not optimized [airflow]

Posted by "shahar1 (via GitHub) via commits" <co...@airflow.apache.org>.
shahar1 closed issue #72358: ti.get_previous_ti method is not optimized
URL: https://github.com/apache/airflow/issues/72358


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] ti.get_previous_ti method is not optimized [airflow]

Posted by "LiamHecht (via GitHub)" <gi...@apache.org>.
LiamHecht commented on issue #72358:
URL: https://github.com/apache/airflow/issues/72358#issuecomment-6385159943

   This looks fixed already. #72699 added the `.limit(1)` to the previous-TI lookup in `get_previous_task_instance` (merged to `main` on 2026-09-09, included in 3.4.0b1). It was backported to `v3-3-test` in #72842, so it should ship in 3.3.3. It is not in 3.3.2.
   
   On current `main` the query also stays bounded for loop tasks: it fetches one row with `.limit(1)`, and the loop-iteration path is capped at 500 rows.
   
   If you can confirm on 3.4.0b2 (or 3.3.3 once released), this issue can probably be closed.
   
   ---
   Drafted-by: Claude Code (Opus 5.5) (no human review before posting)
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org