orientechnologies / orientechnologies/orientdb
Queries with embedded queries in where clause fail to use indexes.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5k
- Forks
- 868
- Avg merge
- 15h 6m
- Merged PRs (30d)
- 18
Description
OrientDB Version: 3.2.10
Java Version: 17.0.1+12-39
OS: RHEL 8.6
Expected behavior
Queries with embedded queries in where clause should use appropriate indexes when executing.
Actual behavior
select from UOM_RELATIONSHIP_TYPE where inCOI = (select @rid from COI where COI_NAME = 'my coi') or
select from UOM_RELATIONSHIP_TYPE where inCOI.COI_NAME = 'my coi'
executes in 300ms because it is doing a full scan of each vertex type
While doing this:
var rid = oDatabaseDocument.query("select @rid from COI where COI_NAME = 'my coi'");
var output = oDatabaseDocument.query("select from UOM_RELATIONSHIP_TYPE where inCOI = " + rid);
executes in 9ms, because it uses indexes and avoids a full scan.
Steps to reproduce
- Create 2 tables with one that has an out edge to the other.
- Index the search field (from example above a unique btree on COI_NAME)
- Populate with some data.
- Create a query that uses the out edge as the filter.
- Execute the query with the
PROFILEkey word to see the databases execution plan, it should fail to use indexes. - Execute the query in the console and time the response.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Reproduce the two queries on OrientDB 3.2.10 with PROFILE, compare their execution plans with the variable-based version, and trace the query-planning path responsible for index selection. Done means the embedded-query forms use the appropriate indexes and avoid full scans.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100