Memory Hierarchy: Cost and Access Time

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What reads data in blocks?

  • Only file systems
  • Only Registers
  • All storage media (correct)
  • Only Hard disks

Most storage media is fast in randomly accessing a block, but slow at reading consecutive blocks.

False (B)

What is the typical block size for NTFS filesystems?

  • 8 KiB
  • 64 MB
  • Between 4 KiB and several MiB
  • 4 KiB (correct)

What is main concern when fitting database records into blocks?

<p>Organizing blocks by rows or by columns</p> Signup and view all the answers

What does a secondary index provide in a database system?

<p>An additional lookup structure for efficiently finding specific rows (A)</p> Signup and view all the answers

Sequential searching of rows is required when using an index.

<p>False (B)</p> Signup and view all the answers

Which of the following is a common type of index?

<p>Tree-based index (A)</p> Signup and view all the answers

What is the role of Primary Index?

<p>Sorting and Organizing of Data</p> Signup and view all the answers

What is the purpose of query optimization in a database management system (DBMS)?

<p>To find the most efficient way to execute a given query (A)</p> Signup and view all the answers

Query optimization always guarantees the absolute best execution plan.

<p>False (B)</p> Signup and view all the answers

Which of the following is a key consideration when optimizing queries?

<p>Ensuring that the optimization time does not exceed the savings achieved (A)</p> Signup and view all the answers

What is main goal of 'Optimizing' Queries?

<p>Get the same query result but faster!</p> Signup and view all the answers

A general Cost-Based Algorithm does which of these steps?

<p>Enumerates alternative query plans and estimates cost for each alternative. (C)</p> Signup and view all the answers

A Heuristic-Based algorithm is generally more complex than Cost-Based

<p>False (B)</p> Signup and view all the answers

Which is NOT a con of Cost-Based aproach?

<p>Very easy &amp; cheap (A)</p> Signup and view all the answers

What should you do, If you can replace a cartesian product with a join?

<p>Do so</p> Signup and view all the answers

What does 'cheapest' mean in cost-based optimization

<p>Define good cost metrics (B)</p> Signup and view all the answers

Can we Limit the search space while not guaranteeing the cheapest solution?

<p>True (A)</p> Signup and view all the answers

What do we need for Cost-Based?

<p>A Cost Estimation Function! (B)</p> Signup and view all the answers

For Cost-Based aproach, what should you enumerate?

<p>All query plans?</p> Signup and view all the answers

Always consider the time needed for evaluating the query together vs. the time needed for ______ it

<p>optimizing</p> Signup and view all the answers

Once the Query is Parsed then what happends?

<p>Goes to Query Optimizer (A)</p> Signup and view all the answers

Cost Model is not part of General Cost-Based Algorithm

<p>False (B)</p> Signup and view all the answers

What is used to represent unoptimized relational

<p>Canalical Operator Tree (D)</p> Signup and view all the answers

Annotated Operator Tree is [blank] towards the execution plan

<p>intermediate step</p> Signup and view all the answers

What should the Query Optimization do?

<p>Translation of a query into a naïve canonical query plan (D)</p> Signup and view all the answers

Query optimization determines the 'worst' order of the relational algebra operators

<p>False (B)</p> Signup and view all the answers

What is the predominant factor for Cost Metrics

<p>Number of disk accesses (C)</p> Signup and view all the answers

Disk accesses are measured by Number of block reads * [blank]

<p>average block read costs</p> Signup and view all the answers

What should you remember about In-Memory-Databases...?

<p>CPU time is mostly negligible (A)</p> Signup and view all the answers

Goodhart's law is a law that says : When a target becomes a measure, it ceases to be a good measure.

<p>False (B)</p> Signup and view all the answers

Campbell's Law about social ______, says The more any quantitative social indicator is used for social decision-making, the more subject it will be to corruption pressures

<p>Psychology</p> Signup and view all the answers

Relational algebra allows for which?

<p>alternative, yet equivalent evaluation plans (C)</p> Signup and view all the answers

