user2277: What output had the longest period between when it was created and eventually spent?

user63872: As of 20 May 2020, there is a new record:
The UTXO had a value of 50 BTC, and was created in this coinbase transaction, in block 3,654:
f38d6f043c070ce9805ee81f46db4d32d0c9f148d62bbfbc0378bc5847c7dc70
The UTXO was then spent in this transaction, sending 40 BTC to one address, and ~10 BTC (less fees) to another address, in block 631,058:
cb1440c787d8a46977886405a34da89939e1b04907f567bf182ef27ce53a8d71
The UTXO was thus held for 627,404 blocks, or about 11 years, 3 months and 11 days. 
At the time it was spent, the output was worth just under $500,000 USD. When it was spent, there were 205,887.48 bitcoin days destroyed. 

user2277: As of June 19 2019, using the following query:
bitcoin-indexer=> select reverse_bytes(output_tx.hash_id || output_tx.hash_rest),
 output.tx_idx,
 output_tx.current_height,
 input_tx.current_height,
 input_tx.current_height - output_tx.current_height from output
 inner join input on input.output_tx_hash_id = output.tx_hash_id AND input.output_tx_idx = output.tx_idx
 join tx as output_tx on output.tx_hash_id = output_tx.hash_id
 join tx as input_tx on input.tx_hash_id = input_tx.hash_id
order by (input_tx.current_height - output_tx.current_height) desc limit 40;

against fully indexed blockchain (using rust-bitcoin-indexer), I was able to identify the coinbase of d5a045c9d8a5bf7619c52968945c494d49333b80d51f1d0e2747b9e8bb2c6709 as the longest held UTXO ever spent (so far).
It was created in block 45697 and spent in block 559367, which lasted 8 years 10 months and 3 days.
The full set of results:
                           reverse_bytes                            | tx_idx | current_height | current_height | ?column?
