[15 points] After a system’s crash,
the undo-log using non-quiescent checkpointing contains the following
data:
a.
What are the correct values of the three <START CKPT
????> records ? You
have to provide three correct values for the three “????”s.
b.
Assuming that the three <START CKPT ???>
records are correctly stored in the log, according to your
answer at a., show which elements are recovered by the undo recovery
manager and compute their values after recovery.
<START T1> |
<T1 X1 55> |
<START T2> |
<T2 X2 99> |
<COMMIT T1> |
. . . . |
Is represented by the table:
N |
T |
E |
V |
0 |
T1 |
-1 |
|
1 |
T1 |
X1 |
55 |
2 |
T2 |
-1 |
|
3 |
T2 |
X2 |
99 |
4 |
T1 |
-2 |
|
. . . |
|
|
|
Recall that each transaction starts
and ends at
most once, i.e. a sequence <START T> … <COMMIT T> …
<START T>
… will not occur in the log. Moreover, any update by the transaction T
will
occur between its <START T> and <COMMIT T>, or between
<START
T> and <ABORT T> respectively.
Write a SQL query that can be run during database recovery, after a
system
crash. The answer to your query should return a table with two
attributes, E,
and V, indicating which elements have to be updated with what
values.
You should include each element E at most once in your answer:
otherwise
it would be ambiguous how to update it.
depts(DID(20), NAME(40), REGION(30)))All fields are CHAR except PRICE which is a FLOAT (which is represented using 20 characters).
depts_prods(DID(20), PID(20))
prods(NAME(40), PID(20), PRICE(20))
select depts.region, count(*)
from depts
group by depts.region
The second computes for each region how many products have been sold by departments in that region:
select depts.region, count(*)
from depts, depts_prods
where depts.did = depts_prods.did
group by depts.region
Turn in the following information for each of the two
queries: the
estimated running time and the actual running time. In addition,
indicate what join method the query optimizer selected for the second
query (i.e. you will say 'nested loop' or 'hash join' or ...).
For this and the following question you need to inspect the query plan.
Click on the corresponding button at the top of the Query Analyzer, or
hit CTRL-L. You also need to inspect the estimated cost: click on the
query plan's root node and read the 'subtree cost' (in seconds).
Finally, you need to measure the actual running time: this is shown by
the Query Analyzer at the bottom right; times under 1second are shown
as 0.
SELECT depts.region, avg(prods.price)Turn in the following: the query's answer, the estimated and actual running times, and the join methods selected by the query optimizer for the two joins.
FROM prods, depts_prods, depts
WHERE depts.did = depts_prods.did and
depts_prods.pid = prods.pid
GROUP BY depts.region
SELECT depts.region, depts_prods.didand
FROM depts, depts_prods
WHERE depts.did = depts_prods.did
SELECT count(*)
FROM depts, depts_prods
WHERE depts.did = depts_prods.did