feat(oracle): use TABLE(:bind_array) for bulk get chunks >= 900 keys#4359
Open
D2758695161 wants to merge 1 commit into
Open
feat(oracle): use TABLE(:bind_array) for bulk get chunks >= 900 keys#4359D2758695161 wants to merge 1 commit into
D2758695161 wants to merge 1 commit into
Conversation
| // Oracle's TABLE(:bind_array) syntax binds a string array as an Oracle | ||
| // collection type, avoiding the 1000-expression IN-list limit. | ||
| query := "SELECT key, value, binary_yn, etag, expiration_time FROM " + o.metadata.TableName + " WHERE key IN (SELECT COLUMN_VALUE FROM TABLE(:1)) AND (expiration_time IS NULL OR expiration_time > systimestamp)" | ||
| rows, err = o.db.QueryContext(ctx, query, goora.StringArray(keys)) |
Contributor
There was a problem hiding this comment.
goora.StringArray(keys) does this exist?
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.
Summary
Implements the optimization described in #4041.
What changed
In �ulkGetChunk, when the number of keys is >= 900, the query now uses Oracle's TABLE(:bind_array) syntax instead of the standard IN (:1, :2, ...) syntax:
\\sql
SELECT key, value, binary_yn, etag, expiration_time
FROM state_table
WHERE key IN (SELECT COLUMN_VALUE FROM TABLE(:1))
\\
This passes goora.StringArray(keys) as a bind variable, leveraging the go_ora driver's native Oracle ARRAY support.
Threshold
The 900-key threshold leaves a safe margin below Oracle's 1000-expression hard limit.
Testing
Existing unit tests cover chunking behavior and edge cases. The existing mock-based tests should continue to pass as the logic path is determined at runtime based on key count.
Closes #4041