--------------------------------------------------------------------+--------+----------------+----------------+----------                
 \xd5a045c9d8a5bf7619c52968945c494d49333b80d51f1d0e2747b9e8bb2c6709 |      0 |          45697 |         559367 |   513670
 \x67e8d773078b75fb5680089b8d2d380be93943a1dcf9c37e309d517a98e5d40c |      0 |          66188 |         570705 |   504517
 \x9c90d07be3d18c7a3612cd971934ed89c0d07fa302d4922481d1114dfaedc93d |      0 |          73303 |         577470 |   504167
 \x7a8a36f68d265ff49e4df5215a2a6dd922dbfbb6cc695399d2b10efd4a75c47d |      0 |          52632 |         553012 |   500380
 \x08ca56db26ad6d171e7fbcb24e592590bf369d70fc5931eb3790278681f35768 |      0 |          52644 |         551281 |   498637
 \x5fba526502ee887bc1e6beb0255cfcdfaaf41e0d25e233e447e585458ed37ac5 |      0 |          52652 |         551281 |   498629
 \x9596d84e671daea6ee965244ca75e204dfa72a471db3cb51dc406fbfeacc2e92 |      0 |          69951 |         567828 |   497877
 \x82b6f02c86fd3afb5ca23b7bf88d509e92516129dc36ceb4864114ed5ec710f5 |      0 |          66446 |         563621 |   497175
 \x31a67bf1f3cf01351b76cb16931ceb45c670b50af850181ab586d97040d90a1b |      0 |          82729 |         579816 |   497087
 \x463b0f7c96214418af0f50836047ce0e9cbc5940b739d7d67eed1842e2edf768 |      0 |          82944 |         579816 |   496872                  
 \x508d7a4ff36cda617aecd02da86fd5449176b0c75d3e398242253dbce6d54eeb |      1 |          83477 |         579817 |   496340                 
 \x4e0584a90c9dce50ecd9ed1b2d79a3a8af0f690041dccc035fd81f06ac200571 |      0 |          56710 |         551275 |   494565                  
 \xc6c9e4be37ea843fe50df740b5acba5d23c894a4b68191b1c157b281a8a985c5 |      0 |          74897 |         568169 |   493272
 \x9296baa58de452d15763079e71861f5580863c462ce855a41e485e92f28f6e98 |      1 |          68586 |         560782 |   492196
 \x404116e265c3717b403697ea226f6d839a24f88009b1802b978b692edca95cf4 |      0 |          59137 |         551279 |   492142
 \xf6a0cc22d749a299c83c86df3406b9d6d9e6a70215978363ef5e884812112461 |      0 |          60717 |         551279 |   490562
 \xa28a27378b3499997d1c990813adddbd25e470e0b44510896435b9a918968a0b |      0 |          61047 |         551272 |   490225                 
 \x36a230b30815e40d238f27f2654ff3681f6c1931076e90c4c05065002b9d91e6 |      0 |          73788 |         562598 |   488810
 \xdcc71895e1baf0abb83ff27348211662b517105b18789f4410a55a51dc50a156 |      0 |          66637 |         555282 |   488645
 \x899ee05d5c4e91b3ee49958a9d0333ff9b1987c352d946ecdb1fd91588f667ac |      0 |          66336 |         554738 |   488402
 \x6284dc97c5c923308675e9b0db88210ad61a42815caaf024b07cc0eb9e262c67 |      0 |          33538 |         521167 |   487629
 \x56102337f6f10161a2286fe1ffb91e353b13a17db6a41c6149574d6dae476528 |      0 |          33590 |         521167 |   487577
 \xf398b7e93220747aa2f45f36284606b2ae802741160f28f2fd3f2afa40bfd346 |      0 |          66627 |         553372 |   486745
 \x708d840ea0041386b4376896b14e510d0cad3cdaeb707fe93ab2d33372723503 |      0 |          68283 |         554738 |   486455
 \x452e2d312a18d907f2ef1ec976b1ed18ef2f5a079ee47037a346f260bad339e2 |      0 |          33784 |         519776 |   485992
 \x0c1739923133af9f52a5764227f2da487f5f4520b5d0127c0867062a311cfeca |      0 |          65671 |         551393 |   485722
 \x6f69ff89b936ac2120cbdc824138022de749977202153680b199bfb1d8afba75 |      1 |          89869 |         575308 |   485439
 \xfcc26559921b51b07cf81d858689a4007fc9cf8fad96d4394da89e3e2d1a1299 |      0 |          91948 |         576386 |   484438
 \xd1ff751609b5a74f99573d7d7baa1c1dc493c9bebd586f6bf381ee0877282ed2 |      0 |          97810 |         579234 |   481424
 \x583b6351a67d96fc42c5294ee4282616c5bd1481e464720cb959fa4c3a5ce192 |      0 |          70534 |         551654 |   481120
 \x836f332753244b3eaa6ea80ddcd59d6727de8874abef09f5f5bfa44d05025d05 |      0 |          70541 |         551654 |   481113
 \xee2feeca4e02840b7036e28045a5dfd06ab65af5b1068cd9598ec3b87d4f4b32 |      1 |          70542 |         551654 |   481112
 \xb0d701da413083e89f00f824a8300387ded7671ca3ca967811c758019cfaf3ba |      0 |          93709 |         574785 |   481076
 \x23b140fb832912031596256b184010e52e24cf66da94dabc80770970087d2f82 |      1 |          92499 |         573193 |   480694
 \x7712a8c8752090e8fa9527603ed08f72b00ace2b9a495d91e78523ff50844182 |      0 |          77095 |         555959 |   478864
 \xed151ae3b0d1cd50df1f97cc4b8747d185b56f54f5aef3754079faa089e3e783 |      0 |          83936 |         561411 |   477475
 \x8d432c241971e25172268765b219d6ed82c3868981a85c9189812b57ddd28912 |      0 |          97972 |         574951 |   476979
 \xcfc9154235db58abd3f09bfd277b084a95ccbd03ed2161d0ab4ef4ed36166821 |      0 |          84411 |         561076 |   476665
 \x5ad52480756416f6288be488f14392799c0ea2d050f96d4306b846d516b02f80 |      1 |          82966 |         558812 |   475846
 \x269bbd2cd3dd7f88da4ca7086e75d36f0d2d4a54b1b5f0ed7509f7375cc71715 |      0 |           3607 |         479423 |   475816
(40 rows)


2277: <p>What output had the longest period between when it was created and eventually spent?</p>
 63872: <p>As of 20 May 2020, there is a new record:</p>

<p>The UTXO had a value of 50 BTC, and was created in this coinbase transaction, in block 3,654:</p>

<p><code>f38d6f043c070ce9805ee81f46db4d32d0c9f148d62bbfbc0378bc5847c7dc70</code></p>

