Skip to content

postgresql: Ensure a minimum limit for the snapshot branches query

With small limits (< 10), the snapshot branches query can degenerate into using the deduplication index on snapshot_branch (name, target, target_type), and the postgresql planner happily scans several hundred million rows.

So ensure a minimum limit value of 10 before executing the query for optimal performances when a small branches_count value is provided to the snapshot_get_branches method of the Storage interface.

Related to swh/meta$963

Test Plan

Testing the snapshot_get_branches method with small branches_count values is already done in current tests.


Migrated from D5191 (view on Phabricator)

Merge request reports