[open-ils-commits] [GIT] Evergreen ILS branch master updated. 0cbc35b72615a56ed8ad9a0dd0dd89261111b0dd

Evergreen Git git at git.evergreen-ils.org
Tue Aug 18 23:07:48 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  0cbc35b72615a56ed8ad9a0dd0dd89261111b0dd (commit)
       via  54eb62a68268768bdb44b04459376f4c11c2381f (commit)
      from  c22cd51ceae8683c31ad2fea7b2388a1c9262dfa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0cbc35b72615a56ed8ad9a0dd0dd89261111b0dd
Author: Ben Shum <bshum at biblio.org>
Date:   Tue Aug 18 23:06:39 2015 -0400

    LP#1419172: Stamping upgrade script for optimizing full circ count
    
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 6110f7d..3b00fb8 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0926', :eg_version); -- dpearl/kmlussier/bshum
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0927', :eg_version); -- dbwells/csharp/bshum
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.optimize_full_circ_count.sql b/Open-ILS/src/sql/Pg/upgrade/0927.schema.optimize_full_circ_count.sql
similarity index 85%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.optimize_full_circ_count.sql
rename to Open-ILS/src/sql/Pg/upgrade/0927.schema.optimize_full_circ_count.sql
index 6440dfa..f1651e0 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.optimize_full_circ_count.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0927.schema.optimize_full_circ_count.sql
@@ -1,6 +1,6 @@
 BEGIN;
 
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0927', :eg_version);
 
 CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
    SELECT cp.id,

commit 54eb62a68268768bdb44b04459376f4c11c2381f
Author: Dan Wells <dbw2 at calvin.edu>
Date:   Thu May 7 16:43:16 2015 -0400

    LP#1419172 Optimize full_circ_count view to avoid seq scans
    
    As reported by Chris Sharp:
    
    "The reporter.classic_item_list view was modified in bug 1208572 to use
    extend_reporter.full_circ_count to provide the use count for each item.
    Unfortunately, this change was found to be the cause of consistently
    long-running (2+ hours) reports queries in PINES as its query plan on
    our PostgreSQL 9.3 server was resulting in sequential scans of both the
    circulation and aged_circulation tables."
    
    This commit restructures the view to avoid JOINs, and is in production
    at PINES with noted improvement.
    
    Signed-off-by: Dan Wells <dbw2 at calvin.edu>
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/src/sql/Pg/extend-reporter.sql b/Open-ILS/src/sql/Pg/extend-reporter.sql
index cb7eec5..852b537 100644
--- a/Open-ILS/src/sql/Pg/extend-reporter.sql
+++ b/Open-ILS/src/sql/Pg/extend-reporter.sql
@@ -26,12 +26,11 @@ CREATE TABLE extend_reporter.legacy_circ_count (
 );
 
 CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
- SELECT cp.id, COALESCE(c.circ_count, 0::bigint) + COALESCE(count(DISTINCT circ.id), 0::bigint) + COALESCE(count(DISTINCT acirc.id), 0::bigint) AS circ_count
-   FROM asset."copy" cp
-   LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
-   LEFT JOIN "action".circulation circ ON circ.target_copy = cp.id
-   LEFT JOIN "action".aged_circulation acirc ON acirc.target_copy = cp.id
-  GROUP BY cp.id, c.circ_count;
+   SELECT cp.id,
+   COALESCE((SELECT circ_count FROM extend_reporter.legacy_circ_count WHERE id = cp.id), 0)
+   + (SELECT COUNT(*) FROM action.circulation WHERE target_copy = cp.id)
+   + (SELECT COUNT(*) FROM action.aged_circulation WHERE target_copy = cp.id) AS circ_count
+   FROM asset.copy cp;
 
 CREATE OR REPLACE VIEW extend_reporter.global_bibs_by_holding_update AS
   SELECT DISTINCT ON (id) id, holding_update, update_type
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.optimize_full_circ_count.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.optimize_full_circ_count.sql
new file mode 100644
index 0000000..6440dfa
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.optimize_full_circ_count.sql
@@ -0,0 +1,12 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
+   SELECT cp.id,
+   COALESCE((SELECT circ_count FROM extend_reporter.legacy_circ_count WHERE id = cp.id), 0)
+   + (SELECT COUNT(*) FROM action.circulation WHERE target_copy = cp.id)
+   + (SELECT COUNT(*) FROM action.aged_circulation WHERE target_copy = cp.id) AS circ_count
+   FROM asset.copy cp;
+
+COMMIT;

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/extend-reporter.sql            |   11 +++++------
 .../0927.schema.optimize_full_circ_count.sql       |   12 ++++++++++++
 3 files changed, 18 insertions(+), 7 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0927.schema.optimize_full_circ_count.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list