Hi,

I have an observation with reference to using inner queries (i.e. LET 
keyword) and would like to understand why this happens. Given the details 
below;

*Scenario :* I have two groups of Users who share a common Id. I need find 
the users who are common. In other words, simulate an inner join.

*Schema :* I have two classes UserA and UserB representing the two user 
groups. Common attribute is userId. I'm using a document db. Both the 
classes have UNIQUE_HASH_INDEX s on the userId attribute.

*Query*:

SELECT userId, $l[0].userId
FROM UserA
LET $l = (
  SELECT
  FROM UserB WHERE userId = $parent.$current.userId
) WHERE $l.size() > 0

*Observations : *
1. Time to return results increases exponentially when the number of 
records in each of the classes increase (seems the index is not used in the 
inner query)
2. Explain on the query does not reveal any usage of the indexes created
3. If I replace the "$parent.$current.userId" portion with an actual 
userId, the results are given pretty fast (seems the index is used in the 
inner query)
4. A JavaScript function (OFunction) where I query and loop through all the 
records of UserA and run a query to find the matching records of UserB with 
in the loop executes pretty fast

Does the above observations suggest that the indexes are not used in the 
inner query?

Thanks in advance.
Omega

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to