Window functions SORT costly, can we overcome it?
问题 My Requirement: Identify top 10 accounts of a DEPT_NUM , ordered by the account number in ascending order. Query: SELECT * FROM ( select acctnum,dept_num,row_number() OVER (PARTITION BY DEPT_NUM ORDER BY ACCTNUM) as row_identifier FROM MYTABLE ) WHERE row_identifier between 1 and 10; Trace: 7532 rows selected. Execution Plan ---------------------------------------------------------- Plan hash value: 1480074522 -----------------------------------------------------------------------------------