[open-ils-commits] [GIT] Evergreen ILS branch master updated. f762b75ac430ed70365ebc0385d2c9d0da04ab26
Evergreen Git
git at git.evergreen-ils.org
Mon Jun 27 18:49:14 EDT 2011
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 f762b75ac430ed70365ebc0385d2c9d0da04ab26 (commit)
via 27bed378975a1164232d0b922cd03ce7493dee82 (commit)
via cdcbbbbc520e91f003b68d716dcd0d75a2b68971 (commit)
from a30820353694707a2096663a4b2b86fa9c2db4da (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 f762b75ac430ed70365ebc0385d2c9d0da04ab26
Author: Mike Rylander <mrylander at gmail.com>
Date: Mon Jun 27 18:47:14 2011 -0400
Pinning upgrade script for copy visibility speed boost
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 18c39b3..c7b404d 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,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 ('0567', :eg_version); -- miker/berick
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0568', :eg_version); -- miker/tsbere
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.cache_visibility_speed_boost.sql b/Open-ILS/src/sql/Pg/upgrade/0568.schema.cache_visibility_speed_boost.sql
similarity index 97%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.cache_visibility_speed_boost.sql
rename to Open-ILS/src/sql/Pg/upgrade/0568.schema.cache_visibility_speed_boost.sql
index 79ea252..6e10db0 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.cache_visibility_speed_boost.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0568.schema.cache_visibility_speed_boost.sql
@@ -1,3 +1,11 @@
+-- Evergreen DB patch 0568.schema.cache_visibility_speed_boost.sql
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0568', :eg_version);
+
CREATE OR REPLACE FUNCTION asset.cache_copy_visibility () RETURNS TRIGGER as $func$
DECLARE
add_front TEXT;
@@ -205,3 +213,6 @@ BEGIN
RETURN NEW;
END;
$func$ LANGUAGE PLPGSQL;
+
+COMMIT;
+
commit 27bed378975a1164232d0b922cd03ce7493dee82
Author: Thomas Berezansky <tsbere at mvlc.org>
Date: Tue Jun 21 10:24:58 2011 -0400
Unwrapped upgrade script
Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.cache_visibility_speed_boost.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.cache_visibility_speed_boost.sql
new file mode 100644
index 0000000..79ea252
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.cache_visibility_speed_boost.sql
@@ -0,0 +1,207 @@
+CREATE OR REPLACE FUNCTION asset.cache_copy_visibility () RETURNS TRIGGER as $func$
+DECLARE
+ add_front TEXT;
+ add_back TEXT;
+ add_base_query TEXT;
+ add_peer_query TEXT;
+ remove_query TEXT;
+ do_add BOOLEAN := false;
+ do_remove BOOLEAN := false;
+BEGIN
+ add_base_query := $$
+ SELECT cp.id, cp.circ_lib, cn.record, cn.id AS call_number, cp.location, cp.status
+ FROM asset.copy cp
+ JOIN asset.call_number cn ON (cn.id = cp.call_number)
+ JOIN actor.org_unit a ON (cp.circ_lib = a.id)
+ JOIN asset.copy_location cl ON (cp.location = cl.id)
+ JOIN config.copy_status cs ON (cp.status = cs.id)
+ JOIN biblio.record_entry b ON (cn.record = b.id)
+ WHERE NOT cp.deleted
+ AND NOT cn.deleted
+ AND NOT b.deleted
+ AND cs.opac_visible
+ AND cl.opac_visible
+ AND cp.opac_visible
+ AND a.opac_visible
+ $$;
+ add_peer_query := $$
+ SELECT cp.id, cp.circ_lib, pbcm.peer_record AS record, NULL AS call_number, cp.location, cp.status
+ FROM asset.copy cp
+ JOIN biblio.peer_bib_copy_map pbcm ON (pbcm.target_copy = cp.id)
+ JOIN actor.org_unit a ON (cp.circ_lib = a.id)
+ JOIN asset.copy_location cl ON (cp.location = cl.id)
+ JOIN config.copy_status cs ON (cp.status = cs.id)
+ WHERE NOT cp.deleted
+ AND cs.opac_visible
+ AND cl.opac_visible
+ AND cp.opac_visible
+ AND a.opac_visible
+ $$;
+ add_front := $$
+ INSERT INTO asset.opac_visible_copies (copy_id, circ_lib, record)
+ SELECT id, circ_lib, record FROM (
+ $$;
+ add_back := $$
+ ) AS x
+ $$;
+
+ remove_query := $$ DELETE FROM asset.opac_visible_copies WHERE copy_id IN ( SELECT id FROM asset.copy WHERE $$;
+
+ IF TG_TABLE_NAME = 'peer_bib_copy_map' THEN
+ IF TG_OP = 'INSERT' THEN
+ add_peer_query := add_peer_query || ' AND cp.id = ' || NEW.target_copy || ' AND pbcm.record = ' || NEW.peer_record;
+ EXECUTE add_front || add_peer_query || add_back;
+ RETURN NEW;
+ ELSE
+ remove_query := 'DELETE FROM asset.opac_visible_copies WHERE copy_id = ' || OLD.target_copy || ' AND record = ' || OLD.peer_record || ';';
+ EXECUTE remove_query;
+ RETURN OLD;
+ END IF;
+ END IF;
+
+ IF TG_OP = 'INSERT' THEN
+
+ IF TG_TABLE_NAME IN ('copy', 'unit') THEN
+ add_base_query := add_base_query || ' AND cp.id = ' || NEW.id;
+ EXECUTE add_front || add_basequery || add_back;
+ END IF;
+
+ RETURN NEW;
+
+ END IF;
+
+ -- handle items first, since with circulation activity
+ -- their statuses change frequently
+ IF TG_TABLE_NAME IN ('copy', 'unit') THEN
+
+ IF OLD.location <> NEW.location OR
+ OLD.call_number <> NEW.call_number OR
+ OLD.status <> NEW.status OR
+ OLD.circ_lib <> NEW.circ_lib THEN
+ -- any of these could change visibility, but
+ -- we'll save some queries and not try to calculate
+ -- the change directly
+ do_remove := true;
+ do_add := true;
+ ELSE
+
+ IF OLD.deleted <> NEW.deleted THEN
+ IF NEW.deleted THEN
+ do_remove := true;
+ ELSE
+ do_add := true;
+ END IF;
+ END IF;
+
+ IF OLD.opac_visible <> NEW.opac_visible THEN
+ IF OLD.opac_visible THEN
+ do_remove := true;
+ ELSIF NOT do_remove THEN -- handle edge case where deleted item
+ -- is also marked opac_visible
+ do_add := true;
+ END IF;
+ END IF;
+
+ END IF;
+
+ IF do_remove THEN
+ DELETE FROM asset.opac_visible_copies WHERE copy_id = NEW.id;
+ END IF;
+ IF do_add THEN
+ add_base_query := add_base_query || ' AND cp.id = ' || NEW.id;
+ add_peer_query := add_peer_query || ' AND cp.id = ' || NEW.id;
+ EXECUTE add_front || add_base_query || ' UNION ' || add_peer_query || add_back;
+ END IF;
+
+ RETURN NEW;
+
+ END IF;
+
+ IF TG_TABLE_NAME IN ('call_number', 'record_entry') THEN -- these have a 'deleted' column
+
+ IF OLD.deleted AND NEW.deleted THEN -- do nothing
+
+ RETURN NEW;
+
+ ELSIF NEW.deleted THEN -- remove rows
+
+ IF TG_TABLE_NAME = 'call_number' THEN
+ DELETE FROM asset.opac_visible_copies WHERE copy_id IN (SELECT id FROM asset.copy WHERE call_number = NEW.id);
+ ELSIF TG_TABLE_NAME = 'record_entry' THEN
+ DELETE FROM asset.opac_visible_copies WHERE record = NEW.id;
+ END IF;
+
+ RETURN NEW;
+
+ ELSIF OLD.deleted THEN -- add rows
+
+ IF TG_TABLE_NAME = 'call_number' THEN
+ add_base_query := add_base_query || ' AND cn.id = ' || NEW.id;
+ EXECUTE add_front || add_base_query || add_back;
+ ELSIF TG_TABLE_NAME = 'record_entry' THEN
+ add_base_query := add_base_query || ' AND cn.record = ' || NEW.id;
+ add_peer_query := add_peer_query || ' AND pbcm.record = ' || NEW.id;
+ EXECUTE add_front || add_base_query || ' UNION ' || add_peer_query || add_back;
+ END IF;
+
+ RETURN NEW;
+
+ END IF;
+
+ END IF;
+
+ IF TG_TABLE_NAME = 'call_number' THEN
+
+ IF OLD.record <> NEW.record THEN
+ -- call number is linked to different bib
+ remove_query := remove_query || 'call_number = ' || NEW.id || ');';
+ EXECUTE remove_query;
+ add_base_query := add_base_query || ' AND cn.id = ' || NEW.id;
+ EXECUTE add_front || add_base_query || add_back;
+ END IF;
+
+ RETURN NEW;
+
+ END IF;
+
+ IF TG_TABLE_NAME IN ('record_entry') THEN
+ RETURN NEW; -- don't have 'opac_visible'
+ END IF;
+
+ -- actor.org_unit, asset.copy_location, asset.copy_status
+ IF NEW.opac_visible = OLD.opac_visible THEN -- do nothing
+
+ RETURN NEW;
+
+ ELSIF NEW.opac_visible THEN -- add rows
+
+ IF TG_TABLE_NAME = 'org_unit' THEN
+ add_base_query := add_base_query || ' AND cp.circ_lib = ' || NEW.id || ';';
+ add_peer_query := add_peer_query || ' AND cp.circ_lib = ' || NEW.id || ';';
+ ELSIF TG_TABLE_NAME = 'copy_location' THEN
+ add_base_query := add_base_query || ' AND cp.location = ' || NEW.id || ';';
+ add_peer_query := add_peer_query || ' AND cp.location = ' || NEW.id || ';';
+ ELSIF TG_TABLE_NAME = 'copy_status' THEN
+ add_base_query := add_base_query || ' AND cp.status = ' || NEW.id || ';';
+ add_peer_query := add_peer_query || ' AND cp.status = ' || NEW.id || ';';
+ END IF;
+
+ EXECUTE add_front || add_base_query || ' UNION ' || add_peer_query || add_back;
+
+ ELSE -- delete rows
+
+ IF TG_TABLE_NAME = 'org_unit' THEN
+ remove_query := 'DELETE FROM asset.opac_visible_copies WHERE circ_lib = ' || NEW.id || ';';
+ ELSIF TG_TABLE_NAME = 'copy_location' THEN
+ remove_query := remove_query || 'location = ' || NEW.id || ');';
+ ELSIF TG_TABLE_NAME = 'copy_status' THEN
+ remove_query := remove_query || 'status = ' || NEW.id || ');';
+ END IF;
+
+ EXECUTE remove_query;
+
+ END IF;
+
+ RETURN NEW;
+END;
+$func$ LANGUAGE PLPGSQL;
commit cdcbbbbc520e91f003b68d716dcd0d75a2b68971
Author: Thomas Berezansky <tsbere at mvlc.org>
Date: Tue Jun 21 10:24:25 2011 -0400
Attempt to speed up cache visbility trigger
With the old version merges were timing out.
Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql
index fe93778..615de57 100644
--- a/Open-ILS/src/sql/Pg/999.functions.global.sql
+++ b/Open-ILS/src/sql/Pg/999.functions.global.sql
@@ -1149,50 +1149,57 @@ $$;
CREATE OR REPLACE FUNCTION asset.cache_copy_visibility () RETURNS TRIGGER as $func$
DECLARE
- add_query TEXT;
+ add_front TEXT;
+ add_back TEXT;
+ add_base_query TEXT;
+ add_peer_query TEXT;
remove_query TEXT;
do_add BOOLEAN := false;
do_remove BOOLEAN := false;
BEGIN
- add_query := $$
- INSERT INTO asset.opac_visible_copies (copy_id, circ_lib, record)
- SELECT id, circ_lib, record FROM (
- SELECT cp.id, cp.circ_lib, cn.record, cn.id AS call_number, cp.location, cp.status
- FROM asset.copy cp
- JOIN asset.call_number cn ON (cn.id = cp.call_number)
- JOIN actor.org_unit a ON (cp.circ_lib = a.id)
- JOIN asset.copy_location cl ON (cp.location = cl.id)
- JOIN config.copy_status cs ON (cp.status = cs.id)
- JOIN biblio.record_entry b ON (cn.record = b.id)
- WHERE NOT cp.deleted
- AND NOT cn.deleted
- AND NOT b.deleted
- AND cs.opac_visible
- AND cl.opac_visible
- AND cp.opac_visible
- AND a.opac_visible
- UNION
- SELECT cp.id, cp.circ_lib, pbcm.peer_record AS record, NULL AS call_number, cp.location, cp.status
- FROM asset.copy cp
- JOIN biblio.peer_bib_copy_map pbcm ON (pbcm.target_copy = cp.id)
- JOIN actor.org_unit a ON (cp.circ_lib = a.id)
- JOIN asset.copy_location cl ON (cp.location = cl.id)
- JOIN config.copy_status cs ON (cp.status = cs.id)
- WHERE NOT cp.deleted
- AND cs.opac_visible
- AND cl.opac_visible
- AND cp.opac_visible
- AND a.opac_visible
- ) AS x
-
+ add_base_query := $$
+ SELECT cp.id, cp.circ_lib, cn.record, cn.id AS call_number, cp.location, cp.status
+ FROM asset.copy cp
+ JOIN asset.call_number cn ON (cn.id = cp.call_number)
+ JOIN actor.org_unit a ON (cp.circ_lib = a.id)
+ JOIN asset.copy_location cl ON (cp.location = cl.id)
+ JOIN config.copy_status cs ON (cp.status = cs.id)
+ JOIN biblio.record_entry b ON (cn.record = b.id)
+ WHERE NOT cp.deleted
+ AND NOT cn.deleted
+ AND NOT b.deleted
+ AND cs.opac_visible
+ AND cl.opac_visible
+ AND cp.opac_visible
+ AND a.opac_visible
+ $$;
+ add_peer_query := $$
+ SELECT cp.id, cp.circ_lib, pbcm.peer_record AS record, NULL AS call_number, cp.location, cp.status
+ FROM asset.copy cp
+ JOIN biblio.peer_bib_copy_map pbcm ON (pbcm.target_copy = cp.id)
+ JOIN actor.org_unit a ON (cp.circ_lib = a.id)
+ JOIN asset.copy_location cl ON (cp.location = cl.id)
+ JOIN config.copy_status cs ON (cp.status = cs.id)
+ WHERE NOT cp.deleted
+ AND cs.opac_visible
+ AND cl.opac_visible
+ AND cp.opac_visible
+ AND a.opac_visible
+ $$;
+ add_front := $$
+ INSERT INTO asset.opac_visible_copies (copy_id, circ_lib, record)
+ SELECT id, circ_lib, record FROM (
+ $$;
+ add_back := $$
+ ) AS x
$$;
remove_query := $$ DELETE FROM asset.opac_visible_copies WHERE copy_id IN ( SELECT id FROM asset.copy WHERE $$;
IF TG_TABLE_NAME = 'peer_bib_copy_map' THEN
IF TG_OP = 'INSERT' THEN
- add_query := add_query || 'WHERE x.id = ' || NEW.target_copy || ' AND x.record = ' || NEW.peer_record || ';';
- EXECUTE add_query;
+ add_peer_query := add_peer_query || ' AND cp.id = ' || NEW.target_copy || ' AND pbcm.record = ' || NEW.peer_record;
+ EXECUTE add_front || add_peer_query || add_back;
RETURN NEW;
ELSE
remove_query := 'DELETE FROM asset.opac_visible_copies WHERE copy_id = ' || OLD.target_copy || ' AND record = ' || OLD.peer_record || ';';
@@ -1204,8 +1211,8 @@ BEGIN
IF TG_OP = 'INSERT' THEN
IF TG_TABLE_NAME IN ('copy', 'unit') THEN
- add_query := add_query || 'WHERE x.id = ' || NEW.id || ';';
- EXECUTE add_query;
+ add_base_query := add_base_query || ' AND cp.id = ' || NEW.id;
+ EXECUTE add_front || add_basequery || add_back;
END IF;
RETURN NEW;
@@ -1250,8 +1257,9 @@ BEGIN
DELETE FROM asset.opac_visible_copies WHERE copy_id = NEW.id;
END IF;
IF do_add THEN
- add_query := add_query || 'WHERE x.id = ' || NEW.id || ';';
- EXECUTE add_query;
+ add_base_query := add_base_query || ' AND cp.id = ' || NEW.id;
+ add_peer_query := add_peer_query || ' AND cp.id = ' || NEW.id;
+ EXECUTE add_front || add_base_query || ' UNION ' || add_peer_query || add_back;
END IF;
RETURN NEW;
@@ -1276,15 +1284,15 @@ BEGIN
ELSIF OLD.deleted THEN -- add rows
- IF TG_TABLE_NAME IN ('copy','unit') THEN
- add_query := add_query || 'WHERE x.id = ' || NEW.id || ';';
- ELSIF TG_TABLE_NAME = 'call_number' THEN
- add_query := add_query || 'WHERE x.call_number = ' || NEW.id || ';';
+ IF TG_TABLE_NAME = 'call_number' THEN
+ add_base_query := add_base_query || ' AND cn.id = ' || NEW.id;
+ EXECUTE add_front || add_base_query || add_back;
ELSIF TG_TABLE_NAME = 'record_entry' THEN
- add_query := add_query || 'WHERE x.record = ' || NEW.id || ';';
+ add_base_query := add_base_query || ' AND cn.record = ' || NEW.id;
+ add_peer_query := add_peer_query || ' AND pbcm.record = ' || NEW.id;
+ EXECUTE add_front || add_base_query || ' UNION ' || add_peer_query || add_back;
END IF;
- EXECUTE add_query;
RETURN NEW;
END IF;
@@ -1297,8 +1305,8 @@ BEGIN
-- call number is linked to different bib
remove_query := remove_query || 'call_number = ' || NEW.id || ');';
EXECUTE remove_query;
- add_query := add_query || 'WHERE x.call_number = ' || NEW.id || ';';
- EXECUTE add_query;
+ add_base_query := add_base_query || ' AND cn.id = ' || NEW.id;
+ EXECUTE add_front || add_base_query || add_back;
END IF;
RETURN NEW;
@@ -1317,14 +1325,17 @@ BEGIN
ELSIF NEW.opac_visible THEN -- add rows
IF TG_TABLE_NAME = 'org_unit' THEN
- add_query := add_query || 'WHERE x.circ_lib = ' || NEW.id || ';';
+ add_base_query := add_base_query || ' AND cp.circ_lib = ' || NEW.id || ';';
+ add_peer_query := add_peer_query || ' AND cp.circ_lib = ' || NEW.id || ';';
ELSIF TG_TABLE_NAME = 'copy_location' THEN
- add_query := add_query || 'WHERE x.location = ' || NEW.id || ';';
+ add_base_query := add_base_query || ' AND cp.location = ' || NEW.id || ';';
+ add_peer_query := add_peer_query || ' AND cp.location = ' || NEW.id || ';';
ELSIF TG_TABLE_NAME = 'copy_status' THEN
- add_query := add_query || 'WHERE x.status = ' || NEW.id || ';';
+ add_base_query := add_base_query || ' AND cp.status = ' || NEW.id || ';';
+ add_peer_query := add_peer_query || ' AND cp.status = ' || NEW.id || ';';
END IF;
- EXECUTE add_query;
+ EXECUTE add_front || add_base_query || ' UNION ' || add_peer_query || add_back;
ELSE -- delete rows
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/999.functions.global.sql | 111 ++++++++++--------
...> 0568.schema.cache_visibility_speed_boost.sql} | 122 +++++++++++---------
3 files changed, 127 insertions(+), 108 deletions(-)
copy Open-ILS/src/sql/Pg/upgrade/{0560.fix_opac_copy_vis_cache.sql => 0568.schema.cache_visibility_speed_boost.sql} (54%)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list