Inefficient query generated on vault queries with custom paging

Description

On postgres, when running vault queries with custom paging this is the generated sql:

The `vault_states` table is joined with itself for no reason.
This has a significant performance impact when the `vault_states` is large.

Assignee

Unassigned

Reporter

Tudor Malene

Labels

None

Priority

High

Fix versions

Ported to...

None

Feature Team

Kernel Group

CVSS Vector

None

Engineering Teams

None

Severity

Critical

Affects versions

Configure