SQL Server 2012 is a powerful and complex database platform. The relational engine itself is composed of many subsystems. One of these is the command parser, which takes the input from the connection, validates it, and parses it into an internal structure called a
. Another is the Query Optimizer, which takes the query tree and prepares the statement for execution. These preparation tasks include ensuring the user executing the query has enough access to the underlying database objects within the query and optimizing the query with respect to performance. Query optimization is cost based, and SQL Server chooses the execution plan that is best for the given statement.