SAP Knowledge Base Article - Preview

2098977 - ORDER BY clause causing query to take longer - SAP ASE


  • You are running a query with a UNION ALL clasue and an ORDER BY clause.
  • Without ORDER BY the query runs fast.
  • When appending ORDER BY on a column that is already indexed, the query takes considerably longer to execute.
  • When ORDER BY is used, the query plan shows that the optimizer is spending a lot of time in sorting of a worktable.
  • ASE is configured with the optimization goal "allrows_oltp".



SAP Adaptive Server Enterprise (ASE) 15.x


SAP Adaptive Server Enterprise 15.7 ; Sybase Adaptive Server Enterprise 15.0 ; Sybase Adaptive Server Enterprise 15.5


allrows_mix, allrows_dss, join, nested-loop, hash-joins, merge-joins, optgoal, performance , KBA , BC-SYB-ASE , Sybase ASE Database Platform (non Business Suite) , Problem

About this page

This is a preview of a SAP Knowledge Base Article. Click more to access the full version on SAP for Me (Login required).

Search for additional results

Visit SAP Support Portal's SAP Notes and KBA Search.