Understand SQL Server optimizer decisions

Shivani T 0 Reputation points
2023-08-28T10:04:32.42+00:00

I want to understand how SQL server optimizer takes decisions to optimize and process the SQL query. Is there any resource which can guide me to do so ?

SQL Server | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 47,436 Reputation points
    2023-08-28T11:33:18.9733333+00:00

    There is not a really handy document, but to start with see Query processing architecture guide

    0 comments No comments

  2. LiHongMSFT-4306 31,566 Reputation points
    2023-08-29T03:08:06.29+00:00

    Hi @Shivani T

    Query optimization is a CPU-intensive operation. The process to sift through plans requires significant computing resources and to find the best plan may require more time than is available. As a result, a balance must be maintained between the resources needed to optimize the query, the resources required to execute the query, and the time we must wait for the entire process to complete. As a result, the optimizer is not built to select the best execution plan, but instead to search and find the best possible plan after a set amount of time passes. It may not be the perfect execution plan, but we accept that as a limitation of how a process with so many possibilities must operate.

    Please refer to this article for more details: Query optimization techniques in SQL Server: the basics.

    Best regards,

    Cosmog Hong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.