<p>The UTXO was then spent in this transaction, sending 40 BTC to one address, and ~10 BTC (less fees) to another address, in block 631,058:</p>

<p><code>cb1440c787d8a46977886405a34da89939e1b04907f567bf182ef27ce53a8d71</code></p>

<p>The UTXO was thus held for 627,404 blocks, or about 11 years, 3 months and 11 days. </p>

<p>At the time it was spent, the output was worth just under $500,000 USD. When it was spent, there were 205,887.48 <a href="https://bitcoin.stackexchange.com/questions/845/what-are-bitcoin-days-destroyed">bitcoin days destroyed</a>. </p>
 2277: <p>As of June 19 2019, using the following query:</p>

<pre><code>bitcoin-indexer=&gt; select reverse_bytes(output_tx.hash_id || output_tx.hash_rest),
 output.tx_idx,
 output_tx.current_height,
 input_tx.current_height,
 input_tx.current_height - output_tx.current_height from output
 inner join input on input.output_tx_hash_id = output.tx_hash_id AND input.output_tx_idx = output.tx_idx
 join tx as output_tx on output.tx_hash_id = output_tx.hash_id
 join tx as input_tx on input.tx_hash_id = input_tx.hash_id
order by (input_tx.current_height - output_tx.current_height) desc limit 40;
</code></pre>

<p>against fully indexed blockchain (using <a href="https://github.com/dpc/rust-bitcoin-indexer" rel="noreferrer">rust-bitcoin-indexer</a>), I was able to identify the coinbase of <a href="https://blockchair.com/bitcoin/transaction/d5a045c9d8a5bf7619c52968945c494d49333b80d51f1d0e2747b9e8bb2c6709" rel="noreferrer"><code>d5a045c9d8a5bf7619c52968945c494d49333b80d51f1d0e2747b9e8bb2c6709</code></a> as the longest held UTXO ever spent (so far).</p>

<p>It was created in block 45697 and spent in block 559367, which lasted 8 years 10 months and 3 days.</p>

<p>The full set of results:</p>

