Skip to content
CCPEDIAby Unity Nodes
App Development

Are active and archived contracts on the same table in Canton-on-postgres context ? Will archiving a huge amount of contracts affect performance?

2 posts283 views3 likesLast activity Apr 2022

  1. jaypeedaOP 2

    Hi team,

    Are active and archived contracts on the same table in Canton-on-postgres context ?
    We are trying to understand whether archiving a huge amount of contracts would affect the performance…

    Thanks and Regards,
    Jean-Paul

  2. MatthiasSchmalz 1

    Hi Jean-Paul

    There are two tables relevant here:

    1. The contracts table stores contract data. No change, if you archive a contract. If you prune the participant, the data of archived contracts will be deleted, if the contract has been archived before the pruning threshold.
      canton/V1_1__initial.sql at 04cab0f2296f98baaafc6478f208a9621bba7d1f · digital-asset/canton · GitHub

    2. The active_contracts table stores the state of a contract (active, archived, transferred away). If you archive a contract, a new line will be appended to this table. If you prune, the lines referring to contracts archived before the pruning threshold will be removed.
      canton/V1_1__initial.sql at 04cab0f2296f98baaafc6478f208a9621bba7d1f · digital-asset/canton · GitHub

    Overall, if you have a huge number of archived contracts, reading from these tables will slow down. But it should only slow down by O(log(#contracts)), due to the indices on these tables.

    Hope that answers your question.
    Matthias