From f2a5b46dd36fab1f4db439155b7ab3151fd2ac5c Mon Sep 17 00:00:00 2001 From: scottmk Date: Wed, 23 Sep 2009 17:56:38 +0000 Subject: [PATCH] Create two new indexes on action.circulation & action.aged_circulation, and a virtual view for counting circulations by year. M Open-ILS/src/sql/Pg/002.schema.config.sql A Open-ILS/src/sql/Pg/upgrade/0017.schema.circ-target-copy-indexes.sql M Open-ILS/examples/fm_IDL.xml git-svn-id: svn://svn.open-ils.org/ILS/trunk@14129 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 45 ++++++++++++++++++++++ Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- .../0017.schema.circ-target-copy-indexes.sql | 11 ++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0017.schema.circ-target-copy-indexes.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 66f45f2e0c..b9fa062e69 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -5132,6 +5132,51 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + SELECT id, SUM(count) AS count, year, is_renewal FROM ( + SELECT + cp.id, + COUNT(circ.id), + EXTRACT(YEAR FROM circ.xact_start) AS year, + (phone_renewal OR desk_renewal OR opac_renewal) as is_renewal + FROM + asset.copy cp + JOIN action.circulation circ ON (cp.id = circ.target_copy) + GROUP BY 1, 3, 4 + UNION + SELECT + cp.id, + COUNT(circ.id), + EXTRACT(YEAR FROM circ.xact_start) AS year, + (phone_renewal OR desk_renewal OR opac_renewal) as is_renewal + FROM + asset.copy cp + JOIN action.aged_circulation circ ON (cp.id = circ.target_copy) + GROUP BY 1, 3, 4 + UNION + SELECT + id, + circ_count, + -1 AS year, + false as is_renewal + FROM + extend_reporter.legacy_circ_count + )x GROUP BY 1, 3, 4 + + + + + + + + + + + + + diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index a6481c37ff..341cea1efb 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0016'); +INSERT INTO config.upgrade_log (version) VALUES ('0017'); CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0017.schema.circ-target-copy-indexes.sql b/Open-ILS/src/sql/Pg/upgrade/0017.schema.circ-target-copy-indexes.sql new file mode 100644 index 0000000000..d6bb92d4b5 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0017.schema.circ-target-copy-indexes.sql @@ -0,0 +1,11 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0017'); + +CREATE INDEX action_circulation_target_copy_idx +ON action.circulation (target_copy); + +CREATE INDEX action_aged_circulation_target_copy_idx ON +ON action.aged_circulation (target_copy); + +COMMIT; -- 2.11.0