Skip to content

fix(oracle): use bind parameters in showIndex - #18498

Draft
wikirik-agent wants to merge 1 commit into
mainfrom
wikirik-agent/oracle-show-index-bind
Draft

wikirik-agent wants to merge 1 commit into
mainfrom
wikirik-agent/oracle-show-index-bind

Conversation

@wikirik-agent

@wikirik-agent wikirik-agent commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Description of Changes

Model.sync() runs queryInterface.showIndex() for every model. On Oracle, that query inlined the table name as a literal, so every call was a new SQL text that Oracle had to hard parse against the ALL_IND_COLUMNS / ALL_INDEXES / ALL_CONSTRAINTS dictionary views. On Oracle 23 that parse takes hundreds of milliseconds.

This PR makes the Oracle query interface run showIndex with the table and schema names as bind parameters, so Oracle reuses the parsed statement across tables:

  • OracleQueryGenerator#showIndexesQueryWithBind() returns { query, bind } and shares its SQL with showIndexesQuery(). showIndexesQuery() still returns the same SQL with literals, so its output does not change.
  • OracleQueryInterface#showIndex() uses the bind variant.

Local numbers against a fresh gvenzl/oracle-free:23.26.3-slim container, the same image CI uses:

before after
a single showIndex call, new table name each time (micro-benchmark) 680–840 ms 31–41 ms
showIndex total time in test/integration/associations/** (650 calls) 181 s 2.5 s
test/integration/associations/** total (276 tests; with #18497 applied as well) 272 s 82 s

Hard parsing accounted for about 56% of all SQL time in the Oracle integration suite. That is the main reason the "oracle latest" CI job (~15 min) is the slowest one; "oracle oldest" (18 XE) runs the same tests in ~6 min. #18496 is a CI-only experiment that forces cursor sharing to measure the same effect.

showConstraints (the foreign-key lookup) and describeTable inline literals the same way. They are handled in the stacked follow-up #18499, which needs a small core seam because the abstract query interface post-processes their results.

List of Breaking Changes

None.

🤖 Generated with Claude Code

Oracle hard parses every distinct SQL text. Because the table name was
inlined, every showIndex call (which Model.sync runs for each model) was
hard parsed against the dictionary views, which takes hundreds of
milliseconds on Oracle 23.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant