[open-ils-commits] r14450 - tags/rel_1_6_0_0/Open-ILS/src/sql/Pg (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Oct 15 12:46:06 EDT 2009


Author: miker
Date: 2009-10-15 12:46:02 -0400 (Thu, 15 Oct 2009)
New Revision: 14450

Modified:
   tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/1.4.0.5-1.6.0.0-upgrade-db.sql
   tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/extend-reporter.sql
Log:
backporting trunk fix for pathological historical circ report query plan

Modified: tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/1.4.0.5-1.6.0.0-upgrade-db.sql
===================================================================
--- tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/1.4.0.5-1.6.0.0-upgrade-db.sql	2009-10-15 16:44:17 UTC (rev 14449)
+++ tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/1.4.0.5-1.6.0.0-upgrade-db.sql	2009-10-15 16:46:02 UTC (rev 14450)
@@ -3859,6 +3859,14 @@
 
 COMMIT;
 
+CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
+ SELECT cp.id, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) + COALESCE(count(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;
+
 SELECT reporter.disable_materialized_simple_record_trigger();
 
 CREATE OR REPLACE FUNCTION reporter.simple_rec_update (r_id BIGINT, deleted BOOL) RETURNS BOOL AS $$

Modified: tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/extend-reporter.sql
===================================================================
--- tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/extend-reporter.sql	2009-10-15 16:44:17 UTC (rev 14449)
+++ tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/extend-reporter.sql	2009-10-15 16:46:02 UTC (rev 14450)
@@ -26,10 +26,11 @@
 );
 
 CREATE OR REPLACE VIEW extend_reporter.full_circ_count AS
- SELECT cp.id, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) AS circ_count
+ SELECT cp.id, COALESCE(sum(c.circ_count), 0::bigint) + COALESCE(count(circ.id), 0::bigint) + COALESCE(count(acirc.id), 0::bigint) AS circ_count
    FROM asset."copy" cp
    LEFT JOIN extend_reporter.legacy_circ_count c USING (id)
-   LEFT JOIN "action".all_circulation circ ON circ.target_copy = cp.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;
 
 CREATE OR REPLACE VIEW extend_reporter.global_bibs_by_holding_update AS



More information about the open-ils-commits mailing list