Is it possible to estimate growth of the JSON API query store as the ledger itself grows?

Is it possible to estimate growth of the query store as the ledger itself grows?

1 Like

The query store of the JSON API only stores active contracts and it only stores contracts for templates and parties that have been used in queries. So the size of the query store is roughly the size of the ACS for the templates and parties that have been used in queries.

2 Likes

Thanks for that! Given that, when/how is data in the query store expired/removed?

1 Like

Data is only updated as a result of a query. So when you make the next query involving the same template and parties, contracts that have been archived in the meantime will get removed.

1 Like

So, would this be an accurate description of how the query store works:

  1. The json-api sends the query to the ledger
  2. The ledger responds with absolute contract Ids that match the query params
  3. The query store provides data for Ids it contains, removes any not listed
  4. The json-api requests the contract data for the Ids the query store does not contain
  5. The query store is updated with new contracts, full list of contract data sent back to user as query response
1 Like

Close, there are two cases to consider:

  1. The first query where nothing is in the database. In this case, we fetch the ACS from the ledger, we store it in the database and we record the offset of that ACS.

  2. On following queries, we then fetch the offset from the database, query the transaction stream between this offset and current ledger end and use that to add or remove contracts based on Create and Archive events.

1 Like