JBAS-1932 New headings mattype sql speed improvements
authorBill Erickson <berickxx@gmail.com>
Thu, 28 Dec 2017 16:51:29 +0000 (11:51 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Join the mattype data via a more direct path instead of the nested
views.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/new-headings-mattype.sql

index f073b05..3ebc0db 100644 (file)
@@ -11,7 +11,7 @@ SELECT entry.*,
     usr.usrname AS bib_editor_usrname,
     evergreen.marc_tag_to_string('1', bre.marc) AS bib_marc_1xx,
     evergreen.marc_tag_to_string('245', bre.marc) AS bib_marc_245,
-    rec_attr.attrs -> 'mattype' AS mattype,
+    ccvm.code AS mattype,
     (reporter.metabib_browse_entry_window_prev(
         entry.browse_axis, entry.entry_sort_value)).*,
     (reporter.metabib_browse_entry_window_next(
@@ -19,7 +19,9 @@ SELECT entry.*,
 FROM reporter.cataloged_browse_entry_combined entry
     JOIN config.metabib_field cmf ON (cmf.id = entry.field_def)
     JOIN biblio.record_entry bre ON (bre.id = entry.bib_record)
-    JOIN metabib.record_attr rec_attr ON (rec_attr.id = bre.id)
+    JOIN metabib.record_attr_vector_list vec ON (vec.source = bre.id)
+    JOIN config.coded_value_map ccvm
+        ON (ccvm.ctype = 'mattype' AND ccvm.id = ANY (vec.vlist))
     JOIN actor.usr usr ON (usr.id = bre.editor)
 ORDER BY 
     CASE entry.browse_axis