What is Nostr?
andrew / Andrew
npub1kun…p0ge
2023-01-02 08:28:42

andrew on Nostr: b=# with recursive h(blockhash,height) as ( select ...

b=# with recursive h(blockhash,height) as (
select '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'::sha256,0
union
select blocks.hash,height+1 from h,blocks where h.blockhash=prev
) select * from h;
Time: 1951.347 ms (00:01.951)

A bit of fun with recursive CTEs in PostgreSQL. Crazy fast if you think this is functionally a million JOINs between two tables with a million rows each.
Author Public Key
npub1kundug94z4c9llhf29v3ar657she8wu9p80cr2z3e4dujj0vzveqwpp0ge