diff --git a/dspace/etc/database_schema.sql b/dspace/etc/database_schema.sql index 9b3ff923ef..3ad9c1bf40 100644 --- a/dspace/etc/database_schema.sql +++ b/dspace/etc/database_schema.sql @@ -325,6 +325,11 @@ CREATE TABLE Community2Collection collection_id INTEGER REFERENCES Collection(collection_id) ); +-- Index on community ID +CREATE INDEX Community2Collection_community_id_idx ON Community2Collection(community_id); +-- Index on collection ID +CREATE INDEX Community2Collection_collection_id_idx ON Community2Collection(collection_id); + ------------------------------------------------------- -- Collection2Item table ------------------------------------------------------- @@ -337,6 +342,8 @@ CREATE TABLE Collection2Item -- index by collection_id CREATE INDEX collection2item_collection_idx ON Collection2Item(collection_id); +-- and item_id +CREATE INDEX Collection2Item_item_id_idx ON Collection2Item( item_id ); ------------------------------------------------------- -- ResourcePolicy table @@ -384,6 +391,8 @@ CREATE TABLE Handle -- index by handle, commonly looked up CREATE INDEX handle_handle_idx ON Handle(handle); +-- index by resource id and resource type id +CREATE INDEX handle_resource_id_and_type_idx ON handle(resource_id, resource_type_id); ------------------------------------------------------- -- WorkspaceItem table @@ -503,6 +512,9 @@ CREATE TABLE Communities2Item item_id INTEGER REFERENCES Item(item_id) ); +-- Index by item_id for update/re-index +CREATE INDEX Communities2Item_item_id_idx ON Communities2Item( item_id ); + ------------------------------------------------------- -- Community2Item view ------------------------------------------------------ @@ -525,6 +537,8 @@ CREATE TABLE ItemsByAuthor -- index by sort_author, of course! CREATE INDEX sort_author_idx on ItemsByAuthor(sort_author); +-- And by item ID for updates/re-indexing +CREATE INDEX ItemsByAuthor_item_id_idx ON ItemsByAuthor(item_id); ------------------------------------------------------- -- CollectionItemsByAuthor view @@ -557,7 +571,8 @@ CREATE TABLE ItemsByTitle -- index by the sort_title CREATE INDEX sort_title_idx on ItemsByTitle(sort_title); - +-- And by item ID for updates/re-indexing +CREATE INDEX ItemsByTitle_item_id_idx ON ItemsByTitle(item_id); ------------------------------------------------------- -- CollectionItemsByTitle view @@ -589,6 +604,8 @@ CREATE TABLE ItemsByDate -- sort by date CREATE INDEX date_issued_idx on ItemsByDate(date_issued); +-- And by item ID for updates/re-indexing +CREATE INDEX ItemsByDate_item_id_idx ON ItemsByDate(item_id); ------------------------------------------------------- -- CollectionItemsByDate view @@ -618,6 +635,9 @@ CREATE TABLE ItemsByDateAccessioned date_accessioned TEXT ); +-- Index on item_id for update/re-indexing +CREATE INDEX ItemsByDateAccessioned_item_id_idx ON ItemsByDateAccessioned(item_id); + ------------------------------------------------------- -- CollectionItemsByDateAccession view ------------------------------------------------------- diff --git a/dspace/etc/database_schema_12-13.sql b/dspace/etc/database_schema_12-13.sql index 1edcac5e19..4f05f5a60b 100644 --- a/dspace/etc/database_schema_12-13.sql +++ b/dspace/etc/database_schema_12-13.sql @@ -67,4 +67,23 @@ ALTER TABLE collection ADD submitter INTEGER REFERENCES EPersonGroup( eperson_gr ALTER TABLE collection ADD admin INTEGER REFERENCES EPersonGroup( eperson_group_id ); -ALTER TABLE eperson ADD netid varchar(64) UNIQUE; \ No newline at end of file +ALTER TABLE eperson ADD netid varchar(64) UNIQUE; + +------------------------------------------------------------------------------- +-- Additional indices for performance +------------------------------------------------------------------------------- + +-- index by resource id and resource type id +CREATE INDEX handle_resource_id_and_type_idx ON handle(resource_id, resource_type_id); + +-- Indexing browse tables update/re-index performance +CREATE INDEX Communities2Item_item_id_idx ON Communities2Item( item_id ); +CREATE INDEX ItemsByAuthor_item_id_idx ON ItemsByAuthor(item_id); +CREATE INDEX ItemsByTitle_item_id_idx ON ItemsByTitle(item_id); +CREATE INDEX ItemsByDate_item_id_idx ON ItemsByDate(item_id); +CREATE INDEX ItemsByDateAccessioned_item_id_idx ON ItemsByDateAccessioned(item_id); + +-- Improve mapping tables +CREATE INDEX Community2Collection_community_id_idx ON Community2Collection(community_id); +CREATE INDEX Community2Collection_collection_id_idx ON Community2Collection(collection_id); +CREATE INDEX Collection2Item_item_id_idx ON Collection2Item( item_id );