<pre><code>                           reverse_bytes                            | tx_idx | current_height | current_height | ?column?
--------------------------------------------------------------------+--------+----------------+----------------+----------                
 \xd5a045c9d8a5bf7619c52968945c494d49333b80d51f1d0e2747b9e8bb2c6709 |      0 |          45697 |         559367 |   513670
 \x67e8d773078b75fb5680089b8d2d380be93943a1dcf9c37e309d517a98e5d40c |      0 |          66188 |         570705 |   504517
 \x9c90d07be3d18c7a3612cd971934ed89c0d07fa302d4922481d1114dfaedc93d |      0 |          73303 |         577470 |   504167
 \x7a8a36f68d265ff49e4df5215a2a6dd922dbfbb6cc695399d2b10efd4a75c47d |      0 |          52632 |         553012 |   500380
 \x08ca56db26ad6d171e7fbcb24e592590bf369d70fc5931eb3790278681f35768 |      0 |          52644 |         551281 |   498637
 \x5fba526502ee887bc1e6beb0255cfcdfaaf41e0d25e233e447e585458ed37ac5 |      0 |          52652 |         551281 |   498629
 \x9596d84e671daea6ee965244ca75e204dfa72a471db3cb51dc406fbfeacc2e92 |      0 |          69951 |         567828 |   497877
 \x82b6f02c86fd3afb5ca23b7bf88d509e92516129dc36ceb4864114ed5ec710f5 |      0 |          66446 |         563621 |   497175
 \x31a67bf1f3cf01351b76cb16931ceb45c670b50af850181ab586d97040d90a1b |      0 |          82729 |         579816 |   497087
 \x463b0f7c96214418af0f50836047ce0e9cbc5940b739d7d67eed1842e2edf768 |      0 |          82944 |         579816 |   496872                  
 \x508d7a4ff36cda617aecd02da86fd5449176b0c75d3e398242253dbce6d54eeb |      1 |          83477 |         579817 |   496340                 
 \x4e0584a90c9dce50ecd9ed1b2d79a3a8af0f690041dccc035fd81f06ac200571 |      0 |          56710 |         551275 |   494565                  
 \xc6c9e4be37ea843fe50df740b5acba5d23c894a4b68191b1c157b281a8a985c5 |      0 |          74897 |         568169 |   493272
 \x9296baa58de452d15763079e71861f5580863c462ce855a41e485e92f28f6e98 |      1 |          68586 |         560782 |   492196
 \x404116e265c3717b403697ea226f6d839a24f88009b1802b978b692edca95cf4 |      0 |          59137 |         551279 |   492142
 \xf6a0cc22d749a299c83c86df3406b9d6d9e6a70215978363ef5e884812112461 |      0 |          60717 |         551279 |   490562
 \xa28a27378b3499997d1c990813adddbd25e470e0b44510896435b9a918968a0b |      0 |          61047 |         551272 |   490225                 
 \x36a230b30815e40d238f27f2654ff3681f6c1931076e90c4c05065002b9d91e6 |      0 |          73788 |         562598 |   488810
 \xdcc71895e1baf0abb83ff27348211662b517105b18789f4410a55a51dc50a156 |      0 |          66637 |         555282 |   488645
 \x899ee05d5c4e91b3ee49958a9d0333ff9b1987c352d946ecdb1fd91588f667ac |      0 |          66336 |         554738 |   488402
 \x6284dc97c5c923308675e9b0db88210ad61a42815caaf024b07cc0eb9e262c67 |      0 |          33538 |         521167 |   487629
 \x56102337f6f10161a2286fe1ffb91e353b13a17db6a41c6149574d6dae476528 |      0 |          33590 |         521167 |   487577
 \xf398b7e93220747aa2f45f36284606b2ae802741160f28f2fd3f2afa40bfd346 |      0 |          66627 |         553372 |   486745
 \x708d840ea0041386b4376896b14e510d0cad3cdaeb707fe93ab2d33372723503 |      0 |          68283 |         554738 |   486455
 \x452e2d312a18d907f2ef1ec976b1ed18ef2f5a079ee47037a346f260bad339e2 |      0 |          33784 |         519776 |   485992
 \x0c1739923133af9f52a5764227f2da487f5f4520b5d0127c0867062a311cfeca |      0 |          65671 |         551393 |   485722
 \x6f69ff89b936ac2120cbdc824138022de749977202153680b199bfb1d8afba75 |      1 |          89869 |         575308 |   485439
 \xfcc26559921b51b07cf81d858689a4007fc9cf8fad96d4394da89e3e2d1a1299 |      0 |          91948 |         576386 |   484438
 \xd1ff751609b5a74f99573d7d7baa1c1dc493c9bebd586f6bf381ee0877282ed2 |      0 |          97810 |         579234 |   481424
 \x583b6351a67d96fc42c5294ee4282616c5bd1481e464720cb959fa4c3a5ce192 |      0 |          70534 |         551654 |   481120
 \x836f332753244b3eaa6ea80ddcd59d6727de8874abef09f5f5bfa44d05025d05 |      0 |          70541 |         551654 |   481113
 \xee2feeca4e02840b7036e28045a5dfd06ab65af5b1068cd9598ec3b87d4f4b32 |      1 |          70542 |         551654 |   481112
 \xb0d701da413083e89f00f824a8300387ded7671ca3ca967811c758019cfaf3ba |      0 |          93709 |         574785 |   481076
 \x23b140fb832912031596256b184010e52e24cf66da94dabc80770970087d2f82 |      1 |          92499 |         573193 |   480694
 \x7712a8c8752090e8fa9527603ed08f72b00ace2b9a495d91e78523ff50844182 |      0 |          77095 |         555959 |   478864
 \xed151ae3b0d1cd50df1f97cc4b8747d185b56f54f5aef3754079faa089e3e783 |      0 |          83936 |         561411 |   477475
 \x8d432c241971e25172268765b219d6ed82c3868981a85c9189812b57ddd28912 |      0 |          97972 |         574951 |   476979
 \xcfc9154235db58abd3f09bfd277b084a95ccbd03ed2161d0ab4ef4ed36166821 |      0 |          84411 |         561076 |   476665
 \x5ad52480756416f6288be488f14392799c0ea2d050f96d4306b846d516b02f80 |      1 |          82966 |         558812 |   475846
 \x269bbd2cd3dd7f88da4ca7086e75d36f0d2d4a54b1b5f0ed7509f7375cc71715 |      0 |           3607 |         479423 |   475816
(40 rows)
</code></pre>
