Can FORCE SCAN improve query performance

I think FORCE SEEK can improve SELECT query performance, but I wonder if FORCE SCAN can improve query performance.

Can someone explain with an example?

+4
source share
1 answer

Let's say you have a query that will result in 1,000,000 rows, but SQL Server scores will only be 100. Then SQL Server scores 100 index queries using a table lookup faster than a full table scan. But instead, he finishes querying and searching 1,000,000 indexes!

In this case, adding a force scan hint will improve query performance.

Please note that this situation is unusual. SQL Server is trying to optimize for the worst case and will not use a search engine if there is not enough confidence that there are too few of them. That is why forceseek used more often by forcescan .

+2
source

Source: https://habr.com/ru/post/1443197/


All Articles