209 - 293: Query Optimization Flashcards

1
Q

What is a Query Graph?

A

A query graph is an undirected graph where relations are vertices and predicates between attributes of relations form edges.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the advantage of unnesting dependent joins?
A) Avoids the need for hash joins.
B) Reduces data redundancy.
C) Enables the use of alternate join implementations.
D) Increases query complexity.

A

C) Enables the use of alternate join implementations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Catalan Number’s relevance to join ordering?
A) Counts possible nested queries.
B) Gives the number of query graph edges.
C) Indicates the number of possible binary join trees.
D) Measures join selectivity.

A

C) Indicates the number of possible binary join trees.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the Principle of Optimality?

A

An optimal join tree’s subtrees are also optimal join trees for their respective relations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are Randomized Approaches in Optimization?

A

Methods like hill climbing or simulated annealing explore alternatives to avoid exhaustive enumeration of join trees.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Query Unnesting?

A

Unnesting transforms nested subqueries into equivalent joins or simplified queries for efficiency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are Cost Functions for Joins?

A

Nested Loops Join:|R1|x|R2|
Hash Join: 1.2 * |R1|
Sort-Merge Join: |R1|log|R1|+|R2|log|R2|

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which join tree type allows cross products?
A) Left-deep
B) Right-deep
C) Zigzag
D) Bushy

A

D) Bushy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Dynamic Programming in Query Optimization

A

Dynamic programming avoids redundant computations by reusing results of sub-problems to build optimal join trees incrementally.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Greedy Operator Ordering (GOO)

A

GOO selects join trees or relations to combine based on minimizing the size of intermediate results.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the primary reason for optimizing join order?
A) To increase query graph complexity.
B) To reduce the cost of intermediate results.
C) To avoid cyclic dependencies in the query graph.
D) To increase the size of the result set.

A

B) To reduce the cost of intermediate results.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a Join Tree?

A

A join tree is a binary tree used in query plans, where:

Leaf nodes are relations.
Inner nodes are join operators.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Cardinality of Join Trees

A

if T is leaf relation R:
|T|= |R|
if T= T1 join T2:
|T|=Product_(Ri e T1, Rj e T2) of f_i,j * |T1|*|T2|

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Join Selectivity Formula f_i,j

A

f_i,j = |Ri Join_pi, j Rj| / |Ri|x|Rj|

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a Materialized View?

A

A materialized view is a database object where the results of a query are precomputed and stored. Updates to the underlying tables require updates to the materialized view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is denormalization in database schema design?

A

Denormalization is the process of intentionally introducing redundancy into a database schema to improve query performance by reducing joins.

17
Q

What is the tradeoff of using denormalization in a database schema?

A

Denormalization improves query performance but introduces redundancy, which can complicate updates and increase storage costs.

18
Q

Which of the following statements about Materialized Views is correct?
a) The query result is computed at runtime.
b) They are automatically updated without user intervention.
c) They store precomputed query results.
d) They cannot be used for optimization.

A

c) They store precomputed query results.