Search code examples
orientdb

How to speed up query against index of linked document


I have follow database structure:

create class User
create class Social

create property Social.vk string
create property User.social LINK Social

create index User.social unique
create index Social.vk notunique

Query select from User where social.vk = '123' uses index.

Explain in studio gives me info:

 involvedIndexes
 ["User.social","Social.vk"]

 elapsed
 2771.4197

It significantly slower than

select from Social where vk = '123' which runs at 10-30 millis.

How can i speed up slow query or maybe redesign my data with bidirectional linking?

upd
Comparing to query time without index, seems like index not uses, but according 'explain' it uses.

upd2
Problem appears when 'vk' field is not unique and has many repeated values


Solution

  • It's a bug with osql. Simple workaround - query indexes directly. So there is no problem with performance.