国产探花免费观看_亚洲丰满少妇自慰呻吟_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.



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 徐水县| 马公市| 西安市| 茂名市| 湟中县| 佛山市| 惠安县| 吴桥县| 托克托县| 平阳县| 若羌县| 手游| 民和| 高碑店市| 富锦市| 乌兰浩特市| 天津市| 永丰县| 华安县| 张家港市| 建瓯市| 承德市| 富顺县| 祁门县| 柘城县| 城市| 揭西县| 成武县| 正宁县| 漳州市| 咸宁市| 汝阳县| 景宁| 华安县| 合阳县| 甘肃省| 固镇县| 郧西县| 云安县| 那曲县| 读书|