HomeSoftware Heritage

postgresql: ensure origin_visit(_status) queries use index

Description

postgresql: ensure origin_visit(_status) queries use index

When using an inner join for the single origin value, instead of a
subquery, the query fails to use the (origin, visit) indexes and falls
back to fetching all the visits (or all the statuses) for the origin and
sorting them.

This breaks down for origins with a lot of visits, such as the ones that
are being used for end to end monitoring.

Using a subselect to generate a single origin id value ensures that the
queries can use the proper indexes.

Details

Provenance
olasdAuthored on Apr 12 2022, 1:53 PM
olasdPushed on Apr 12 2022, 2:32 PM
Differential Revision
D7554: postgresql: ensure origin_visit(_status) queries use index
Parents
rDSTO035d4c1dd19e: origin_get_with_statuses: Rename RPC endpoint path
Branches
Unknown
Tags
Unknown
References
tag: v1.3.1
Build Status
Buildable 28401
Build 44408: test-and-buildJenkins console · Jenkins