[cassandra] snapshot_count_branches timeouts on large snapshots
When attempting to browse an origin with a snapshot containing a large number of branches, the snapshot_count_branches
operation timeouts with the cassandra storage backend.
For instance, when browsing https://archive.softwareheritage.org/browse/origin/directory/?origin_url=https://github.com/web-platform-tests/wpt, the latest snapshot for that origin is bd9a5ff52282a9f189334dde60ab799f84ee2cbb
and it contains 106567
branches.
softwareheritage=> select count(*) from snapshot_branches where snapshot_id = (select object_id from snapshot where id = decode('bd9a5ff52282a9f189334dde60ab799f84ee2cbb', 'hex'));
count
--------
106567
(1 row)
I think we should split the queries to get a snapshot size into multiple ones to avoid being hit by these cassandra timeouts.
Related sentry issue: SWH-STORAGE-2XA3.