|
|||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
Oh!!! Why my SQL query is taking so much time to retrieve data...? This is the common question when our SQL query is taking much time to execute. So i will briefly describe hat is happening when we are executing any query. IntroductionTo understand what is happening when executing SQL query, we must know how the execution (Parsing of SQL statements) is happening. Basically SQL query will be parsed "Top to Bottom and Left to Right". Understanding SQL ExecutionWhen ever we Execute any SQL query(Statements) SQL Server will give output by processing this Query in two phase. 1. Relational engine 2. Storage Engine Our SQL Query will be first given to the Relational Engine of the SQL server to analyze all statements. Means here our query will be parsed and will be optimized in the form so that SQL server can do transaction on that query. At this time our query will be in optimized form means it is the shortest execution plan which can be taken out on the database to retrieve or update the data. Then after, this optimized query in the form of binary data will be submitted to the Storage Engine, where the actual execution will be done on database. All retrieval or modification of the data will be carried out here. So in these two steps our query will be executed and we are getting result. So we will focus on the "Relational Engine" part of the execution plan because from here we will get our Answer to the Question "Why my query is getting to much time to execute?". Relational Engine
Why we see difference between Estimated and Actual PlanWhen we generate the Estimated plan and when we run the query actually and get the actual execution plan then there may be some difference between them. This difference may be due to following scenarios.
NEXTIn My Next Part of this article, i will show you how to use Execution Plan to improve our query. Part Two will be posted soon. ReferenceseBook Dissecting SQL Server Execution Plan By Grant Fritchey.
|
||||||||||||||||||||||||||||||||||||||||