Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonView findById triggers full table scan #3225

Closed
AaronTacke opened this issue Nov 13, 2024 · 1 comment
Closed

JsonView findById triggers full table scan #3225

AaronTacke opened this issue Nov 13, 2024 · 1 comment

Comments

@AaronTacke
Copy link

Expected Behavior

Calling findById for a JsonView results in a query like this
SELECT student_view_.* FROM "STUDENT_SCHEDULE" student_view_ WHERE (student_view_.DATA."_id" = ?)
which triggers a full table/index scan.

Actual Behaviour

Calling findById for a JsonView should use .numberOnly() (see Oracle Docs)
SELECT student_view_.* FROM "STUDENT_SCHEDULE" student_view_ WHERE (student_view_.DATA."_id".numberOnly() = ?)
which allows the OracleDB to use an unique index lookup.

Steps To Reproduce

  1. Run oracle-jsonview-demo-app with query logging (add <logger name="io.micronaut.data.query" level="DEBUG"/> to logback.xml)
  2. curl localhost:8080/students/1
  3. In SQL*Plus: SET AUTOTRACE ON EXP and execute query logged by micronaut
    Result shows INDEX FAST FULL SCAN or TABLE ACCESS FULL and warns:
1 - SEL$A8194D38 / "OUTER_ALIAS0"@"SEL$2"
     -  The following columns have predicates which preclude their
        use as keys in index range scan. Consider rewriting the
        predicates.
          "ID"

Environment Information

Should currently occur in every environment and with every database which supports JsonViews.

Example Application

https://github.com/oracle-samples/oracle-db-examples/tree/main/java/micronaut-jsonview-demo-app

Version

4.5.0

@AaronTacke
Copy link
Author

Solved by #3222

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

No branches or pull requests

1 participant