国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

TOP N 和SET ROWCOUNT N 哪個更快?

2024-07-21 02:31:02
字體:
來源:轉載
供稿:網友
懶得翻譯了,大意:
在有合適的索引的時候,Top n和set rowcount n是一樣快的。但是對于一個無序堆來說,top n更快。
原理自己看英文去。

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 are equally fast, but with unsorted input from a heap, 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 row. If the input is nearly sorted, the TOP N engine must delete or insert 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, deletes, 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 was not as efficient anymore. Usually, the I/O time is the same both with an index and without; however, without an index SQL Server must do 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 way.



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 扶风县| 额尔古纳市| 海盐县| 普定县| 林州市| 兴城市| 宽甸| 景德镇市| 崇仁县| 盐源县| 临武县| 吴旗县| 三原县| 永福县| 双桥区| 赣州市| 灵山县| 汝南县| 舒城县| 平罗县| 章丘市| 沁水县| 平定县| 永昌县| 屏东县| 灵武市| 平罗县| 迁西县| 林甸县| 白水县| 靖边县| 通州市| 浦北县| 阿勒泰市| 鄂托克旗| 临朐县| 旬邑县| 自贡市| 铁力市| 孝感市| 亚东县|