TOP N 和SET ROWCOUNT N 哪个更快?_MySQL
懒得翻译了,大意:
在有合适的索引的时候,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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Editor of Machine Power Report: Wu Xin The domestic version of the humanoid robot + large model team completed the operation task of complex flexible materials such as folding clothes for the first time. With the unveiling of Figure01, which integrates OpenAI's multi-modal large model, the related progress of domestic peers has been attracting attention. Just yesterday, UBTECH, China's "number one humanoid robot stock", released the first demo of the humanoid robot WalkerS that is deeply integrated with Baidu Wenxin's large model, showing some interesting new features. Now, WalkerS, blessed by Baidu Wenxin’s large model capabilities, looks like this. Like Figure01, WalkerS does not move around, but stands behind a desk to complete a series of tasks. It can follow human commands and fold clothes

The Linux top command cannot be used because the top command is not installed in the system. The solution is to install the top command through the "apt-get install procps" or "yum install procps" command.

Which ASUS motherboard should be paired with the R55600? The ASUS ROGStrixB550-FGaming motherboard is an excellent choice. It is perfectly compatible with Ryzen55600X processor and provides excellent performance and features. This motherboard has a reliable power supply system, can support overclocking, and provides a wealth of expansion slots and ports to meet daily use and gaming needs. ROGStrixB550-FGaming is also equipped with high-quality audio solutions, fast network connections and reliable heat dissipation design to ensure that the system remains efficient and stable. In addition, this motherboard adopts a gorgeous ROG style and is equipped with gorgeous RGB lighting effects, adding visual enjoyment to your computer. All in all, ASUS ROGStri

What driver is good to install on rx5808g? 20.5.1 and 20.4.2WHQL refer to the version number of the software or driver. These version numbers are typically used to identify updates or fixes to software or drivers. In the computer world, WHQL stands for Windows Hardware Quality Labs, which is an institution used by Microsoft to test and verify the compliance and stability of hardware and drivers. Therefore, 20.5.1 and 20.4.2WHQL indicate that these software or drivers have passed Microsoft's testing and verification and can be safely used in the Windows operating system. AMDrx580 graphics card relatively stable drivers 20.5.1 and 20.4.2WHQL refers to the version number of the software or driver. These version numbers are passed

Which one is better, Celeron g4900 or i36100? When it comes to the two processors Celeron G4900 and I36100, there is no doubt that the performance of I36100 is superior. Celeron processors are generally considered low-end processors and are primarily used in budget laptops. The I3 processor is mainly used for high-end processors, and its performance is very good. Whether you are playing games or watching videos, you will not experience any lagging when using the I3 processor. Therefore, if possible, try to buy Intel I-series processors, especially for desktop computers, so that you can enjoy the fun of the online world. How is the performance of the Celeron G4900T? From a performance perspective, the Pentium G4900T performs well in terms of frequency. Compared with the previous version, the CPU performance is

Please recommend which 1155-pin CPU is the best. The current 1155-pin CPU with the highest performance is Intel Corei7-3770K. It has 4 cores and 8 threads, a base frequency of 3.5GHz, and supports TurboBoost2.0 technology, which can reach up to 3.9GHz. In addition, it is equipped with 8MB of level 3 cache and is an excellent processor with the LGA1155 pin, the most powerful CPU Intel Core i73770K. The LGA1155 interface is the interface type used by second and third generation Core processors. The best performing one is Intel Core i73770K. The parameters of this processor are as follows: 1. Applicable type: desktop; 2. CPU series: Core i7; 3. CPU

Which version of the graphics card driver is best to use? 1. There is no absolute best version. It is most important to choose the version that suits your computer; 2. Because the applicability and stability of the graphics card driver version are related to the computer hardware environment and system configuration; 3. You can check the detailed information of the computer and graphics card on the official website, select the appropriate driver version based on the information, or refer to the reviews of other users. It is recommended to back up the system before installing the driver to avoid unexpected situations. Graphics card driver version 472.19 series is an excellent choice. Currently, the driver compatibility of version 472 is the best. Installing version 472 of the driver can also maximize the performance of the graphics card. The NVIDIA graphics card driver Win7 installation version, numbered 2, 472.19, is a product with remarkable quality.

Many of us have seen this snippet over and over again in Python code: with open('Hi.text', 'w') as f: f.write("Hello, there") However, some of us Some people don't know what with is used for and why we need to use it here. In this read, you'll find out about almost any problem that can be solved with. let's start! First, let's consider what we need to do without using the with keyword. In this case we need to open the file first and try to write. Regardless of success or failure, we'd better be
