You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calls to TransactionHistoryService.streamByCriteria currently lack strong guarantee about transaction order. Naturally postgres will return them in order they are stored and that is historical order. Occasionally due to vacuuming order might be messed. Explicit order by is required. The best way to do that is to ORDER BY blocks.height, transactions.sequence, but postgres lacks cross-table indexes to make such ordering efficient. To deal with that block_height column has to be added to transactions table, composite foreign key can be used to ensure that block_id and block_height point to the same row. Then index over transactions(block_height, sequence) can be created and ORDER BY block_height, sequence can be executed quickly.
Later same index can also be used by API to return transactions in reverse order instead of relying on timestamp.
The text was updated successfully, but these errors were encountered:
Calls to
TransactionHistoryService.streamByCriteria
currently lack strong guarantee about transaction order. Naturally postgres will return them in order they are stored and that is historical order. Occasionally due to vacuuming order might be messed. Explicit order by is required. The best way to do that is toORDER BY blocks.height, transactions.sequence
, but postgres lacks cross-table indexes to make such ordering efficient. To deal with thatblock_height
column has to be added totransactions
table, composite foreign key can be used to ensure thatblock_id
andblock_height
point to the same row. Then index overtransactions(block_height, sequence)
can be created andORDER BY block_height, sequence
can be executed quickly.Later same index can also be used by API to return transactions in reverse order instead of relying on timestamp.
The text was updated successfully, but these errors were encountered: