Databases 3 min read

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.

Java Tech Enthusiast
Java Tech Enthusiast
Java Tech Enthusiast
How SQL Statements Are Executed in a Database

SQL execution begins when the client sends a statement over a transport protocol such as TCP.

The parser receives the SQL, performs syntax and semantic analysis, and builds a query tree.

The optimizer takes the query tree, evaluates possible execution plans (e.g., index scan, nested‑loop join, hash join), estimates their costs using statistics, and selects the most efficient plan.

The executor runs the chosen plan, invoking access methods to fetch data from storage or cache. For read‑only queries the buffer manager handles data retrieval; for UPDATE/INSERT statements the transaction manager processes them, and the lock manager enforces ACID properties.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

optimizationsqldatabaseQuery Execution
Java Tech Enthusiast
Written by

Java Tech Enthusiast

Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.