Reduce index bloat involving non-search_field values
authorBob Wicksall <bwicksall@pls-net.org>
Thu, 13 Jun 2013 05:06:10 +0000 (01:06 -0400)
committerDan Scott <dscott@laurentian.ca>
Thu, 27 Jun 2013 03:43:57 +0000 (23:43 -0400)
Rows in metabib.title_field_entry, subject_field_entry,
series_field_entry, and author_field_entry are doubled or tripled due to
bad logic in biblio.extract_metabib_field_entry. This results in these
tables being 2 or more times their correct size.

This was introduced in 2.2.0 when the logic for browse_field and
facet_field were added to biblio.extract_metabib_field_entry. 2.1 is not
affected.

The duplicates are caused when biblio.extract_metabib_field_entry
returns TRUE in the search_field column for all rows even if they should
just be facet_field or browse_field after the first search_field value
is returned.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/030.schema.metabib.sql

index e14c239..a047e1e 100644 (file)
@@ -411,6 +411,11 @@ DECLARE
     output_row  metabib.field_entry_template%ROWTYPE;
 BEGIN
 
+    -- Start out with no field-use bools set
+    output_row.browse_field = FALSE;
+    output_row.facet_field = FALSE;
+    output_row.search_field = FALSE;
+
     -- Get the record
     SELECT INTO bib * FROM biblio.record_entry WHERE id = rid;
 
@@ -513,6 +518,7 @@ BEGIN
 
             output_row.search_field = TRUE;
             RETURN NEXT output_row;
+            output_row.search_field = FALSE;
         END IF;
 
     END LOOP;