getrawtransaction is slower when used with blockhash #22382

issue orweinberger opened this issue on July 1, 2021
  1. orweinberger commented at 1:49 PM on July 1, 2021: none

    Expected behavior

    When using getrawtransaction with an included blockhash, performance should be better as there is no need to scan the entire txindex.

    Actual behavior

    Running getrawtransaction while including the blockhash is ~5x slower.

    <!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->

    To reproduce

    $ time ./bin/bitcoin-cli getrawtransaction 20a93350cd6f4e03dfb6cbb3f104965293627f25c199c1be0e4d187a4ed5f4bb
    020000000001018d3f7d8efaa377dda74892af26c1ca028466d97721d2ea6c74a5cbcf404feb9004000000171600147f5a49a2d89f86ff498103bdbcb1762f9f0ab5aefeffffff08a04a05000000000017a91467a849785bb12f1a03260b3b52ec9dff52b30e708724b80100000000001976a914f0b7e8a5ede232c2654fca3b47f8d0c95f7a561688ac50fe0b00000000001976a914ed06524fb21248a37e7f8f20cdc67e27f49c4f1588acf44f01000000000017a9147422dbf3bdf441a640d09a2a91e6fa40837b019f878d9b3100000000001976a9142a5cd9333e4e94c88f7cd33216b2fc0af15fbd8588ac89b400000000000017a914d05dbcdb4587f1a243cc1ed89e96cd4ec19e24a08778e169180000000017a914f520df8923419f60d9a76df60cfc7a0e3a3fc86f8708d806000000000017a9147246c684dd4890e9c8977e6312c30ecdea2b0a55870247304402205704dd3b6d8930e89c660011ab2f6a42aedcbde438d5f121998e3db6a66889310220054a506aee274f885229d6a9ed89eca17bac87dca401f9c63d07990e98b2f0a301210390e3b178ebc51da1589baee9de37de491dba0575838aacf88c2cd70a06a4486eb47c0a00
    
    real	0m0.003s
    user	0m0.000s
    sys	0m0.002s
    $ time ./bin/bitcoin-cli getrawtransaction 20a93350cd6f4e03dfb6cbb3f104965293627f25c199c1be0e4d187a4ed5f4bb false 0000000000000000000a801776a92ced69dc5fb0a5919271872a9261a613d9c3
    020000000001018d3f7d8efaa377dda74892af26c1ca028466d97721d2ea6c74a5cbcf404feb9004000000171600147f5a49a2d89f86ff498103bdbcb1762f9f0ab5aefeffffff08a04a05000000000017a91467a849785bb12f1a03260b3b52ec9dff52b30e708724b80100000000001976a914f0b7e8a5ede232c2654fca3b47f8d0c95f7a561688ac50fe0b00000000001976a914ed06524fb21248a37e7f8f20cdc67e27f49c4f1588acf44f01000000000017a9147422dbf3bdf441a640d09a2a91e6fa40837b019f878d9b3100000000001976a9142a5cd9333e4e94c88f7cd33216b2fc0af15fbd8588ac89b400000000000017a914d05dbcdb4587f1a243cc1ed89e96cd4ec19e24a08778e169180000000017a914f520df8923419f60d9a76df60cfc7a0e3a3fc86f8708d806000000000017a9147246c684dd4890e9c8977e6312c30ecdea2b0a55870247304402205704dd3b6d8930e89c660011ab2f6a42aedcbde438d5f121998e3db6a66889310220054a506aee274f885229d6a9ed89eca17bac87dca401f9c63d07990e98b2f0a301210390e3b178ebc51da1589baee9de37de491dba0575838aacf88c2cd70a06a4486eb47c0a00
    
    real	0m0.014s
    user	0m0.000s
    sys	0m0.002s
    

    System information

    GCP c2-standard-4 (4 vCPUs, 16 GB memory) with 1TB of persistent SSD

    Ubuntu 20.04.2 LTS Bitcoin Core v0.21.1

  2. orweinberger added the label Bug on Jul 1, 2021
  3. jlopp referenced this in commit dabd77640e on Jul 1, 2021
  4. jlopp referenced this in commit 5ab22ef944 on Jul 1, 2021
  5. jlopp referenced this in commit 6dd28e7688 on Jul 2, 2021
  6. jlopp referenced this in commit 5dd11ea140 on Jul 2, 2021
  7. promag commented at 9:57 PM on July 2, 2021: member

    no need to scan the entire txindex. @orweinberger I think you meant "load the specified block and scan it". BTW was it running with -txindex enabled?

  8. jlopp referenced this in commit 78f4c8b98e on Jul 3, 2021
  9. orweinberger commented at 4:29 PM on July 6, 2021: none

    @promag You're right, that's what I meant. Yes I'm running with txindex=1

  10. MarcoFalke closed this on Jul 22, 2021

  11. MarcoFalke referenced this in commit 7925f3aba8 on Jul 22, 2021
  12. sidhujag referenced this in commit 54a29aafa0 on Jul 23, 2021
  13. rebroad referenced this in commit 6d2529e134 on Jul 29, 2021
  14. DrahtBot locked this on Aug 18, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me