I've noticed that too, but this is delivered Peoplesoft code that we're
not supposed to change.

If I just remove the distinct from the main query, it executes in
seconds. There are only about 5000 rows returned by the non-distinct
version of th equery. Why is simply adding a distinct increasing the the
time from a few seconds to minutes to only sort 5000 rows?