SQL - @@TOTAL_READ Function



The SQL @@TOTAL_READ statistical function is used to retrieve the number of disks reads. It returns the total number of disk reads by the SQL server instance since the last time SQL server was started. It does not include the cache reads.

Syntax

Following is the syntax of the SQL @@TOTAL_READ function −

@@TOTAL_READ 

Return type

The return type of this function is an INTEGER.

Parameters

  • It does not accept any parameters.

Return value

This function returns the number of disk reads.

Example

In the following example,we are using the SQL @@TOTAL_READ function to retrieve the number of disk reads by this SQL server.

SELECT @@TOTAL_READ AS Number_of_reads;

Output

The above program produces the following output −

+----------------------+
| Number_of_disk_reads |
+----------------------+
| 70510                |
+----------------------+

Example

The following is another example of the SQL @@TOTAL_READ function. You can also use the GETDATE() function to retrieve the number of disk reads until today by the SQL server, since the SQL server last started.

SELECT @@TOTAL_READ AS Number_of_disk_reads, GETDATE() AS Todays_date;

Output

On executing the above program, it will produce the following output −

+----------------------+-------------------------+
| Number_of_disk_reads | Todays_date             |
+----------------------+-------------------------+
| 70816                | 2023-03-02 12:09:45.770 |
+----------------------+-------------------------+
sql-statistical-functions.htm
Advertisements