In what plans the Querying behaviour is heterogeneous?

<p>Dynamic plans (C)</p> Signup and view all the answers

Hybrid plans combine pre-optimization in a quick with fine-tuning during runtime

<p>False (B)</p> Signup and view all the answers

What transformations are based on?

<p>Set of relational algebra equivalences (B)</p> Signup and view all the answers

Transformation rules transform an ______ tree step by step

<p>operation</p> Signup and view all the answers

What effect results of a query are affected by?

<p>Results of a query are never affected by transformations (C)</p> Signup and view all the answers

Pushing selections is always a good heuristic

<p>False (B)</p> Signup and view all the answers

What is used to break Cartesian products

<p>Force Joins (A)</p> Signup and view all the answers

What is a typical block size for NTFS and most 'traditional' file systems?

<p>4 KiB (D)</p> Signup and view all the answers

What are the two ways to organize blocks to fit database records?

<p>By rows or by columns</p> Signup and view all the answers

Indexes always require sequential searching of rows to find stored data.

<p>False (B)</p> Signup and view all the answers

Which of the following is a type of index mentioned?

<p>Tree-based Index (C)</p> Signup and view all the answers

What is the primary purpose of a query processor in a DBMS?

<p>To process and execute database queries (C)</p> Signup and view all the answers

File organization and indexing are irrelevant to query processing efficiency.

<p>False (B)</p> Signup and view all the answers

A query optimizer aims to find the way of executing a query.

<p>optimal</p> Signup and view all the answers

Match the memory type with its typical capacity:

<p>Register = 8 KB Cache = 8 MB Main Memory = 64 GB Hard Disk = 1 TB</p> Signup and view all the answers

What is the goal of Query Optimization?

<p>To find the 'optimal' way of executing the query. (A)</p> Signup and view all the answers

The 'optimal' way of executing a query is always the fastest in absolute terms.

<p>False (B)</p> Signup and view all the answers

What is a key technique for 'Optimizing' Queries?

<p>Getting the same query result, but faster! (B)</p> Signup and view all the answers

What is one way you can optimize a query?

<p>Using heuristics or cost-based optimization</p> Signup and view all the answers

Heuristic based query optimization guarantees the absolute best result.

<p>False (B)</p> Signup and view all the answers

Which of the following is a con related to heuristic-based query optimization?

<p>Result quality varies a lot (A)</p> Signup and view all the answers

What is crucial to have when using Cost-Based Query Optimization?

<p>Cost Metric (C)</p> Signup and view all the answers

Match the query optimization phase with its description:

<p>Query Parsing = Transforms SQL into algebra representation. Query Optimization = Finds faster ways of writting an algebra expression. Algorithm Selection = Finds the best algorithm for each operator.</p> Signup and view all the answers

In the context of file organization, what do file systems group together?

<p>Storage media blocks (C)</p> Signup and view all the answers

A primary index refers to additional data structures, beyond the raw data, that facilitate efficient data retrieval.

<p>False (B)</p> Signup and view all the answers

In database systems, a secondary index helps to efficiently find specific in stored data.

<p>rows</p> Signup and view all the answers

Which of the following is a core question to consider when fitting database records into blocks?

<p>Organize Blocks by ROWS or by COLUMNS? (D)</p> Signup and view all the answers

What is meant by the term 'algebra' in the context of 'Algebraic Query Rewriting'.

<p>Algebra allows for symbolic calculations</p> Signup and view all the answers

Algebraic query rewriting always leads to drastically different results.

<p>False (B)</p> Signup and view all the answers

What does it mean to Cascade a selection?

<p>σc₁ ^ c₂ ...(R) ≡ σc₁ (σc₂ (...(R))...) (A)</p> Signup and view all the answers

What does it mean to be 'Commutative' in the context of selections applied to Relational Algebra?

<p>σc₁ (σc₂(R)) ≡ σc₂ (σc₁(R)) (A)</p> Signup and view all the answers

What does it mean to be 'Commutative' in the context of Joins?

