Skip to content

Commit

Permalink
Add indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 committed Nov 25, 2024
1 parent a40719c commit 4c81f6c
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 0 deletions.
100 changes: 100 additions & 0 deletions thoth-api/migrations/v0.13.1/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
-- Remove indexes from account table
DROP INDEX IF EXISTS idx_account_email;

-- Remove indexes from publisher_account table
DROP INDEX IF EXISTS idx_publisher_account_account_id;

-- Remove indexes from work table
DROP INDEX IF EXISTS idx_work_work_id;
DROP INDEX IF EXISTS idx_work_doi;
DROP INDEX IF EXISTS idx_work_reference;
DROP INDEX IF EXISTS idx_work_short_abstract_substr;
DROP INDEX IF EXISTS idx_work_long_abstract_substr;
DROP INDEX IF EXISTS idx_work_landing_page;
DROP INDEX IF EXISTS idx_work_imprint_id;
DROP INDEX IF EXISTS idx_work_updated_at_with_relations_desc;
DROP INDEX IF EXISTS idx_work_full_title_asc;
DROP INDEX IF EXISTS idx_work_publication_date_asc;
DROP INDEX IF EXISTS idx_work_publication_date_desc;

-- Remove indexes from work_relation table
DROP INDEX IF EXISTS idx_work_relation_relation_ordinal_relator_asc;
DROP INDEX IF EXISTS idx_work_relation_relation_ordinal_related_asc;

-- Remove indexes from publisher table
DROP INDEX IF EXISTS idx_publisher_publisher_id;
DROP INDEX IF EXISTS idx_publisher_publisher_name;
DROP INDEX IF EXISTS idx_publisher_publisher_shortname;

-- Remove indexes from imprint table
DROP INDEX IF EXISTS idx_imprint_id;
DROP INDEX IF EXISTS idx_imprint_imprint_name;
DROP INDEX IF EXISTS idx_imprint_imprint_url;
DROP INDEX IF EXISTS idx_imprint_publisher_id;

-- Remove indexes from subject table
DROP INDEX IF EXISTS idx_subject_subject_code_asc;

-- Remove indexes from publication table
DROP INDEX IF EXISTS idx_publication_work_id;
DROP INDEX IF EXISTS idx_publication_isbn;
DROP INDEX IF EXISTS idx_publication_publication_type;

-- Remove indexes from location table
DROP INDEX IF EXISTS idx_location_location_platform_asc;

-- Remove indexes from price table
DROP INDEX IF EXISTS idx_price_currency_code_asc;

-- Remove indexes from contributor table
DROP INDEX IF EXISTS idx_contributor_full_name;
DROP INDEX IF EXISTS idx_contributor_last_name;
DROP INDEX IF EXISTS idx_contributor_orcid;

-- Remove indexes from contribution table
DROP INDEX IF EXISTS idx_contribution_work_id;
DROP INDEX IF EXISTS idx_contribution_contributor_id;
DROP INDEX IF EXISTS idx_contribution_ordinal_asc;

-- Remove indexes from affiliation table
DROP INDEX IF EXISTS idx_affiliation_contribution_id;
DROP INDEX IF EXISTS idx_affiliation_ordinal_asc;

-- Remove indexes from institution table
DROP INDEX IF EXISTS idx_institution_institution_name;
DROP INDEX IF EXISTS idx_institution_ror;
DROP INDEX IF EXISTS idx_institution_institution_doi;

-- Remove indexes from funding table
DROP INDEX IF EXISTS idx_funding_work_id;
DROP INDEX IF EXISTS idx_funding_program;

-- Remove indexes from series table
DROP INDEX IF EXISTS idx_series_series_name;
DROP INDEX IF EXISTS idx_series_issn_print;
DROP INDEX IF EXISTS idx_series_issn_digital;
DROP INDEX IF EXISTS idx_series_series_url;
DROP INDEX IF EXISTS idx_series_series_description;
DROP INDEX IF EXISTS idx_series_imprint_id;

-- Remove indexes from issue table
DROP INDEX IF EXISTS idx_issue_ordinal_work_id_asc;
DROP INDEX IF EXISTS idx_issue_ordinal_series_id_asc;

-- Remove indexes from language table
DROP INDEX IF EXISTS idx_language_language_code_asc;

-- Remove indexes from reference table
DROP INDEX IF EXISTS idx_reference_work_id;
DROP INDEX IF EXISTS idx_reference_doi;
DROP INDEX IF EXISTS idx_reference_unstructured_citation;
DROP INDEX IF EXISTS idx_reference_issn;
DROP INDEX IF EXISTS idx_reference_isbn;
DROP INDEX IF EXISTS idx_reference_journal_title;
DROP INDEX IF EXISTS idx_reference_article_title;
DROP INDEX IF EXISTS idx_reference_series_title;
DROP INDEX IF EXISTS idx_reference_volume_title;
DROP INDEX IF EXISTS idx_reference_author_substr;
DROP INDEX IF EXISTS idx_reference_standard_designator;
DROP INDEX IF EXISTS idx_reference_standards_body_name;
DROP INDEX IF EXISTS idx_reference_standards_body_acronym;
100 changes: 100 additions & 0 deletions thoth-api/migrations/v0.13.1/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
-- Indexes account table
CREATE INDEX idx_account_email ON account (email);

-- Indexes publisher_account table
CREATE INDEX idx_publisher_account_account_id ON publisher_account (account_id);

