// vim: spl=en spell tw=80 encoding=utf-8:
==== Practice Exercises ====
11.3 - Give an example of a relational-algebra expression and a query-processing
strategy in each of the following situations:
a. MRU is preferable to LRU.
b. LRU is preferable to MRU.
----
a. When processing a selection over a table it would be preferred to use MRU
because we would be sequentially scanning the table. The Most Recently Used
block will not again be needed when thus processing such a query.
b. ??
11.4 Consider the deletion of record 5 from the file in figure 11.7. Compare the
relative merits of the following techniques for implementing the deletion.
a. Move record 6 to the space occupied by record 5, and move record 7 to the
space occupied by record 6.
b. Move record 7 to the space occupied by record 5.
c. Mark record 5 as deleted and move no records.
----
if a file is somehow ordered strategy a will keep that ordering. Despite of that
it is the most costly strategy. Strategy b is quite cheap but does not maintain
ordering of the records. It has the added advantage of not leaving blank space
in the file. Strategy c is the cheapest but requires free space management so as
not to have files cluttered with 'free' space.
11.7 Consider the following bitmap technique for tracking free space in a file.
For each block in the file, two bits are maintained in the bitmap. If the block
is between 0 and 30 percent full the bits are 00, between 30 and 60 percent full
the bits are 01, between 60 and 90 percent the bits are 10, and above 90 percent
the bits are 11. Such bitmaps can be kept in memory even for quite large files.
a. Describe how to keep the bitmap up to date on record insertions and
deletions.
b. Outline the benefit of the bitmap technique over free lists in searching for
free space and in updating free space information.
-----
a. After insertion or deletion one can recalculate the free space in the block
and update the memory bitmap. Notice that this recalculation is done in memory
and thus very cheap.
b. As free lists are usually kept in disk (as pointers in the blocks) this
technique has the obvious advantage that search for free space can be done
in-memory, at the cost of no disk access. This is also true for updates.
==== Exercises ====
11.9 How does the remapping of bad sectors by disk controllers affect
data-retrieval rates?
----
As sectors reserved for bad sector substitution are usually in a separate disk
zone, sequential fetching can be impaired by this technique. Blocks that are in
a zone are remapped to blocks in another zone, thus requiring seeks for
contiguous fetching.
11.11 Explain why the allocation of records to blocks affects database-system
performance significantly.
----
Data that is supposed to be accessed in sequence should be close to avoid disk
seeks. If data is badly organized (allocated) this can give rise to a lot of
disk seeks which are the most costly disk operations.
11.13 In the sequential file organization, why is an overflow block used even if
there is, at the moment, only one overflow record.
----
Because insertion of a record implies moving _all_ the records that are after
it. This is a very costly operation, so it should be better to have an overflow
block instead of doing it. Also, if there is one record overflown, possibility
that others follow is great (it's like hash tables, or vectors that when
extended it's never just by one capacity unit).
11.14 List two advantages and two disadvantages of each of the following
strategies for storing a relational database:
a. Store each relation in one file.
b. Store multiple relations (perhaps even the entire database) in one file.
----
a.
adv1: filesystem file size limits apply to relation only, not database.
adv2: simpler access implementation.
dis1: one cannot fine tune global block allocation.
dis2: easier block reordering inside relation.
b.
adv1: one can better control block allocation to relations.
adv2: hard to reorder blocks.
dis1: filesystem file size limits apply to whole database.
dis2: harder to implement access, sometimes requiring several indirections.
11.16 If you have data that should not be lost on disk failure, and the data are
write intensive, how would you store the data?
----
RAID 5 with non-volatile write buffers. Or, if data size permits it, on
non-volatile ram with ECC.
11.17 In earlier generation disks the number of sectors per track was the same
across all tracks. Current generation disks have more sectors per track on outer
tracks, and fewer sectors per track on inner tracks (since they are shorter in
length). What is the effect of such a change on each of the three main
indicators of disk speed?
----
It has no effect whatsoever in Seek Time and Rotational Latency. It can however
mean that for some tracks Data-Transfer rate can be higher or lower depending on
which track the blocks are.
11.18 Standard buffer managers assume each page is of the same size and costs
the same to read. Consider a bugger manager that, instead of LRU, uses the rate
of reference to objects, that is, how often an object has been accessed in the
last n seconds. Suppose we want to store in the buffer objects of varying sizes,
and varying read costs (such as Web pages, whose read cost depends on the site
from which they are fetched). Suggest how a buffer manager may choose which page
to evict from the buffer.
----
In this case buffer managers could use latency and page size as a factor. The
idea is that long or far away pages should take longer to age (in LRU case) or
their access should be considered for longer periods (n increases in rate of
reference).