I’m not quite sure when selecting only a certain number of rows would be better than simply making a more specific select statement. I have a feeling I’m missing something pretty straight forward but I can’t figure it out. I have less than 6 months experience with any SQL and it’s been cursory at that so I’m sorry if this is a really simple question but I couldn’t find a clear answer.
Share
I know of two common uses:
Paging : be sure to specify an ordering. If an ordering isn’t specified, many db implementations use whatever is convenient for executing the query. This ‘optimal’ ordering behavior could give very unpredictable results.
Subqueries : many places that a subquery can be issued require that the result is a single value. top 1 is just faster than max in many cases.