Skip to content

Commit

Permalink
Merge pull request #468 from input-output-hk/perf/ledger-tip-query
Browse files Browse the repository at this point in the history
perf(cardano-services): order by block.id in ledger tip queries
  • Loading branch information
rhyslbw committed Sep 28, 2022
2 parents 4afdf79 + b985d3f commit 48979ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const findTip = `
hash,
slot_no
FROM block
ORDER BY block.block_no DESC NULLS LAST
ORDER BY block.id DESC
LIMIT 1`;

export const findBlocksByHashes = `
Expand All @@ -83,7 +83,7 @@ export const findBlocksByHashes = `
LEFT JOIN block AS prev_blk ON block.previous_id = prev_blk.id
LEFT JOIN pool_hash AS pool ON pool.id = leader.pool_hash_id
WHERE block.hash = ANY($1)
ORDER BY block.block_no ASC NULLS LAST`;
ORDER BY block.id ASC`;

export const findBlocksOutputByHashes = `
SELECT
Expand All @@ -94,7 +94,7 @@ export const findBlocksOutputByHashes = `
JOIN block ON block.id = tx.block_id
WHERE block.hash = ANY($1)
GROUP BY block.hash, block.id
ORDER BY block.block_no ASC NULLS LAST`;
ORDER BY block.id ASC`;

export const findMultiAssetByTxOut = `
SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const findLatestCompleteEpoch = `
export const findLedgerTip = `
SELECT block_no, slot_no, hash
FROM block
ORDER BY block_no DESC NULLS LAST
ORDER BY id DESC
LIMIT 1;
`;

Expand Down

0 comments on commit 48979ea

Please sign in to comment.