From: Lebbeous Fogle-Weekley Date: Wed, 25 Jan 2012 21:11:57 +0000 (-0500) Subject: Per miker, saving the call to TS_HEADLINE for an outer select, after... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4719ce410043475de205d435542a53f23895cd54;p=evergreen%2Fequinox.git Per miker, saving the call to TS_HEADLINE for an outer select, after... ... we've done our core search and limited to a low number of results, should be much faster (with big data sets anyway). Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/src/sql/Pg/030.schema.metabib.sql b/Open-ILS/src/sql/Pg/030.schema.metabib.sql index 331e0c5f88..4cc72c0266 100644 --- a/Open-ILS/src/sql/Pg/030.schema.metabib.sql +++ b/Open-ILS/src/sql/Pg/030.schema.metabib.sql @@ -1307,13 +1307,13 @@ CREATE OR REPLACE normalization INTEGER -- argument to TS_RANK_CD() ) RETURNS TABLE ( value TEXT, -- plain - match TEXT, -- marked up field INTEGER, bouyant_and_class_match BOOL, field_match BOOL, field_weight INTEGER, rank REAL, - bouyant BOOL + bouyant BOOL, + match TEXT -- marked up ) AS $func$ DECLARE query TSQUERY; @@ -1374,9 +1374,8 @@ BEGIN '; END IF; - RETURN QUERY EXECUTE 'SELECT DISTINCT + RETURN QUERY EXECUTE 'SELECT *, TS_HEADLINE(value, $1, $3) FROM (SELECT DISTINCT mbe.value, - TS_HEADLINE(mbe.value, $1, $3), cmf.id, cmc.bouyant AND _registered.field_class IS NOT NULL, _registered.field = cmf.id, @@ -1389,8 +1388,10 @@ BEGIN JOIN config.metabib_class cmc ON (cmf.field_class = cmc.name) ' || search_class_join || opac_visibility_join || ' WHERE $1 @@ mbe.index_vector - ORDER BY 4 DESC, 5 DESC NULLS LAST, 6 DESC, 7 DESC, 8 DESC, 1 ASC - LIMIT $5' + ORDER BY 3 DESC, 4 DESC NULLS LAST, 5 DESC, 6 DESC, 7 DESC, 1 ASC + LIMIT $5) x + ORDER BY 3 DESC, 4 DESC NULLS LAST, 5 DESC, 6 DESC, 7 DESC, 1 ASC + ' -- sic, repeat the order by clause in the outer select too USING query, search_class, headline_opts, visibility_org, query_limit, normalization diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bib_autosuggest.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bib_autosuggest.sql index 9f8c6638fa..5099f1d7cf 100644 --- a/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bib_autosuggest.sql +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bib_autosuggest.sql @@ -528,13 +528,13 @@ CREATE OR REPLACE normalization INTEGER -- argument to TS_RANK_CD() ) RETURNS TABLE ( value TEXT, -- plain - match TEXT, -- marked up field INTEGER, bouyant_and_class_match BOOL, field_match BOOL, field_weight INTEGER, rank REAL, - bouyant BOOL + bouyant BOOL, + match TEXT -- marked up ) AS $func$ DECLARE query TSQUERY; @@ -595,9 +595,8 @@ BEGIN '; END IF; - RETURN QUERY EXECUTE 'SELECT DISTINCT + RETURN QUERY EXECUTE 'SELECT *, TS_HEADLINE(value, $1, $3) FROM (SELECT DISTINCT mbe.value, - TS_HEADLINE(mbe.value, $1, $3), cmf.id, cmc.bouyant AND _registered.field_class IS NOT NULL, _registered.field = cmf.id, @@ -610,8 +609,10 @@ BEGIN JOIN config.metabib_class cmc ON (cmf.field_class = cmc.name) ' || search_class_join || opac_visibility_join || ' WHERE $1 @@ mbe.index_vector - ORDER BY 4 DESC, 5 DESC NULLS LAST, 6 DESC, 7 DESC, 8 DESC, 1 ASC - LIMIT $5' + ORDER BY 3 DESC, 4 DESC NULLS LAST, 5 DESC, 6 DESC, 7 DESC, 1 ASC + LIMIT $5) x + ORDER BY 3 DESC, 4 DESC NULLS LAST, 5 DESC, 6 DESC, 7 DESC, 1 ASC + ' -- sic, repeat the order by clause in the outer select too USING query, search_class, headline_opts, visibility_org, query_limit, normalization