Comment by jeltz
7 years ago
Which is why PostgreSQL uses heap sort with a fixed max heap size for sort with a small limit (called "top-N heapsort" when running explain analyze). Then the complexity for getting the kth value is O(n log k) which is O(n).
No comments yet
Contribute on Hacker News ↗