Remove using distinct sql clause for Environment associations preloading
As part of last_deployment
association we were using DISTINCT ON
SQL
SELECT
DISTINCT ON (environment_id) deployments.*
FROM
"deployments"
WHERE
"deployments"."status" = 2
AND "deployments"."environment_id" IN (137, 8098355)
ORDER BY
environment_id,
deployments.id DESC
and it is not good in terms of performance. See issue #345672 (closed)
We are introducing a custom preloader which does preload with_union
and it is more efficient. So clean up the other places (old callers) where distinct_on_environment
is used.
More details: !75767 (comment 806416386)
Edited by Bala Kumar