Databases Reference
In-Depth Information
HOW MUCH DOES IT COST?
The term cost doesn't translate into seconds or anything meaningful; it is just an
arbitrary number used to assign a value representing the resource cost for a plan.
However, its origin was a benchmark on a desktop computer at Microsoft early in
SQL Server's life.
In a plan, each operator has a baseline cost, which is then multiplied by the size of
the row and the estimated number of rows to get the cost of that operator — and the
cost of the plan is the total cost of all the operators.
Because cost is created from a baseline value and isn't related to the speed of your
hardware, any plan created will have the same cost on every SQL Server installation
(like-for-like version).
The statistics that the optimizer uses to estimate the number of rows aren't covered
here because they aren't relevant to the concepts illustrated in this chapter, but you
can read about them in Chapter 5.
Because our SELECT query is very simple, it drops out of the process in the pre-optimization
phase because the plan is obvious to the optimizer (a trivial plan ). Now that there is a query plan,
it's on to the Query Executor for execution.
Query Executor
The Query Executor's job is self-explanatory; it executes the query. To be more specii c, it executes
the query plan by working through each step it contains and interacting with the Storage Engine to
retrieve or modify data.
NOTE The interface to the Storage Engine is actually OLE DB, which is a
legacy from a design decision made in SQL Server's history. The development
team's original idea was to interface through OLE DB to allow different Storage
Engines to be plugged in. However, the strategy changed soon after that.
The idea of a pluggable Storage Engine was dropped and the developers started
writing extensions to OLE DB to improve performance. These customizations
are now core to the product; and while there's now no reason to have OLE DB,
the existing investment and performance precludes any justii cation to change it.
The SELECT query needs to retrieve data, so the request is passed to the Storage Engine through an
OLE DB interface to the Access Methods.
 
Search WWH ::




Custom Search