Sunteți pe pagina 1din 4

Prof.

Hasso Plattner

A Course in
In-Memory Data Management
The Inner Mechanics
of In-Memory Databases

August 31, 2013

This learning material is part of the reading material for Prof.


Plattner’s online lecture "In-Memory Data Management" taking place at
www.openHPI.de. If you have any questions or remarks regarding the
online lecture or the reading material, please give us a note at openhpi-
imdb@hpi.uni-potsdam.de. We are glad to further improve the material.
Chapter 10
Delete

The delete operation terminates the validity of a given tuple. It stores the
information in the database that a certain item is no longer valid. This oper-
ation can either be of physical or logical nature. A physical delete operation
removes an item from the database so that it is no longer physically ac-
cessible. In contrast, a logical delete operation only terminates the validity
of an item in the dataset, but keeps the tuple still available for temporal
queries [Pla09].
The SQL syntax for a delete statement looks like the following, where the
predicate may select a single or multiple tuples.
DELETE FROM table_name WHERE condition;

10.1 Example of Physical Delete

In the following example, all persons with the name ’Jane Doe’ are supposed
to be removed from a database table storing first and last names. Based on
the applied dictionary encoding (see Chapter 6), the table consists of two
columns with a dictionary and attribute vector each.

Dic$onary*“fname”* A5ribute*Vector*“fname”* Dic$onary*“lname”* A5ribute*Vector*“lname”*


valueID* value* recID* valueID* valueID* value* recID* valueID*
…" …" …" …" …" …" …" …"
22" Andrew" 38" 22" 17" Brown" 38" 19"
23" Jane" 39" 24" 18" Doe" 39" 21"
24" John" 40" 25" 19" Miller" 40" 17"
25" Mary" 41" 23" 20" Schmidt" 41" 18"
26" Peter" 42" 24" 21" Smith" 42" 18"
…" …" 43" 26" …" …" 43" 20"
…" …" …" …"

69
70 10 Delete

First, the valueIDs for the first and last name need to be identified. Jane cor-
responds to valueID 23 and Doe to valueID 18, according to their respective
dictionary.

Dic$onary*“fname”* A5ribute*Vector*“fname”* Dic$onary*“lname”* A5ribute*Vector*“lname”*


valueID* value* recID* valueID* valueID* value* recID* valueID*
…" …" …" …" …" …" …" …"
22" Andrew" 38" 22" 17" Brown" 38" 19"
23" Jane" 39" 24" 18" Doe" 39" 21"
24" John" 40" 25" 19" Miller" 40" 17"
25" Mary" 41" 23" 20" Schmidt" 41" 18"
26" Peter" 42" 24" 21" Smith" 42" 18"
…" …" 43" 26" …" …" 43" 20"
…" …" …" …"

Next, we scan through the attribute vectors and find the appropriate
positions, which means we look up the recordIDs for these values. In our
example, there is only one tuple with that combination of first and last name.

Dic$onary*“fname”* A5ribute*Vector*“fname”* Dic$onary*“lname”* A5ribute*Vector*“lname”*


valueID* value* recID* valueID* valueID* value* recID* valueID*
…" …" …" …" …" …" …" …"
22" Andrew" 38" 22" 17" Brown" 38" 19"
23" Jane" 39" 24" 18" Doe" 39" 21"
24" John" 40" 25" 19" Miller" 40" 17"
25" Mary" 41" 23" 20" Schmidt" 41" 18"
26" Peter" 42" 24" 21" Smith" 42" 18"
…" …" 43" 26" …" …" 43" 20"
…" …" …" …"

When finally deleting the two values from the attribute vectors, all subse-
quent tuples need to be adjusted to maintain a sequence without gaps and
they are moved to preserve a sequential memory area. This implementation
alternative of the delete operation is therefore very expensive in terms of per-
formance. In Chapter 26, later during the course, the insert-only approach is
presented as a better alternative to implement deletion in typical enterprise
use cases. This approach is of logical nature.

Dic$onary*“fname”* A5ribute*Vector*”fname”* Dic$onary*“lname”* A5ribute*Vector*“lname”*


valueID* value* recID* valueID* valueID* value* recID* valueID*
…" …" …" …" …" …" …" …"
22" Andrew" 38" 22" 17" Brown" 38" 19"
23" Jane" 39" 24" 18" Doe" 39" 21"
24" John" 40" 25" 19" Miller" 40" 17"
25" Mary" 41" 23" 20" Schmidt" 41" 18"
26" Peter" 41" 24" 21" Smith" 41" 18"
…" …" 42" 26" …" …" 42" 20"
…" …" …" …"
REFERENCES 71

10.2 References

[Pla09] H. Plattner. A Common Database Approach for OLTP and OLAP


Using an In-Memory Column Database. In SIGMOD, pages 1–2,
2009.

S-ar putea să vă placă și