-- Indexes work table
CREATE INDEX idx_work_work_id ON work (work_id);
CREATE INDEX idx_work_doi ON work (doi);
CREATE INDEX idx_work_reference ON work (reference);
CREATE INDEX idx_work_short_abstract_substr ON work (substring(short_abstract FROM 1 FOR 255));
CREATE INDEX idx_work_long_abstract_substr ON work (substring(long_abstract FROM 1 FOR 255));
CREATE INDEX idx_work_landing_page ON work (landing_page);
CREATE INDEX idx_work_imprint_id ON work (imprint_id);
CREATE INDEX idx_work_updated_at_with_relations_desc ON work (updated_at_with_relations DESC, work_id);
CREATE INDEX idx_work_full_title_asc ON work (full_title ASC, work_id);
CREATE INDEX idx_work_publication_date_asc ON work (publication_date ASC, work_id);
CREATE INDEX idx_work_publication_date_desc ON work (publication_date DESC, work_id);

-- Indexes work_relation table
CREATE INDEX idx_work_relation_relation_ordinal_relator_asc ON work_relation (relation_ordinal ASC, relator_work_id);
CREATE INDEX idx_work_relation_relation_ordinal_related_asc ON work_relation (relation_ordinal ASC, related_work_id);

-- Indexes publisher table
CREATE INDEX idx_publisher_publisher_id ON publisher (publisher_id);
CREATE INDEX idx_publisher_publisher_name ON publisher (publisher_name);
CREATE INDEX idx_publisher_publisher_shortname ON publisher (publisher_shortname);

-- Indexes imprint table
CREATE INDEX idx_imprint_id ON imprint (imprint_id);
CREATE INDEX idx_imprint_imprint_name ON imprint (imprint_name);
CREATE INDEX idx_imprint_imprint_url ON imprint (imprint_url);
CREATE INDEX idx_imprint_publisher_id ON imprint (publisher_id);

-- Indexes subject table
CREATE INDEX idx_subject_subject_code_asc ON subject (subject_code ASC, work_id);

-- Indexes publication table
CREATE INDEX idx_publication_work_id ON publication (work_id);
CREATE INDEX idx_publication_isbn ON publication (isbn);
CREATE INDEX idx_publication_publication_type ON publication (publication_type);

-- Indexes location table
CREATE INDEX idx_location_location_platform_asc ON location (location_platform ASC, publication_id);

-- Indexes price table
CREATE INDEX idx_price_currency_code_asc ON price (currency_code ASC, publication_id);

-- Indexes contributor table
CREATE INDEX idx_contributor_full_name ON contributor (full_name);
CREATE INDEX idx_contributor_last_name ON contributor (last_name);
CREATE INDEX idx_contributor_orcid ON contributor (orcid);

-- Indexes contribution table
CREATE INDEX idx_contribution_work_id ON contribution (work_id);
CREATE INDEX idx_contribution_contributor_id ON contribution (contributor_id);
CREATE INDEX idx_contribution_ordinal_asc ON contribution (contribution_ordinal ASC, work_id);

-- Indexes affiliation table
CREATE INDEX idx_affiliation_contribution_id ON affiliation (contribution_id);
CREATE INDEX idx_affiliation_ordinal_asc ON affiliation (affiliation_ordinal ASC, contribution_id);

-- Indexes contributor table
CREATE INDEX idx_institution_institution_name ON institution (institution_name);
CREATE INDEX idx_institution_ror ON institution (ror);
CREATE INDEX idx_institution_institution_doi ON institution (institution_doi);

-- Indexes funding table
CREATE INDEX idx_funding_work_id ON funding (work_id);
CREATE INDEX idx_funding_program ON funding (program);

-- Indexes series table
CREATE INDEX idx_series_series_name ON series (series_name);
CREATE INDEX idx_series_issn_print ON series (issn_print);
CREATE INDEX idx_series_issn_digital ON series (issn_digital);
CREATE INDEX idx_series_series_url ON series (series_url);
CREATE INDEX idx_series_series_description ON series (series_description);
CREATE INDEX idx_series_imprint_id ON series (imprint_id);

-- Indexes issue table
CREATE INDEX idx_issue_ordinal_work_id_asc ON issue (issue_ordinal ASC, work_id);
CREATE INDEX idx_issue_ordinal_series_id_asc ON issue (issue_ordinal ASC, series_id);

-- Indexes language table
CREATE INDEX idx_language_language_code_asc ON language (language_code ASC, work_id);

-- Indexes reference table
CREATE INDEX idx_reference_work_id ON reference (work_id);
CREATE INDEX idx_reference_doi ON reference (doi);
CREATE INDEX idx_reference_unstructured_citation ON reference (unstructured_citation);
CREATE INDEX idx_reference_issn ON reference (issn);
CREATE INDEX idx_reference_isbn ON reference (isbn);
CREATE INDEX idx_reference_journal_title ON reference (journal_title);
CREATE INDEX idx_reference_article_title ON reference (article_title);
CREATE INDEX idx_reference_series_title ON reference (series_title);
CREATE INDEX idx_reference_volume_title ON reference (volume_title);
CREATE INDEX idx_reference_author_substr ON reference ((substring(author FROM 1 FOR 255)));
CREATE INDEX idx_reference_standard_designator ON reference (standard_designator);
CREATE INDEX idx_reference_standards_body_name ON reference (standards_body_name);
CREATE INDEX idx_reference_standards_body_acronym ON reference (standards_body_acronym);

0 comments on commit 4c81f6c

Please sign in to comment.