Ahmad Yazdankhah ID 219 Section 13.6

advertisement

1

1.

2.

3.

4.

5.

6.

Database address space

Virtual address space

Map table

Translation table

Swizzling and UnSwizzling

Pinned Blocks

2

A database system is usually client-server architecture

The client applications use a conventional virtual address space

Server’s data is structured as database address space

3

Physical Address: each block and record has a physical address as:

Host

Disk

ID

Cylind.

Num.

Track # Block # Offset

Logical Address: each block can have a shorter address (4 bytes) as logical address.

A map table can translate logical-to-physical

4

Logical address

Logical Physical

Physical address

5

Why we use map table?

Answer: flexibility in data manipulation

How?

All pointers to the records refer to the map table

When moving records around or deleting, we can update the map table.

6

How to combine physical and logical addresses?

With the physical address, reach the block and using the key value to find the record

Host

Disk

ID

Cylind.

Num.

Track # Block #

Key

Value

Keep an offset table in the block header

Offset

Table

Unused

Record

4

Record

3

Record

2

Record

1

7

To move a record in a block, just change the offset table entry

To delete a record, just leave a tombstone in the offset table

To move to another block , just put the new block address in the offset table ( forwarding address )

8

There are some cases that records contain

pointers

 When records represent objects

(and not tuples)

 Object-Relational databases

 Index blocks (next chapter)

9

Here are some facts:

 We know that all data manipulations are done in main memory.

 To refer a data item on HD, we use database address space.

 To refer a data item in memory, we use memory address .

10

Question: what would happen to the pointers when we move the block from the secondary storage to memory?

11

So, we need a translation table to map this correspondence.

Database Address

Database

Address

Memory

Address

Memory address

12

The techniques that change the pointer addresses is known as Pointer Swizzling .

The idea is that we should change the pointers content in order to point to the right locations.

13

When we move a block to memory, we put an entry for each pointer it has into the translation table.

14

In this technique, we swizzle the pointers when we need them.

In this way we save the time because some records won’t be invoked at all.

15

In this technique, we just create the translation table for the blocks and don’t swizzle the pointers inside the blocks.

It means that the pointers always use database address space.

16

Question: what would happen to the pointers when we move the block from memory to the secondary storage?

The pointers should be changed to database address space. This is called Unswizzling !

The translation table can be used in both direction.

17

If the block in the memory cannot be written back to the disk safely, we call it Pinned .

Example: Block B1 has a swizzled pointer to a record in Block B2. What would happen if we move the B2?

In this situation, we set the pin bit of B2 to prevent moving of B2.

18

One possible approach is to keep track of all references to a block in a linked list.

19

20

Download