[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch master updated. c0a4f5614dd47b4b20329837f2caf7a853054cfa
Evergreen Git
git at git.evergreen-ils.org
Thu Oct 9 12:01:03 EDT 2014
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 c0a4f5614dd47b4b20329837f2caf7a853054cfa (commit)
via 04d618aa860afbcd90d8dcfb57c7f26cb433bb2e (commit)
via 82749860db5cf3b53b4cd5be3395b06ea284efae (commit)
from e57d480a0b47d4e5ab1f060cf772568341877b75 (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 c0a4f5614dd47b4b20329837f2caf7a853054cfa
Author: Ben Shum <bshum at biblio.org>
Date: Thu Oct 9 11:59:17 2014 -0400
LP#1374091: stamping upgrade script for speedier record_attr views
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 be088c2..cf2baed 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 ('0891', :eg_version); -- csharp/paxed/bshum
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0892', :eg_version); -- miker/bshum
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.record_attr_flat_speedup.sql b/Open-ILS/src/sql/Pg/upgrade/0892.schema.record_attr_flat_speedup.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.record_attr_flat_speedup.sql
rename to Open-ILS/src/sql/Pg/upgrade/0892.schema.record_attr_flat_speedup.sql
index f1c526a..71ae4e8 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.record_attr_flat_speedup.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0892.schema.record_attr_flat_speedup.sql
@@ -1,6 +1,6 @@
BEGIN;
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0892', :eg_version);
CREATE OR REPLACE VIEW metabib.record_attr_flat AS
SELECT v.source AS id,
commit 04d618aa860afbcd90d8dcfb57c7f26cb433bb2e
Author: Mike Rylander <mrylander at gmail.com>
Date: Mon Sep 29 12:40:32 2014 -0400
LP#1374091: Speed up metarecord version of unAPI mra call
The change to metabib.record_attr_flat in the previous commit caused
a regression in the plan used in unapi.mmr_mra. This commit addresses
that by unrolling the mra view when used in context with metarecords,
which are shaped differently and require slightly different access
patterns.
Signed-off-by: Mike Rylander <mrylander at gmail.com>
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/sql/Pg/990.schema.unapi.sql b/Open-ILS/src/sql/Pg/990.schema.unapi.sql
index 92e7fc8..47b40e3 100644
--- a/Open-ILS/src/sql/Pg/990.schema.unapi.sql
+++ b/Open-ILS/src/sql/Pg/990.schema.unapi.sql
@@ -1283,41 +1283,70 @@ CREATE OR REPLACE FUNCTION unapi.mmr_mra (
),
(SELECT XMLAGG(foo.y)
FROM (
- SELECT DISTINCT ON (COALESCE(cvm.id,uvm.id))
- COALESCE(cvm.id,uvm.id),
+ WITH sourcelist AS (
+ WITH aou AS (SELECT COALESCE(id, (evergreen.org_top()).id) AS id
+ FROM actor.org_unit WHERE shortname = $5 LIMIT 1)
+ SELECT source
+ FROM metabib.metarecord_source_map, aou
+ WHERE metarecord = $1 AND (
+ EXISTS (
+ SELECT 1 FROM asset.opac_visible_copies
+ WHERE record = source AND circ_lib IN (
+ SELECT id FROM actor.org_unit_descendants(aou.id, $6))
+ LIMIT 1
+ )
+ OR EXISTS (SELECT 1 FROM located_uris(source, aou.id, $10) LIMIT 1)
+ )
+ )
+ SELECT cmra.aid,
XMLELEMENT(
name field,
XMLATTRIBUTES(
- mra.attr AS name,
- cvm.value AS "coded-value",
- cvm.id AS "cvmid",
+ cmra.attr AS name,
+ cmra.value AS "coded-value",
+ cmra.aid AS "cvmid",
rad.composite,
rad.multi,
rad.filter,
rad.sorter
),
- mra.value
+ cmra.value
)
- FROM metabib.record_attr_flat mra
- JOIN config.record_attr_definition rad ON (mra.attr = rad.name)
- LEFT JOIN config.coded_value_map cvm ON (cvm.ctype = mra.attr AND code = mra.value)
- LEFT JOIN metabib.uncontrolled_record_attr_value uvm ON (uvm.attr = mra.attr AND uvm.value = mra.value)
- WHERE mra.id IN (
- WITH aou AS (SELECT COALESCE(id, (evergreen.org_top()).id) AS id
- FROM actor.org_unit WHERE shortname = $5 LIMIT 1)
- SELECT source
- FROM metabib.metarecord_source_map, aou
- WHERE metarecord = $1 AND (
- EXISTS (
- SELECT 1 FROM asset.opac_visible_copies
- WHERE record = source AND circ_lib IN (
- SELECT id FROM actor.org_unit_descendants(aou.id, $6))
- LIMIT 1
- )
- OR EXISTS (SELECT 1 FROM located_uris(source, aou.id, $10) LIMIT 1)
+ FROM (
+ SELECT v.source AS id,
+ c.id AS aid,
+ c.ctype AS attr,
+ c.code AS value
+ FROM metabib.record_attr_vector_list v
+ JOIN config.coded_value_map c ON ( c.id = ANY( v.vlist ) )
+ ) AS cmra
+ JOIN config.record_attr_definition rad ON (cmra.attr = rad.name)
+ JOIN sourcelist ON (cmra.id = sourcelist.source)
+ UNION ALL
+ SELECT umra.aid,
+ XMLELEMENT(
+ name field,
+ XMLATTRIBUTES(
+ umra.attr AS name,
+ rad.composite,
+ rad.multi,
+ rad.filter,
+ rad.sorter
+ ),
+ umra.value
)
- )
- ORDER BY 1
+ FROM (
+ SELECT v.source AS id,
+ m.id AS aid,
+ m.attr AS attr,
+ m.value AS value
+ FROM metabib.record_attr_vector_list v
+ JOIN metabib.uncontrolled_record_attr_value m ON ( m.id = ANY( v.vlist ) )
+ ) AS umra
+ JOIN config.record_attr_definition rad ON (umra.attr = rad.name)
+ JOIN sourcelist ON (umra.id = sourcelist.source)
+ ORDER BY 1
+
)foo(id,y)
)
)
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.record_attr_flat_speedup.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.record_attr_flat_speedup.sql
index e87b006..f1c526a 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.record_attr_flat_speedup.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.record_attr_flat_speedup.sql
@@ -15,5 +15,94 @@ CREATE OR REPLACE VIEW metabib.record_attr_flat AS
FROM metabib.record_attr_vector_list v
LEFT JOIN config.coded_value_map c ON ( c.id = ANY( v.vlist ) );
+CREATE OR REPLACE FUNCTION unapi.mmr_mra (
+ obj_id BIGINT,
+ format TEXT,
+ ename TEXT,
+ includes TEXT[],
+ org TEXT,
+ depth INT DEFAULT NULL,
+ slimit HSTORE DEFAULT NULL,
+ soffset HSTORE DEFAULT NULL,
+ include_xmlns BOOL DEFAULT TRUE,
+ pref_lib INT DEFAULT NULL
+) RETURNS XML AS $F$
+ SELECT XMLELEMENT(
+ name attributes,
+ XMLATTRIBUTES(
+ CASE WHEN $9 THEN 'http://open-ils.org/spec/indexing/v1' ELSE NULL END AS xmlns,
+ 'tag:open-ils.org:U2 at mmr/' || $1 AS metarecord
+ ),
+ (SELECT XMLAGG(foo.y)
+ FROM (
+ WITH sourcelist AS (
+ WITH aou AS (SELECT COALESCE(id, (evergreen.org_top()).id) AS id
+ FROM actor.org_unit WHERE shortname = $5 LIMIT 1)
+ SELECT source
+ FROM metabib.metarecord_source_map, aou
+ WHERE metarecord = $1 AND (
+ EXISTS (
+ SELECT 1 FROM asset.opac_visible_copies
+ WHERE record = source AND circ_lib IN (
+ SELECT id FROM actor.org_unit_descendants(aou.id, $6))
+ LIMIT 1
+ )
+ OR EXISTS (SELECT 1 FROM located_uris(source, aou.id, $10) LIMIT 1)
+ )
+ )
+ SELECT cmra.aid,
+ XMLELEMENT(
+ name field,
+ XMLATTRIBUTES(
+ cmra.attr AS name,
+ cmra.value AS "coded-value",
+ cmra.aid AS "cvmid",
+ rad.composite,
+ rad.multi,
+ rad.filter,
+ rad.sorter
+ ),
+ cmra.value
+ )
+ FROM (
+ SELECT v.source AS id,
+ c.id AS aid,
+ c.ctype AS attr,
+ c.code AS value
+ FROM metabib.record_attr_vector_list v
+ JOIN config.coded_value_map c ON ( c.id = ANY( v.vlist ) )
+ ) AS cmra
+ JOIN config.record_attr_definition rad ON (cmra.attr = rad.name)
+ JOIN sourcelist ON (cmra.id = sourcelist.source)
+ UNION ALL
+ SELECT umra.aid,
+ XMLELEMENT(
+ name field,
+ XMLATTRIBUTES(
+ umra.attr AS name,
+ rad.composite,
+ rad.multi,
+ rad.filter,
+ rad.sorter
+ ),
+ umra.value
+ )
+ FROM (
+ SELECT v.source AS id,
+ m.id AS aid,
+ m.attr AS attr,
+ m.value AS value
+ FROM metabib.record_attr_vector_list v
+ JOIN metabib.uncontrolled_record_attr_value m ON ( m.id = ANY( v.vlist ) )
+ ) AS umra
+ JOIN config.record_attr_definition rad ON (umra.attr = rad.name)
+ JOIN sourcelist ON (umra.id = sourcelist.source)
+ ORDER BY 1
+
+ )foo(id,y)
+ )
+ )
+$F$ LANGUAGE SQL STABLE;
+
COMMIT;
commit 82749860db5cf3b53b4cd5be3395b06ea284efae
Author: Mike Rylander <miker at esilibrary.com>
Date: Thu Sep 25 14:34:20 2014 -0400
LP#1374091: Redefine view to help PG make better plans
The metabib.record_attr_flat view previously pulled its data
through several other intermediate views. While this improves
maintenance overhead, it ends up being an optimization fence
for certain data sets. So, we pull the logic from the leaf
views up into the main view. And, poof, 2 orders of magnitude
speedup on large data sets.
Signed-off-by: Mike Rylander <miker at esilibrary.com>
Signed-off-by: Ben Shum <bshum at biblio.org>
diff --git a/Open-ILS/src/sql/Pg/030.schema.metabib.sql b/Open-ILS/src/sql/Pg/030.schema.metabib.sql
index fa2710d..c03868e 100644
--- a/Open-ILS/src/sql/Pg/030.schema.metabib.sql
+++ b/Open-ILS/src/sql/Pg/030.schema.metabib.sql
@@ -409,10 +409,16 @@ CREATE TYPE metabib.record_attr_type AS (
-- Back-compat view ... we're moving to an INTARRAY world
CREATE VIEW metabib.record_attr_flat AS
SELECT v.source AS id,
- m.attr,
- m.value
- FROM metabib.full_attr_id_map m
- JOIN metabib.record_attr_vector_list v ON ( m.id = ANY( v.vlist ) );
+ m.attr AS attr,
+ m.value AS value
+ FROM metabib.record_attr_vector_list v
+ LEFT JOIN metabib.uncontrolled_record_attr_value m ON ( m.id = ANY( v.vlist ) )
+ UNION
+ SELECT v.source AS id,
+ c.ctype AS attr,
+ c.code AS value
+ FROM metabib.record_attr_vector_list v
+ LEFT JOIN config.coded_value_map c ON ( c.id = ANY( v.vlist ) );
CREATE VIEW metabib.record_attr AS
SELECT id, HSTORE( ARRAY_AGG( attr ), ARRAY_AGG( value ) ) AS attrs FROM metabib.record_attr_flat GROUP BY 1;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.record_attr_flat_speedup.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.record_attr_flat_speedup.sql
new file mode 100644
index 0000000..e87b006
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.record_attr_flat_speedup.sql
@@ -0,0 +1,19 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE VIEW metabib.record_attr_flat AS
+ SELECT v.source AS id,
+ m.attr AS attr,
+ m.value AS value
+ FROM metabib.record_attr_vector_list v
+ LEFT JOIN metabib.uncontrolled_record_attr_value m ON ( m.id = ANY( v.vlist ) )
+ UNION
+ SELECT v.source AS id,
+ c.ctype AS attr,
+ c.code AS value
+ FROM metabib.record_attr_vector_list v
+ LEFT JOIN config.coded_value_map c ON ( c.id = ANY( v.vlist ) );
+
+COMMIT;
+
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/030.schema.metabib.sql | 14 ++-
Open-ILS/src/sql/Pg/990.schema.unapi.sql | 79 ++++++++++-----
.../0892.schema.record_attr_flat_speedup.sql | 108 ++++++++++++++++++++
4 files changed, 173 insertions(+), 30 deletions(-)
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0892.schema.record_attr_flat_speedup.sql
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list