snippetsqlModerate
How to re-enable read ahead (prefetch) feature in SQL Server after disabling it?
Viewed 0 times
afterenablereadsqlprefetchhowserverdisablingaheadfeature
Problem
In Microsoft SQL Server, I've disabled the read ahead (prefetch) feature using
But does anyone know how to enable the read ahead feature?
Before I disabled the read ahead, using
I get this result:
Now after disabling read ahead using the above DBCC query, I get this:
I'd like to be able to disable/enable the prefetch feature freely so I could compare among different queries. I googled everywhere but didn't find an answer for that... Anyone knows how to re-enable it? Thanks!
DBCC TRACEON(652,-1)But does anyone know how to enable the read ahead feature?
Before I disabled the read ahead, using
set statistics io onI get this result:
Scan count 1, logical reads 529, physical reads 4, read-ahead reads 1192Now after disabling read ahead using the above DBCC query, I get this:
Scan count 1, logical reads 44, physical reads 19, read-ahead reads 0I'd like to be able to disable/enable the prefetch feature freely so I could compare among different queries. I googled everywhere but didn't find an answer for that... Anyone knows how to re-enable it? Thanks!
Solution
All you need do is turn the trace flag off globally:
A service restart is not required.
To control read-ahead for the current session only, simply omit the
This trace flag is only minimally documented, so for anything more than educational purposes on an isolated test system, it makes sense to contact Microsoft Support for advice.
Note:
DBCC TRACEOFF (652, -1);A service restart is not required.
To control read-ahead for the current session only, simply omit the
-1.DBCC TRACEON (652);
...
...tests
....
DBCC TRACEOFF (652);This trace flag is only minimally documented, so for anything more than educational purposes on an isolated test system, it makes sense to contact Microsoft Support for advice.
Note:
QUERYTRACEON is not effective for trace flag 652.Code Snippets
DBCC TRACEOFF (652, -1);DBCC TRACEON (652);
...
...tests
....
DBCC TRACEOFF (652);Context
StackExchange Database Administrators Q#140784, answer score: 13
Revisions (0)
No revisions yet.