Browse search functions need to be 'stable'
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Evergreen |
Fix Released
|
Critical
|
Unassigned |
Bug Description
Finally got a chance to test 2.5 browse on our full production database. Unfortunately, performance was unusably poor (I stopped the browse query after 32 minutes).
After some troubleshooting, it seems we need a couple helper functions to be set as STABLE (original suggestion was IMMUTABLE, but that was pointed out to be incorrect by Dan S.):
metabib.
metabib.
After doing this, I got what appeared to be correct results in a couple seconds. This change makes sense to me, but since this is nothing I am expert in, I wanted to post this for general feedback before offering a branch of any kind. You can update these functions in an existing DB like so:
ALTER FUNCTION metabib.
ALTER FUNCTION metabib.
tags: | added: pullrequest |
Changed in evergreen: | |
status: | Fix Committed → Fix Released |
Unfortunately I don't think these functions are, strictly speaking, mutable.
The first argument to metabib. browse_ bib_pivot, integer[], refers to the metabib. browse_ entry_def_ map IDs. Given that the corresponding entry in metabib. browse_ entry_def_ map could change between calls, it is not mutable. Those entries may not be likely to change - but if they do, it would require a restart of PostgreSQL to get the change recognized if the functions are marked IMMUTABLE.
I believe metabib. browse_ authority_ refs_pivot suffers from a similar concern.
Per the PostgreSQL docs:
"""IMMUTABLE indicates that the function cannot modify the database and always returns the same result when given the same argument values; that is, it does not do database lookups or otherwise use information not directly present in its argument list."""