SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On



Internal implementation of Query execution Expand / Collapse
Author
Message
Posted Thursday, October 16, 2008 12:40 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, December 07, 2009 5:13 AM
Points: 153, Visits: 114
Hi all,
i want to know what happens when a query is being executed. Means, what are the steps. As in .net we have object initialization, page load, page render, etc.
Sql server also has some steps like parsing, authentication,etc.

Can anyone tell me what all the steps sql server follows when a query is being executed?

Thanks
Deepti
Post #586745
Posted Thursday, October 16, 2008 1:42 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 8:58 AM
Points: 17,110, Visits: 12,214
At a very high level, parse, bind, optimise, process.

First the parser takes the SQL code, makes sure there are no syntax errors and then converts it into a tree-like structure. Then the algebratiser does the binding and name resolution and outputs another tree-like structure .

The optimiser takes the that and does the optimisation of it. It will generate possible execution plans, evaluate the cost and return the cheapest one that it can find.

The execution plan is passed to the query processor which is responsible for the actual processing.

If you run a query with the show executopn plan option, you'll be able to see the steps that the query processor will go through.



Gail Shaw

We walk in the dark places no others will enter
We stand on the bridge and none may pass

Post #586771
Posted Thursday, October 16, 2008 2:24 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, December 07, 2009 5:13 AM
Points: 153, Visits: 114
Thanks gail.
Where can i get the detail of this(no point should be missed)?
And one more doubt.
How these things are communicated to memory?
Post #586785
Posted Thursday, October 16, 2008 2:38 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 8:58 AM
Points: 17,110, Visits: 12,214
There's a chapter on it in "Inside SQL Server 2005: T-SQL Querying"


Gail Shaw

We walk in the dark places no others will enter
We stand on the bridge and none may pass

Post #586789
Posted Thursday, October 16, 2008 5:26 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:06 PM
Points: 7,395, Visits: 15,201
There was also a presentation from one of the SQL Server internals guys at the PASS summit a couple of years back called "A Day In The Life of a Query" that went into the processes in great detail. I know that's avalable, for a fee, at the PASS web site (www.sqlpass.org), but it might be out on the intraweb somewhere.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of SQL Server 2008 Query Performance Tuning Distilled

For better & quicker help read:
How to Post Performance Problems
Post #586854
« Prev Topic | Next Topic »


Permissions Expand / Collapse