SEEK

SEEK is a method used in SQL Server to directly access a row in a table. Using an index, it locates the required data more quickly compared to a standard table scan, improving efficiency in data retrieval.

Example

SET STATISTICS IO ON;
SELECT * FROM Employees
WHERE EmployeeID = 5;
SET STATISTICS IO OFF;

Output

Table 'Employees'. Scan count 0, logical reads 3

Explanation

In the example above, the SEEK operation was used during the execution of the SELECT statement. Sql Server had to look for the particular Employee whose EmployeeID is 5, hence it executed an Index Seek operation. ‘Scan count 0, logical reads 3’ implies that it had to perform 3 logical reads to retrieve the Employee information but it did not have to perform a full scan. This number represents the number of pages read from disk, which makes seek operations far more efficient than scan operations when retrieving a small subset of a large dataset.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.