<p>R × S ≡ S × R (B)</p> Signup and view all the answers

Match the following concepts

<p>Constructing Join = R ⋈c S ≡ σc(R × S) Cascading = Relational Algebra allows for alternative plans.</p> Signup and view all the answers

Algebraic Optimization has no importance to a relational algebra.

<p>False (B)</p> Signup and view all the answers

What is the end goal when it comes to Algebraic Optimization.

<p>Find “better” operator trees which have the same result! (A)</p> Signup and view all the answers

What is a Static Plan?

<p>Where the best plan is known apriori for a certain kind of query</p> Signup and view all the answers

What is the purpose of a Hybrid plan?

<p>Combining Static and Dynamic Plans (A)</p> Signup and view all the answers

The canonical tree has different semantics to the final tree, during query optimization.

<p>False (B)</p> Signup and view all the answers

After running a query plan through the Query Optimizer, what should you make ABSOLUTELY SURE OF?

<p>That you WASTE MORE TIME OPTIMIZING THAN YOU SAVE BY OPTIMIZING! (B)</p> Signup and view all the answers

What might be more costly when a Cost Model attempts to break things up?

<p>Avoiding More Mistakes. (C)</p> Signup and view all the answers

For algebraic transofmrations, all transformations are based on a set of what?

<p>All transformations are based on a set of relational algebra equivalences.</p> Signup and view all the answers

When is commuting projections with 𝜎 ONLY possible?

<p>If selection condition c does only work on projected attributes a₁, ..., an (D)</p> Signup and view all the answers

The best results are always possible when using Simple Heuristics.

<p>False (B)</p> Signup and view all the answers

When using Simple Heuristics for query plans, should be applied as early as possible.

<p>Selection</p> Signup and view all the answers

Which of the following is NOT typically found in a memory hierarchy?

<p>Cloud Storage (B)</p> Signup and view all the answers

A query processor is a component external to a DBMS, responsible for translating SQL queries into a machine-readable format.

<p>False (B)</p> Signup and view all the answers

What is the primary goal of query optimization?

<p>To find the most efficient way to execute a query, reducing resource consumption while achieving a similar result.</p> Signup and view all the answers

In the context of file organization within databases, the primary question to address is whether to organize blocks by ______ or by columns.

<p>rows</p> Signup and view all the answers

Match the following memory types with their relative access times:

<p>Register = 1-10 ns Cache = 10-100 ns Main Memory = 60-300 ns Hard Disk = 10-12 ms</p> Signup and view all the answers

What is a key characteristic of storage media regarding data access speed?

<p>Randomly accessing a block is slower than reading consecutive blocks. (C)</p> Signup and view all the answers

In database systems, all file systems blocks are grouped into smaller blocks to optimize storage.

<p>False (B)</p> Signup and view all the answers

In the context of database indexes, what type of searching is avoided through the use of an index?

<p>Sequential searching.</p> Signup and view all the answers

The primary index on old encyclopedias is analogous to 'Sorting and ______ of Data'.

<p>Organizing</p> Signup and view all the answers

Match each memory type with its approximate capacity:

<p>Register = 8 KB Cache = 8 MB Main Memory = 64 GB Hard Disk = 1 TB</p> Signup and view all the answers

What is the primary function of a (secondary) index in a database system?

<p>To efficiently find specific rows. (A)</p> Signup and view all the answers

In query optimization, algebraic rewriting always involves changing the semantics of the original query to improve performance.

<p>False (B)</p> Signup and view all the answers

Briefly describe the goal of query optimization.

<p>The goal is to find an 'optimal' way of executing a query, given that simply running the query naively might be costly.</p> Signup and view all the answers

Query optimization can be seen as finding a better operator ______.

<p>tree</p> Signup and view all the answers

Match the step to the stage of Query Processing:

<p>Query = Parser &amp; Translator Parser &amp; Translator = Canonical Operator Tree Canonical Operator Tree = Query Optimizer</p> Signup and view all the answers

In the context of query optimization, what does a 'cost-based' approach involve?

