Get the block where a satoshi of an input was mined

0
0
Hi all,
Given a transaction, I am trying to find the coinbase tx(s) that one of its inputs derives from. It is theoretically possible to recursively look for all inputs of past transactions until a coinbase is found, but this is a naive method that would scale very, very badly.
For example, this ordinal explorer gives the creation block of the satoshi associated with the ordinal: https://www.ord.io/81440
Does anyone have an idea of how they do that?
Thank you!