expected_date_offset INTERVAL
-- acquisitions/business-side tables link to here
);
+CREATE INDEX serial_subscription_record_idx ON serial.subscription (record_entry);
+CREATE INDEX serial_subscription_owner_idx ON serial.subscription (owning_lib);
CREATE TABLE serial.subscription_note (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
value TEXT NOT NULL
);
+CREATE INDEX serial_subscription_note_sub_idx ON serial.subscription_note (subscription);
CREATE TABLE serial.caption_and_pattern (
id SERIAL PRIMARY KEY,
chron_4 TEXT,
chron_5 TEXT
);
+CREATE INDEX serial_caption_and_pattern_sub_idx ON serial.caption_and_pattern (subscription);
--at least one distribution per org_unit holding issues
CREATE TABLE serial.distribution (
unit_label_suffix TEXT
);
CREATE UNIQUE INDEX one_dist_per_sre_idx ON serial.distribution (record_entry);
+CREATE INDEX serial_distribution_sub_idx ON serial.distribution (subscription);
+CREATE INDEX serial_distribution_holding_lib_idx ON serial.distribution (holding_lib);
CREATE TABLE serial.distribution_note (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
value TEXT NOT NULL
);
+CREATE INDEX serial_distribution_note_dist_idx ON serial.distribution_note (distribution);
CREATE TABLE serial.stream (
id SERIAL PRIMARY KEY,
DEFERRABLE INITIALLY DEFERRED,
routing_label TEXT
);
+CREATE INDEX serial_stream_dist_idx ON serial.stream (distribution);
CREATE UNIQUE INDEX label_once_per_dist
ON serial.stream (distribution, routing_label)
(reader IS NULL AND department IS NOT NULL)
)
);
+CREATE INDEX serial_routing_list_user_stream_idx ON serial.routing_list_user (stream);
+CREATE INDEX serial_routing_list_user_reader_idx ON serial.routing_list_user (reader);
CREATE TABLE serial.issuance (
id SERIAL PRIMARY KEY,
holding_link_id INT -- probably defunct
-- TODO: add columns for separate enumeration/chronology values
);
+CREATE INDEX serial_issuance_sub_idx ON serial.issuance (subscription);
+CREATE INDEX serial_issuance_caption_and_pattern_idx ON serial.issuance (caption_and_pattern);
+CREATE INDEX serial_issuance_date_published_idx ON serial.issuance (date_published);
CREATE TABLE serial.unit (
sort_key TEXT,
detailed_contents TEXT NOT NULL,
summary_contents TEXT NOT NULL
) INHERITS (asset.copy);
-
ALTER TABLE serial.unit ADD PRIMARY KEY (id);
+CREATE UNIQUE INDEX unit_barcode_key ON serial.unit (barcode) WHERE deleted = FALSE OR deleted IS FALSE;
+CREATE INDEX unit_cn_idx ON serial.unit (call_number);
+CREATE INDEX unit_avail_cn_idx ON serial.unit (call_number);
+CREATE INDEX unit_creator_idx ON serial.unit ( creator );
+CREATE INDEX unit_editor_idx ON serial.unit ( editor );
-- must create this rule explicitly; it is not inherited from asset.copy
CREATE RULE protect_serial_unit_delete AS ON DELETE TO serial.unit DO INSTEAD UPDATE serial.unit SET deleted = TRUE WHERE OLD.id = serial.unit.id;
) DEFAULT 'Expected',
shadowed BOOL NOT NULL DEFAULT FALSE -- ignore when generating summaries/labels
);
+CREATE INDEX serial_item_stream_idx ON serial.item (stream);
+CREATE INDEX serial_item_issuance_idx ON serial.item (issuance);
+CREATE INDEX serial_item_unit_idx ON serial.item (unit);
+CREATE INDEX serial_item_uri_idx ON serial.item (uri);
+CREATE INDEX serial_item_date_received_idx ON serial.item (date_received);
+CREATE INDEX serial_item_status_idx ON serial.item (status);
CREATE TABLE serial.item_note (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
value TEXT NOT NULL
);
+CREATE INDEX serial_item_note_item_idx ON serial.item_note (item);
CREATE TABLE serial.basic_summary (
id SERIAL PRIMARY KEY,
generated_coverage TEXT NOT NULL,
textual_holdings TEXT
);
+CREATE INDEX serial_basic_summary_dist_idx ON serial.basic_summary (distribution);
CREATE TABLE serial.supplement_summary (
id SERIAL PRIMARY KEY,
generated_coverage TEXT NOT NULL,
textual_holdings TEXT
);
+CREATE INDEX serial_supplement_summary_dist_idx ON serial.supplement_summary (distribution);
CREATE TABLE serial.index_summary (
id SERIAL PRIMARY KEY,
generated_coverage TEXT NOT NULL,
textual_holdings TEXT
);
+CREATE INDEX serial_index_summary_dist_idx ON serial.index_summary (distribution);
COMMIT;
--- /dev/null
+
+-- No transaction, just creating indexes if they don't exist
+
+INSERT INTO config.upgrade_log (version) VALUES ('0398'); -- miker
+
+CREATE INDEX serial_subscription_record_idx ON serial.subscription (record_entry);
+CREATE INDEX serial_subscription_owner_idx ON serial.subscription (owning_lib);
+CREATE INDEX serial_caption_and_pattern_sub_idx ON serial.caption_and_pattern (subscription);
+CREATE INDEX serial_distribution_sub_idx ON serial.distribution (subscription);
+CREATE INDEX serial_distribution_holding_lib_idx ON serial.distribution (holding_lib);
+CREATE INDEX serial_distribution_note_dist_idx ON serial.distribution_note (distribution);
+CREATE INDEX serial_stream_dist_idx ON serial.stream (distribution);
+CREATE INDEX serial_routing_list_user_stream_idx ON serial.routing_list_user (stream);
+CREATE INDEX serial_routing_list_user_reader_idx ON serial.routing_list_user (reader);
+CREATE INDEX serial_issuance_sub_idx ON serial.issuance (subscription);
+CREATE INDEX serial_issuance_caption_and_pattern_idx ON serial.issuance (caption_and_pattern);
+CREATE INDEX serial_issuance_date_published_idx ON serial.issuance (date_published);
+CREATE UNIQUE INDEX unit_barcode_key ON serial.unit (barcode) WHERE deleted = FALSE OR deleted IS FALSE;
+CREATE INDEX unit_cn_idx ON serial.unit (call_number);
+CREATE INDEX unit_avail_cn_idx ON serial.unit (call_number);
+CREATE INDEX unit_creator_idx ON serial.unit ( creator );
+CREATE INDEX unit_editor_idx ON serial.unit ( editor );
+CREATE INDEX serial_item_stream_idx ON serial.item (stream);
+CREATE INDEX serial_item_issuance_idx ON serial.item (issuance);
+CREATE INDEX serial_item_unit_idx ON serial.item (unit);
+CREATE INDEX serial_item_uri_idx ON serial.item (uri);
+CREATE INDEX serial_item_date_received_idx ON serial.item (date_received);
+CREATE INDEX serial_item_status_idx ON serial.item (status);
+CREATE INDEX serial_item_note_item_idx ON serial.item_note (item);
+CREATE INDEX serial_basic_summary_dist_idx ON serial.basic_summary (distribution);
+CREATE INDEX serial_supplement_summary_dist_idx ON serial.supplement_summary (distribution);
+CREATE INDEX serial_index_summary_dist_idx ON serial.index_summary (distribution);
+