<p>Modeling and solving an optimization problem. (A)</p> Signup and view all the answers

In query optimization, a heuristic-based algorithm guarantees the selection of the absolute best query plan.

<p>False (B)</p> Signup and view all the answers

What is the purpose of defining 'good cost metrics' in cost-based query optimization?

<p>To quantify the 'cheapest' plan.</p> Signup and view all the answers

The two classes of query optimization algorithm are Cost-Based Algorithm and ______-Based Algorithm.

<p>Heuristic</p> Signup and view all the answers

Match the following steps with the general optimization algorithm the belong to:

<p>Enumerate alternative query plans = Cost-Based Algorithm Estimate cost for each alternative = Cost-Based Algorithm Choose the cheapest Query plan = Cost-Based Algorithm Rewrite plan using common heuristics = Heuristic-Based Algorithm</p> Signup and view all the answers

Which approach is typically the most accurate for Query Optimization?

<p>Hybrid approach (A)</p> Signup and view all the answers

In the context of query optimization, it's always necessary to find the absolute best query execution plan to ensure optimal performance.

<p>False (B)</p> Signup and view all the answers

What is the downside for an operator tree that has too many joins?

<p>There are more intermediate results leading to larger resources being needed.</p> Signup and view all the answers

The canonical and final operator tree should have a similar ______.

<p>semantics</p> Signup and view all the answers

Match the description to each concept:

<p>Canonical Operator Tree = An unoptimized relational algebra statement Annotated Operator Tree = Annotates an operator tree with algorithm annotations</p> Signup and view all the answers

With indexes available, the process of SQL Query is how many times faster?

<p>516 times faster (B)</p> Signup and view all the answers

A static plan must be found at run time for its query.

<p>False (B)</p> Signup and view all the answers

Cite 2 set operations with Commutativity.

<p>RuS = SUR, R∩S=S∩R</p> Signup and view all the answers

A is a heuristic to improve a canonical operator tree step by step, but still doesn't change the results.

<p>transformation</p> Signup and view all the answers

Match the definition to the action:

<p>Push Selections = To change the operator sequences as much as possible Break Up Selections = To break up conjunctive SELECT statements</p> Signup and view all the answers

What is true in regards to selections within heuristic pushing heuristics?

<p>Assumes condition only removes 1% of records, but join removes most records. (C)</p> Signup and view all the answers

Applying projections early doesn't reduce block sizes in blocks containing intermediate results.

<p>False (B)</p> Signup and view all the answers

What operator should native joins be more efficient than?

<p>Cartesian Products.</p> Signup and view all the answers

The step to combine selections and is used to find joins.

<p>Cartesian products</p> Signup and view all the answers

Match the definition with the step of Simple Algebraic Heuristic Algorithm:

<p>Break Up = Push and Introduce Projections: Try to project result sets as greedily as possible. Collect = Collect selections and projections such that there is only a block of selections. Combine = Combine selections and Cartesian products to joins</p> Signup and view all the answers

For Pipelining, which is not necessary?

<p>They are all not necessary. (C)</p> Signup and view all the answers

Pipelining always works well for every operation.

<p>False (B)</p> Signup and view all the answers

If one knows how to evaluate a query better than the optimizer, then what is a potential tool to use?

<p>Override hints.</p> Signup and view all the answers

The final state of query processes is ______.

<p>Query Optimization</p> Signup and view all the answers

Match the concept to what is mentioned in algebraic rewriting:

<p>Selections = Cascading and Commutativity</p> Signup and view all the answers

What is the primary role of a query processor in a Database Management System (DBMS)?

<p>Translating and optimizing queries to efficiently retrieve data. (D)</p> Signup and view all the answers

All storage media have the same speed when randomly accessing data blocks.

<p>False (B)</p> Signup and view all the answers

What is the core question to consider when fitting database records into blocks during file organization?

<p>Organize Blocks by ROWS or by COLUMNS?</p> Signup and view all the answers

A __________ index is an additional lookup data structure to more efficiently find specific rows.

