Friday, February 24, 2012

Execution/compilation

What is the difference beteween execution och compilation in SQL Server?
I suspect that SELECT-statements aren't compiled while CREATE
TABLE-statements are? Is that correct?Have I understood you right if Query execution is the same as Query
compilation?
"Gert-Jan Strik" <sorry@.toomuchspamalready.nl> wrote in message
news:3F4760AF.C87F25CD@.toomuchspamalready.nl...
> When you submit a SELECT statement, SQL-Server will go through different
> stages before it returns the resultset.
> Parsing: first the statement will be analysed to see if it is
> syntactically correct, and if all object names can be found in the
> schema.
> Query optimizing: during this stage, SQL-Server will create execution
> plans that will give the correct result. There are usually many
> different query plans that give the same result, but one query plan
> might be much more efficient than the other. It is also possible, that
> the query plan of an earlier compilation is still in cache. In that
> case, this fase is skipped.
> Query executing: the fastest query plan will be executed. This is where
> the actual rows are read from disk (or buffer cache) and all 'real'
> processing is done.
> The steps above are all relevant for DML (such as SELECT, UPDATE, etc.)
>
> When it comes to DDL (such as CREATE TABLE statements), it is not
> possible to optimize the query. The statements are straightforward and
> can be executed immediately after parsing.
> Gert-Jan
>
> Stefan wrote:
> >
> > What is the difference beteween execution och compilation in SQL Server?
> >
> > I suspect that SELECT-statements aren't compiled while CREATE
> > TABLE-statements are? Is that correct?

No comments:

Post a Comment