Skip to content

Limit the number of origin_visit(_status) joined with origins before sorting.

Without the limit on the subquery, postgresql greatly overestimates the number of items in the cardinal product, which causes it to prefer doing an ordered scan on origins rather than filtering on sorting, which is extremely slow.

Adding this limit bounds the size of the cardinal product to the number of matches in the origin index, which postgresql knows to be low, so it automatically prefers the index scan.


Migrated from D3606 (view on Phabricator)

Merge request reports