<p>secondary</p> Signup and view all the answers

Match the storage media with their respective access times:

<p>Register = 1-10 ns Cache = 10-100 ns Main Memory = 60-300 ns Hard Disk = 10-12 ms</p> Signup and view all the answers

Which of the following tasks is not part of the query optimization process?

<p>File Organization (A)</p> Signup and view all the answers

When optimizing queries, it is generally advantageous to waste more time on optimizing than the time you are saving.

<p>False (B)</p> Signup and view all the answers

What does it mean to get the 'same query result but faster' and what is it in relation to?

<p>Optimizing Queries</p> Signup and view all the answers

A General __________-Based Algorithm involves enumerating alternative query plans, estimating their costs, and choosing the cheapest plan.

<p>Cost</p> Signup and view all the answers

Match each description with the correct term.

<p>Estimating the size of intermediate query results. = Cardinality Estimation Finding the most efficient execution strategy for a query. = Query Optimization Converting a SQL query into a relational algebra expression. = Query Parsing/Translation</p> Signup and view all the answers

When is it appropriate to to use Dynamic plans as opposed to static plans?

<p>They are useful when the querying behavior is very heterogeneous (D)</p> Signup and view all the answers

With Algebraic Query Rewriting transformations, the results of a query can be affected.

<p>False (B)</p> Signup and view all the answers

What is at the 'heart' of the operations of the Query Processor?

<p>Query Optimizer</p> Signup and view all the answers

Applying __________ early minimizes the size of records in intermediate results.

<p>projections</p> Signup and view all the answers

Match heuristic optimization techniques with their descriptions:

<p>Apply selections as early as possible = Reduces the number of intermediate results. Apply projections as early as possible = Reduces the size of records in intermediate results. Avoid Cartesian products = More efficient than Cartesian products.</p> Signup and view all the answers

Flashcards

Storage media reads data in what?

Data is read in chunks.

Storage media speed for block access?

Random access is slow, consecutive access is fast.

File systems group what?

Group storage media blocks into larger blocks.

Databases group what?

Groups file system blocks into even larger blocks.

Signup and view all the flashcards

How do you fit database records into blocks?

Organizing blocks by rows or columns.

Signup and view all the flashcards

What is a secondary index?

Additional lookup structure to efficiently find specific rows.

Signup and view all the flashcards

Indexes vs. sequential row searching?

It avoids scanning; looks up where it is stored.

Signup and view all the flashcards

Types of indexes?

Tree-based, hash indexes.

Signup and view all the flashcards

Query Optimization Goal?

Naïve query and finding the optimal execution method.

Signup and view all the flashcards

What does query optimization aim to do?

Retrieve same result faster.

Signup and view all the flashcards

What are Heuristics?

Using rules of thumb.

Signup and view all the flashcards

Cost-based optimization?

Modeling and solving an optimization problem.

Signup and view all the flashcards

General Cost-Based Algorithm steps?

Enumerate, Estimate, Choose

Signup and view all the flashcards

General Heuristic-Based Algorithm?

Start with a naive plan, tweak till good.

Signup and view all the flashcards

Heuristic-Based pros and cons?

Easy and cheap, result quality varies.

Signup and view all the flashcards

Cost-Based pros and cons?

Better results, complex and expensive.

Signup and view all the flashcards

Heuristic Optimization?

Use rules that commonly lead to good results.

Signup and view all the flashcards

What is a cost estimation function used for?

To evaluate the cost of a query.

Signup and view all the flashcards

Cost-based optimization (naive)

Selecting the cheapest solution.

Signup and view all the flashcards

Why is exhaustive search of query plan prohibitively expensive?

An exhaustive search strategy for finding the best plan for each query is prohibitively expensive

Signup and view all the flashcards

Goal for relational algebra optimization?

Find 'better' algebra trees with same result

Signup and view all the flashcards

Types of Query Plans?

Static, Dynamic and Hybrid.

Signup and view all the flashcards

Static plans: what are they saved for?

