HomeSoftware Heritage

postgresql: Ensure a minimum limit for the snapshot branches query

Description

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 P966

Details