Cost components of query execution

December 4, 2026 · Team EasyExamNotes · 2 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-502 DBMS November 2023 solved question paper

RGPV CS-502 (GS) | November 2023 | Q4(b) | 7 marks

Question (restated): Discuss the major costs incurred when executing a database query.

Answer

Query cost is the resource consumption required to evaluate a query plan. A cost-based optimizer estimates the cost of alternative access paths, join algorithms and operator orders before choosing a plan. The estimate depends on relation sizes, selectivity, indexes, available memory and system characteristics.

Disk I/O cost includes page transfers and random access overhead. A sequential scan reads every page, whereas an index may avoid many pages for selective predicates but incur random accesses. A simple model is Cost = b × tT + s × tS, where b is page transfers, s is seeks, tT is transfer time and tS is seek time.

CPU cost includes predicate evaluation, comparisons, hashing, sorting and tuple construction. Memory cost concerns buffer pages and intermediate structures; insufficient memory causes temporary files and extra I/O. Network cost matters in distributed databases because messages and transferred bytes contribute latency and bandwidth usage. Output materialization and temporary writes can also be significant.

Illustrative example: assume a table occupies 1000 pages, transfer time is 0.1 ms/page and seek time is 4 ms. A sequential scan with one seek costs about 104 ms in this simplified model. An index plan reading 20 randomly located pages with 20 seeks costs about 82 ms, excluding CPU and index traversal. If 100 random pages are needed, the estimate becomes 410 ms, making the scan preferable.

The optimizer compares complete plans rather than individual operations in isolation. A join that produces a large intermediate relation may be more expensive than one that applies a selective predicate first. Modern storage and caching change the relative weights of cost components, so these numerical values are illustrative, not universal measurements.

Further reading: Silberschatz, Korth and Sudarshan, Database System Concepts; Elmasri and Navathe, Fundamentals of Database Systems.

← RGPV CS-502 DBMS November 2023 solved question paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion