Mar 31, 2013

CHAR vs VARCHAR in terms of performance

CHAR, NCHAR    
- fixed type: the system always allocates the indicated size in memory.
- UPDATEs don't need data shifting or physical row expansion.
- If frequent UPDATES operation is anticipated for a column, CHAR/NCHAR types is preferred.

 VARCHAR, NVARHCAR   
- variable type: the system allocates variable size in memory depending on size of the value.
- Less storage is used
- Thus, the less there is for a query to read.
- Faster query performance.

Mar 25, 2013

Logical query processing order

The logical query processing order

(1)   FROM
(2)   WHERE
(3)   GROUP BY
(4)   HAVING
(5)   SELECT
(6)   ORDER BY

> "Each phase operates on one or more tables as inputs and returns a virtual table as output. The output table of one phase is considered the input of the next phase. This is in accord with operation on relations that yield a relation."

> "If you assign an alias to a table, you basically rename the table for the duration of the query. The original table name isn't visible anymore; only the alias is."
------------------
Reference: Querying Microsoft SQL Server 2012 Training Kit by Itzik Ben-Gan, Dejan Sarka, Ron Talmage