FlattenExternalIds derived its inserted_at bound from a CTE in the same
statement, so partitions of v1_task, v1_dag and v1_dag_to_task could only
be pruned at execution time, after every one of them had been locked.
Resolve the ids through v1_lookup_table first and pass the range to the
v1_task and DAG statements as plain parameters under a custom plan, so
the planner prunes before locking. The DAG join only runs when a lookup
row points at a DAG.
Add ResolveTaskExternalIds, which maps task external ids to their primary
keys from the lookup table alone behind an LRU cache, and use it in the
dispatcher's worker-status handler and the scheduler's dead-lettered
durable callback handler, which never needed the task row.