I think FORCE SEEK can improve the performance of SELECT query, but wondering if FORCE SCAN can also improve performance of query.
Can someone explain with example?
Say you have a query that will result in 1.000.000 rows but SQL Server estimates there will only be 100. Then SQL Server estimates 100 index seeks with a table lookup are faster than a full table scan. But instead it ends up doing 1.000.000 index seeks and lookups!
In that case, adding a force scan
hint will improve the performance of a query.
Note that this situation is unusual. SQL Server tries to optimize for the worst case, and will not use a seek unless it's pretty damn sure there are not too many of them. That's why forceseek
is used more often forcescan
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.