is a request posed to a database
(or data system) for data retrieval,
updating, deletion, insertion, etc.
Query
is the stage in a Database Management System (DBMS) where the system interprets and executes
a user’s query (usually written in SQL) to retrieve or modify data efficiently from the database
Query Processing
It ensures all table names, columns, and keywords are valid.
Parsing and Translation
The query is then translated into an internal form (like relational
algebra).
Parsing and Translation
finds the most efficient way to execute the query.
Query Optimizer
It considers multiple query plans (e.g., using indexes, join
methods, or sorting strategies).
Optimization
The goal is to minimize cost, such as CPU time, disk I/O, and memory use
Optimization
runs the optimized query plan
Execution
It retrieves or modifies the data from the database storage
Execution
Checks SQL correctness.
Parsing
Chooses whether to use an index on age or scan the whole table
Optimization
Retrieves matching records and returns the name field.
Execution
refer to the factors a DBMS (Database Management System) uses to estimate how expensive a query plan is
Measures of Query Cost
to decide the most efficient way to run a query
Measures of Query Cost
Most important factor in cost estimation
Disk I/O Cost
Measures how many disk accesses (reads/writes) are needed
Disk I/O Cost
Measures the time spent by the processor
CPU Cost
Usually smaller than disk I/O, but becomes important for in-memory
databases.
CPU Cost
Measures how much RAM is used during query execution.
Memory Usage (Buffer Cost)
Affects how much data can be processed in memory without writing to disk
Memory Usage (Buffer Cost)
High memory use may cause paging or spilling to disk, increasing
total cost
Memory Usage (Buffer Cost)
data may be stored on multiple servers.
Communication Cost (in Distributed Databases)
Critical in distributed query processing and cloud databases.
Communication Cost (in Distributed Databases)
The total time taken from query submission to result delivery.
Query Response Time