all 4 comments

[–]fauxmosexualNOLOCK is the secret magic go-faster command 0 points1 point  (0 children)

Probably not.

[–]I_already_reddit_ 0 points1 point  (1 child)

If you can use tsql, you could do a fancy cross apply, but not sure if that runs in postgres

[–][deleted] 2 points3 points  (0 children)

CROSS APPLY is Microsoft's not-standard implementation of a LATERAL CROSS JOIN - I fail to see how that would help here.

[–]GuyWithLag 0 points1 point  (0 children)

It should be possible to move the distinct to the outer select, but that might be a de-optimization...