From 54c38fe587f633106b924bea9358a5342db3bd1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enis=20Bayramo=C4=9Flu?= Date: Wed, 4 Jan 2023 14:48:19 +0100 Subject: [PATCH 1/2] Optimize the recent transactions query --- exec/Chainweb/Server.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec/Chainweb/Server.hs b/exec/Chainweb/Server.hs index 3e8f125c..98f1ed5a 100644 --- a/exec/Chainweb/Server.hs +++ b/exec/Chainweb/Server.hs @@ -654,7 +654,7 @@ queryRecentTxs logger pool = do guard_ (_tx_block tx `references_` blk) return ( (_tx_chainId tx) - , (_block_height blk) + , (_tx_height tx) , (unBlockId $ _tx_block tx) , (_tx_creationTime tx) , (_tx_requestKey tx) From b2923e4c18436e32bd51b6356c1fc6518e58db82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enis=20Bayramo=C4=9Flu?= Date: Wed, 4 Jan 2023 14:58:16 +0100 Subject: [PATCH 2/2] Avoid the JOIN on the blocks table entirely Now that we're reading the tx height from the transaction itself, we don't have any reason left to JOIN on the blocks table --- exec/Chainweb/Server.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/exec/Chainweb/Server.hs b/exec/Chainweb/Server.hs index 98f1ed5a..7842fe0e 100644 --- a/exec/Chainweb/Server.hs +++ b/exec/Chainweb/Server.hs @@ -650,8 +650,6 @@ queryRecentTxs logger pool = do runSelectReturningList $ select $ do limit_ 20 $ orderBy_ (desc_ . getHeight) $ do tx <- all_ (_cddb_transactions database) - blk <- all_ (_cddb_blocks database) - guard_ (_tx_block tx `references_` blk) return ( (_tx_chainId tx) , (_tx_height tx)