v.20.5Performance Improvement

Remove Duplicate ORDER BY and DISTINCT from Subqueries for Optimization

Remove duplicate ORDER BY and DISTINCT from subqueries, this optimization is enabled with optimize_duplicate_order_by_and_distinct #10067 (Mikhail Malafeev).