Too lazy to translate, to the effect:
Top N and SET rowcount n are the same fast when there is a suitable index. But for an unordered heap, top n is faster.
The principle of looking at English to go.
Q. Is using the TOP N clause faster than using SET ROWCOUNT N to return a specific number of rows from a query?
A. With proper indexes, the TOP N clause and SET ROWCOUNT N statement is equally fast, but with unsorted input from a hea P, TOP N is faster. With unsorted input, the TOP N operator uses a small internal sorted temporary table in which it replaces only the last RO W. If the input is nearly sorted, the TOP N engine must delete or inserts the last row only a few times. Nearly sorted means you ' re dealing with a heap with ordered inserts for the initial population and without many updates, D Eletes, forwarding pointers, and so on afterward.
A nearly sorted heap is more efficient to sort than sorting a huge table. In a test that used top N to sort a table with the same number of rows but with unordered inserts, Top n is not as Effici ENT anymore. Usually, the I/O time is the same both with an index and without; However, without an index SQL Server must does a complete table scan. Processor time and elapsed time show the efficiency of the nearly sorted heap. The I/O time is the same because SQL Server must read all the rows either.
http://www.bkjia.com/PHPjc/631148.html www.bkjia.com true http://www.bkjia.com/PHPjc/631148.html techarticle lazy Translation, the main idea: when the appropriate index, Top N and SET rowcount n is the same fast. But for an unordered heap, top n is faster. The principle of looking at English to go. Q ...