diff --git a/sql/upgrades/181.sql b/sql/upgrades/181.sql new file mode 100644 --- /dev/null +++ b/sql/upgrades/181.sql @@ -0,0 +1,16 @@ +-- SWH DB schema upgrade +-- from_version: 180 +-- to_version: 181 +-- description: add *_raw_manifest_not_null indexes + +insert into dbversion(version, release, description) + values(181, now(), 'Work In Progress'); + +-- copied from 60-indexes.sql +select swh_get_dbflavor() = 'default' as dbflavor_default \gset + +\if :dbflavor_default + create index concurrently directory_raw_manifest_not_null on directory(id) where raw_manifest is not null; + create index concurrently revision_raw_manifest_not_null on revision(id) where raw_manifest is not null; + create index concurrently release_raw_manifest_not_null on release(id) where raw_manifest is not null; +\endif diff --git a/swh/storage/postgresql/db.py b/swh/storage/postgresql/db.py --- a/swh/storage/postgresql/db.py +++ b/swh/storage/postgresql/db.py @@ -30,7 +30,7 @@ """ - current_version = 180 + current_version = 181 def mktemp_dir_entry(self, entry_type, cur=None): self._cursor(cur).execute( diff --git a/swh/storage/sql/30-schema.sql b/swh/storage/sql/30-schema.sql --- a/swh/storage/sql/30-schema.sql +++ b/swh/storage/sql/30-schema.sql @@ -17,7 +17,7 @@ -- latest schema version insert into dbversion(version, release, description) - values(180, now(), 'Work In Progress'); + values(181, now(), 'Work In Progress'); -- a SHA1 checksum create domain sha1 as bytea check (length(value) = 20); diff --git a/swh/storage/sql/60-indexes.sql b/swh/storage/sql/60-indexes.sql --- a/swh/storage/sql/60-indexes.sql +++ b/swh/storage/sql/60-indexes.sql @@ -65,6 +65,7 @@ create index concurrently on directory using gin (file_entries); -- to be reviewed create index concurrently on directory using gin (rev_entries); -- to be reviewed create unique index concurrently on directory(object_id); -- to be reviewed + create index concurrently directory_raw_manifest_not_null on directory(id) where raw_manifest is not null; -- allows keeping track of the few directories that could not be parsed \endif -- directory_entry_dir @@ -153,6 +154,7 @@ \if :dbflavor_default create index concurrently on revision(directory); -- to be reviewed create unique index concurrently on revision(object_id); -- to be reviewed + create index concurrently revision_raw_manifest_not_null on revision(id) where raw_manifest is not null; -- allows keeping track of the few revisions that could not be parsed \endif -- revision_history @@ -238,6 +240,7 @@ \if :dbflavor_default create index concurrently on release(target, target_type); -- to be reviewed create unique index concurrently on release(object_id); -- to be reviewed + create index concurrently release_raw_manifest_not_null on release(id) where raw_manifest is not null; -- allows keeping track of the few releases that could not be parsed \endif \if :dbflavor_does_deduplication