Skip navigation.

Marcin Miller's blog

Top-n query tuning in huge OLTP applications

Marcin Miller's picture

Top-n Query is one of the more advanced SQL problems. How does one retrieve N first (or least) rows from a record set? For example, how does one find the top five highest-paid employees in a given department?