One of the most costly aspects initially was the bitcoind "unspendable" distinction (arbitrary, basically just script too long and first opcode is op_return), required hitting the output table body for every single output during the scan. I was able to bypass that entirely by setting that bit into the outs association table when each output is written (essentially free), and was able to merge this bit into an existing oversized link (still > 10 years of run time) to avoid any store size increase. We have a far more expansive concept of unspendable which is set during script parse, allowing script validation to be bypassed. But that's not cached and wouldn't help here anyway. IOW, there are a lot of provably unspendable scripts that are considered unspent (spendable) by Core, and those get counted in this accounting.