Upgrades to utility code for new formats, and a few more database tweaks.
[cumulus.git] / schema.sql
index 1c6e84e..e0f16a6 100644 (file)
@@ -17,6 +17,7 @@ create table segments (
     segment text unique not null,
     path text,
     checksum text,
+    mtime real,
     size integer
 );
 
@@ -40,10 +41,11 @@ create table segments_used (
     utilization real
 );
 
--- Index tracking which blocks are used by which snapshots.
-create table snapshot_contents (
-    blockid integer,
-    snapshotid integer
-);
-create unique index snapshot_contents_unique
-    on snapshot_contents(blockid, snapshotid);
+-- Overall estimate of segment utilization, for all snapshots combined.
+create view segment_info as
+select segmentid, mtime, size, cast(size * utilization as integer) as used,
+       utilization
+from segments join
+     (select segmentid, max(utilization) as utilization
+      from segments_used group by segmentid)
+using (segmentid);