Queries of a kind.

Signup and view all the flashcards

Dynamic plans.

Best plan chosen at runtime.

Signup and view all the flashcards

Hybrid Plans?

Pre-optimization with fine-tuning during runtime.

Signup and view all the flashcards

Transform canonical tree?

Heuristic and DB statistics.

Signup and view all the flashcards

What is cost metric given by?

Cost is given by the number of disk accesses

Signup and view all the flashcards

Our Cost Metrics for now?

Size of intermediate result sets & Number of Block Accesses

Signup and view all the flashcards

Transformation Rules?

Transform an operator tree into another equivalent tree step by step.

Signup and view all the flashcards

Applying selections?

Apply selections early to reduce intermediate results.

Signup and view all the flashcards

Push Selections.

Change operator sequence to push SELECTs, as possible.

Signup and view all the flashcards

Size of records in intermediate results?

Tuple fits small and can contain with a less number of blocks

Signup and view all the flashcards

Push Projections

Break up cascading projections, commute them and move them down the tree as far as possible

Signup and view all the flashcards

Force Joins

Replace Cartesian Products with matching selections

Signup and view all the flashcards

Pipelines.

If the query is composed of several operators, results can be pipelined between operators

Signup and view all the flashcards

Pipeline execution ways?

Demand and Producer.

Signup and view all the flashcards

Producer Driven?

Each operations has input buffer and buffer filled eagerly by previous operations using all available inputs

Signup and view all the flashcards

Coordinated the execution?

The sequence of operators given by the evaluation plan has to be coordinated in the execution

Signup and view all the flashcards

What available operations for pipelining?

Pipelining restricts available operations such as sort, merge joins and others.

Signup and view all the flashcards

Query Processor

A component in DBMS to execute/optimise queries.

Signup and view all the flashcards

Memory Hierarchy

Registers, Cache, Main memory, Hard disk, Tertiary storage

Signup and view all the flashcards

Enumerate

Alternative query plans that are equivalent to the naive plan.

Signup and view all the flashcards

Disk accesses measurement

The number of seeks multiplied by the average seek costs.

Signup and view all the flashcards

Symbolic calculations

Algebra allows for symbolic calculations.

Signup and view all the flashcards

Cascading π

Only the last projection in a cascade takes effect.

Signup and view all the flashcards

Arbitrary order

Joins and Cartesian products.

Signup and view all the flashcards

Heuristics.

Heuristics are based on last lectures transformation rules and do not change the results.

Signup and view all the flashcards

Simple Heuristics

Avoid cartesian products

Signup and view all the flashcards

Pipelining.

Every record produced by the join is immediately checked for the selection condition(s).

Signup and view all the flashcards

Iterator interfaces

OPEN allocates buffer space for inputs/outputs and passes on parameters (e.g., selection conditions).

Signup and view all the flashcards

Coordinated execution.

The sequence of operators given by the evaluation plan has to be coordinated in the execution.

Signup and view all the flashcards

Study Notes

Memory Hierarchy: Cost vs. Access Time

  • Memory hierarchy is organized by cost and access time
  • Registers offer access times of 1-10 nanoseconds and are the most expensive
  • Cache provides access in 10-100 nanoseconds and is very expensive
  • Main Memory has access times of 60-300 nanoseconds, costing around 10 euros per gigabyte
  • Hard Disk access is slower, at 10-12 milliseconds, and is cheaper at ~0.10 euros per gigabyte
  • Latency Gap reported as 10^6
  • Tertiary Storage is slowest with access times reported as seconds to minutes, and is the cheapest storage option at less than 0.10 euros per gigabyte

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Memory Hierarchy Quiz
10 questions

Memory Hierarchy Quiz

DesirableInfinity avatar
DesirableInfinity
Memory Hierarchy Quiz
10 questions

Memory Hierarchy Quiz

UpbeatTourmaline avatar
UpbeatTourmaline
Memory Hierarchy: Cost vs Access Time
39 questions
Use Quizgecko on...
Browser
Browser