1 -- We maintain a local index of data blocks that have been previously stored
2 -- for constructing incremental snapshots.
4 -- The index is stored in an SQLite3 database. This is its schema.
6 -- List of snapshots which have been created.
7 create table snapshots (
8 snapshotid integer primary key,
15 -- List of segments which have been created.
16 create table segments (
17 segmentid integer primary key,
18 segment text unique not null,
25 -- Index of all blocks which have been stored, by checksum.
26 create table block_index (
27 blockid integer primary key,
28 segmentid integer not null,
35 create index block_content_index on block_index(checksum);
36 create unique index block_name_index on block_index(segmentid, object);
38 -- Summary of segment utilization for each snapshots.
39 create table segments_used (
40 snapshotid integer not null,
41 segmentid integer not null,
44 create unique index segments_used_index
45 on segments_used(snapshotid, segmentid);
47 -- Overall estimate of segment utilization, for all snapshots combined.
48 create view segment_info as
49 select segmentid, mtime, size, cast(size * utilization as integer) as used,
52 (select segmentid, max(utilization) as utilization
53 from segments_used group by segmentid)