How SQL Statements Are Executed in a Database
When a client sends an SQL statement over TCP, the parser checks syntax and semantics and builds a query tree, the optimizer evaluates possible execution plans using statistics to estimate costs and selects the most efficient one, and the executor runs the plan, using the buffer manager for reads or the transaction manager for updates while the lock manager enforces ACID properties.