Skip to content

feat(oracle): use TABLE(:bind_array) for bulk get chunks >= 900 keys#4359

Open
D2758695161 wants to merge 1 commit into
dapr:mainfrom
D2758695161:feat/oracle-table-bind-array
Open

feat(oracle): use TABLE(:bind_array) for bulk get chunks >= 900 keys#4359
D2758695161 wants to merge 1 commit into
dapr:mainfrom
D2758695161:feat/oracle-table-bind-array

Conversation

@D2758695161
Copy link
Copy Markdown

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

  • < 900 keys: standard IN-list with individual bind variables (existing behavior)
  • >= 900 keys: TABLE(:bind_array) with StringArray bind (new optimization)

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

@D2758695161 D2758695161 requested review from a team as code owners April 23, 2026 19:14
// 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))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goora.StringArray(keys) does this exist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Oracle state store bulk querying improvements

2 participants