Dobi
Dobi

Reputation: 101

Newbie: OrientDB Basic SQL Query

OrientDB version 1.7.10

We are running the following two queries and number of records returned are different.

select from (select from sitedata ) where localdate='2014-09-24'
select from sitedata where  localdate='2014-09-24'

The first query returns 6 records where as the second one returns only one record.

Sitedata is a vertex and localdate is a property with Date datatype. There is an index created on the localdate as well.

Conceptually what is the difference between the two queries? In the first scenario we are creating what is known as an inline view in RDBMS world and then putting a filter on the records in the in line view. We assume it must be internally fetching all records from database and then filtering in memory. In the second query the the data is directly being filtered and the index will be used.

Upvotes: 2

Views: 178

Answers (1)

wolf4ood
wolf4ood

Reputation: 1949

The difference is that in the first query the index is not used. So it does the full scan of the class sitedata and apply the filter

The engine is not able to use the index because the target of the query is the nested query, so it evaluate the nested and then the outer query while applying filtering in memory

Upvotes: 2

Related Questions