Searching by shelving location issues a monster query that often times out
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Evergreen |
New
|
Undecided
|
Unassigned |
Bug Description
For many of our shelving locations, if I try to limit my OPAC search results to a particular shelving location, Evergreen produces an SQL query that takes an incredible amount of time. The query continues to run after the Apache time out so the search returns no results to the user. The query continues for around to 30 seconds after Evergreen returns that blank results page.
Here is what the query looks like for our shelving location #436:
SELECT *
-- bib search: #CD_documentLength #CD_meanHarmonic #CD_uniqueWords skip_check(8000) core_limit(10000) limit(1000) estimation_
FROM search.
WITH lang_with AS (SELECT id FROM config.
SELECT m.source AS id,
1.0/((AVG(
(1)
)+1 * COALESCE( NULLIF( FIRST(mrv.vlist @> ARRAY[lang_
1.0/((AVG(
(1)
)+1 * COALESCE( NULLIF( FIRST(mrv.vlist @> ARRAY[lang_
FROM metabib.
LEFT JOIN metabib.
INNER JOIN metabib.
,lang_with
WHERE 1=1
AND (
TRUE
)
GROUP BY 1
ORDER BY 4 ASC NULLS LAST, 5 DESC NULLS LAST, 3 DESC
LIMIT 10000
$core_query_
);
Thanks very much to Rogan Hamby for putting together the detailed information in this bug report.
The query shows that no search terms were entered, just filters. We try to prevent that in the UI, so I wonder if that was intended?