Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- bib search: #CD_documentLength #CD_meanHarmonic #CD_uniqueWords #staff core_limit(100000) badge_orgs(1) estimation_strategy(inclusion) skip_check(0) check_limit(1000) (keyword:Harry potter chamber of secrets) site(PINES)
- explain analyze
- WITH w AS (
- WITH x559f99d69060_keyword_xq AS (SELECT
- (to_tsquery('simple', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$Harry$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')) || to_tsquery('english_nostop', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$Harry$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')))&&
- (to_tsquery('simple', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$potter$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')) || to_tsquery('english_nostop', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$potter$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')))&&
- (to_tsquery('english_nostop', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$chamber$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')) || to_tsquery('simple', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$chamber$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')))&&
- (to_tsquery('english_nostop', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$of$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')) || to_tsquery('simple', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$of$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')))&&
- (to_tsquery('simple', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$secrets$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')) || to_tsquery('english_nostop', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$secrets$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), ''))) AS tsq,
- (to_tsquery('simple', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$Harry$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')) || to_tsquery('english_nostop', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$Harry$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), ''))) ||
- (to_tsquery('simple', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$potter$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')) || to_tsquery('english_nostop', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$potter$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), ''))) ||
- (to_tsquery('english_nostop', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$chamber$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')) || to_tsquery('simple', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$chamber$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), ''))) ||
- (to_tsquery('english_nostop', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$of$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')) || to_tsquery('simple', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$of$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), ''))) ||
- (to_tsquery('simple', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$secrets$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), '')) || to_tsquery('english_nostop', COALESCE(NULLIF( '(' || btrim(regexp_replace(split_date_range(search_normalize($_2623591$secrets$_2623591$)),E'(?:\\s+|:)','&','g'),'&|') || ')', '()'), ''))) AS tsq_rank ),lang_with AS (SELECT id FROM config.coded_value_map WHERE ctype = 'item_lang' AND code = $_2623591$eng$_2623591$), pop_with AS (
- SELECT record,
- ARRAY_AGG(badge) AS badges,
- SUM(s.score::NUMERIC*b.weight::NUMERIC)/SUM(b.weight::NUMERIC) AS total_score
- FROM rating.record_badge_score s
- JOIN rating.badge b ON (
- b.id = s.badge
- AND b.scope = ANY ('{1}')) GROUP BY 1)
- ,c_attr AS (SELECT
- (ARRAY_TO_STRING(ARRAY[search.calculate_visibility_attribute_test('circ_lib','{1,252,221,365,87,321,163,140,152,376,131,106,102,328,46,119,353,145,211,65,21,156,226,203,115,301,182,2,233,68,260,85,96,362,80,231,346,275,197,58,292,184,122,6,344,31,55,216,177,311,124,267,213,33,25,39,209,409,259,234,258,126,117,103,360,191,82,142,3,17,408,246,194,77,248,79,247,356,107,263,411,99,110,15,279,405,166,240,112,288,243,244,242,251,239,241,403,293,345,297,298,86,352,36,372,300,175,227,254,250,331,118,37,262,28,74,355,410,81,84,395,23,11,280,29,62,201,306,59,63,60,135,24,294,193,88,303,94,404,49,111,123,402,26,121,120,137,138,101,155,132,199,144,235,192,374,73,97,9,281,153,90,255,228,5,256,253,284,95,335,57,4,342,52,336,245,148,354,202,407,91,92,93,104,307,308,134,174,109,167,45,18,229,186,343,366,176,147,261,333,116,157,236,210,149,89,208,187,48,161,136,165,206,27,172,158,207,204,212,299,188,309,139,41,180,313,225,108,285,323,322,349,169,183,171,205,56,51,314,78,351,151,43,53,371,317,71,200,282,369,319,230,67,196,113,66,150,286,50,357,223,160,170,72,291,287,350,358,320,290,257,330,98,61,195,305,318,367,141,237,154,304,329,173,100,278,75,401,276,168,114,198,54,266,265,70,295,296,222,190,83,340,22,69,264,146,289,185,380,143,10,133,382,337,249,378,20,8,47,224,379,385,238,381,377,383,384,232,386,373,64,159,398,399,105,7,13,219,220,189,310,30,324,347,76,40,44,38,391,393,396,394,387,179,178,181,19,397,14,12,16,217,218,125,127,128,129,130,269,272,270,32,271,273,268,361,215,214,34,35,162,389,388,390,392,42,316,315,312,326,375,164}',FALSE)],'&'))::query_int AS vis_test FROM asset.patron_default_visibility_mask() x)
- ,b_attr AS (SELECT (search.calculate_visibility_attribute_test('luri_org','{1}',FALSE))::query_int AS vis_test FROM asset.patron_default_visibility_mask() x)
- SELECT id,
- rel,
- CASE WHEN cardinality(records) = 1 THEN records[1] ELSE NULL END AS record,
- NULL::INT AS total,
- NULL::INT AS checked,
- NULL::INT AS visible,
- NULL::INT AS deleted,
- NULL::INT AS excluded,
- badges,
- popularity
- FROM (SELECT m.source AS id,
- ARRAY[m.source] AS records,
- (AVG(
- (COALESCE(ts_rank_cd('{0.1, 0.2, 0.4, 1.0}', x559f99d69060_keyword.index_vector, x559f99d69060_keyword.tsq_rank, 14) * x559f99d69060_keyword.weight * 1000, 0.0))
- )+1 * COALESCE( NULLIF( FIRST(mrv.vlist @> ARRAY[lang_with.id]), FALSE )::INT * 5, 1))::NUMERIC AS rel,
- 1.0/((AVG(
- (COALESCE(ts_rank_cd('{0.1, 0.2, 0.4, 1.0}', x559f99d69060_keyword.index_vector, x559f99d69060_keyword.tsq_rank, 14) * x559f99d69060_keyword.weight * 1000, 0.0))
- )+1 * COALESCE( NULLIF( FIRST(mrv.vlist @> ARRAY[lang_with.id]), FALSE )::INT * 5, 1)))::NUMERIC AS rank,
- FIRST(pubdate_t.value) AS tie_break,
- STRING_AGG(ARRAY_TO_STRING(pop_with.badges,','),',') AS badges,
- AVG(COALESCE(pop_with.total_score::NUMERIC,0.0::NUMERIC))::NUMERIC(2,1) AS popularity
- FROM metabib.metarecord_source_map m
- LEFT JOIN (
- SELECT fe.*, fe_weight.weight, x559f99d69060_keyword_xq.tsq, x559f99d69060_keyword_xq.tsq_rank /* search */
- FROM metabib.keyword_field_entry AS fe
- JOIN config.metabib_field AS fe_weight ON (fe_weight.id = fe.field)
- JOIN x559f99d69060_keyword_xq ON (fe.index_vector @@ x559f99d69060_keyword_xq.tsq)
- UNION ALL
- SELECT fe.id, fe.source, fe.field, fe.value, fe.index_vector, fe_weight.weight, x559f99d69060_keyword_xq.tsq, x559f99d69060_keyword_xq.tsq_rank /* virtual field addition */
- FROM metabib.title_field_entry AS fe
- JOIN config.metabib_field_virtual_map AS fe_weight ON (fe_weight.virtual = 45 AND fe_weight.real IN (6,53) AND fe_weight.real = fe.field)
- JOIN x559f99d69060_keyword_xq ON (fe.index_vector @@ x559f99d69060_keyword_xq.tsq)
- UNION ALL
- SELECT fe.id, fe.source, fe.field, fe.value, fe.index_vector, fe_weight.weight, x559f99d69060_keyword_xq.tsq, x559f99d69060_keyword_xq.tsq_rank /* virtual field addition */
- FROM metabib.keyword_field_entry AS fe
- JOIN config.metabib_field_virtual_map AS fe_weight ON (fe_weight.virtual = 45 AND fe_weight.real IN (39,41,42,46,47,48,50) AND fe_weight.real = fe.field)
- JOIN x559f99d69060_keyword_xq ON (fe.index_vector @@ x559f99d69060_keyword_xq.tsq)
- UNION ALL
- SELECT fe.id, fe.source, fe.field, fe.value, fe.index_vector, fe_weight.weight, x559f99d69060_keyword_xq.tsq, x559f99d69060_keyword_xq.tsq_rank /* virtual field addition */
- FROM metabib.author_field_entry AS fe
- JOIN config.metabib_field_virtual_map AS fe_weight ON (fe_weight.virtual = 45 AND fe_weight.real IN (8) AND fe_weight.real = fe.field)
- JOIN x559f99d69060_keyword_xq ON (fe.index_vector @@ x559f99d69060_keyword_xq.tsq)
- UNION ALL
- SELECT fe.id, fe.source, fe.field, fe.value, fe.index_vector, fe_weight.weight, x559f99d69060_keyword_xq.tsq, x559f99d69060_keyword_xq.tsq_rank /* virtual field addition */
- FROM metabib.subject_field_entry AS fe
- JOIN config.metabib_field_virtual_map AS fe_weight ON (fe_weight.virtual = 45 AND fe_weight.real IN (16) AND fe_weight.real = fe.field)
- JOIN x559f99d69060_keyword_xq ON (fe.index_vector @@ x559f99d69060_keyword_xq.tsq)
- ) AS x559f99d69060_keyword ON (m.source = x559f99d69060_keyword.source)
- INNER JOIN metabib.record_attr_vector_list mrv ON m.source = mrv.source
- INNER JOIN biblio.record_entry bre ON m.source = bre.id AND NOT bre.deleted
- LEFT JOIN pop_with ON ( m.source = pop_with.record )
- LEFT JOIN metabib.record_sorter pubdate_t ON m.source = pubdate_t.source AND attr = 'pubdate'
- ,lang_with
- ,c_attr
- ,b_attr
- WHERE 1=1
- AND (
- (
- (x559f99d69060_keyword.id IS NOT NULL)
- )
- )
- AND (
- ((EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source AND vis_attr_vector @@ c_attr.vis_test) OR (NOT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source) AND (bre.vis_attr_vector IS NULL OR NOT ( int4range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) ))))) OR ((b_attr.vis_test IS NULL OR bre.vis_attr_vector @@ b_attr.vis_test))
- )
- GROUP BY 1
- ORDER BY 4 ASC NULLS LAST, 5 DESC NULLS LAST, 3 DESC
- LIMIT 100000
- ) AS core_query
- ) (SELECT * FROM w LIMIT 1000 OFFSET 0)
- UNION ALL
- SELECT NULL,NULL,NULL,COUNT(*),COUNT(*),COUNT(*),0,0,NULL,NULL FROM w;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement