Repository navigation
Speed up building temp tables for large IN clauses - #8382
Merged
labkey-jeckels merged 2 commits intoNov 26, 2026
Merged
Conversation
On PostgreSQL, build them UNLOGGED with a single unnest() insert and a unique index, and keep each cached until 5 minutes after its last use.
Block readers during the UNLOGGED reset check, limit the UNIQUE index to PostgreSQL, cap cached tables at one hour, and length-prefix cache key values so different lists can't collide.
labkey-jeckels
commented
Nov 24, 2026
| if (HeartBeat.currentTimeMillis() - _lastCheck > CHECK_INTERVAL) | ||
| { | ||
| // Block rather than skip: a reader returning the old generation mid-check could reuse an emptied table | ||
| _checkLock.lock(); |
Contributor
Author
There was a problem hiding this comment.
This is a more conservative approach to avoid reading a truncated table after a DB switch. I'm lukewarm on how much to worry about this failover scenario.
labkey-jeckels
marked this pull request as ready for review
November 24, 2026 01:26
XingY
approved these changes
Nov 25, 2026
| } | ||
|
|
||
| @Test | ||
| public void testUnlogged() |
Contributor
There was a problem hiding this comment.
Should we add a test for testNotUnlogged?
Contributor
Author
There was a problem hiding this comment.
I'm not seeing an easy way to do that, as it would require an external data source to be configured. The UNLOGGED difference is small in terms of codepath differences, so I think it's low risk.
labkey-nicka
removed their request for review
November 25, 2026 23:14
| return null; | ||
|
|
||
| String cacheKey = getCacheKey(jdbcType, sortedParameters); | ||
| DbSchema tempSchema = _tempSchemaSupplier.get(); |
Contributor
There was a problem hiding this comment.
Heads up, this may conflict with similar changes in #8381 which is targeting develop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
Building the temp table behind a large IN clause took 1–2 s for a 100k-value string list on a busy RDS server, and the table was rebuilt every 5 minutes even while clients kept sending the same list. Locally, the full build for 100k barcodes drops from about 740 ms to about 190 ms.
Changes
Tasks