简体   繁体   中英

OrientDB query too slow

OrientDB v2.1.1, I have tow class: NOrder and NPassenger, relationship 1 : n, so NOrder has a filed named "passengers",whose type is linklist.

I have two fields (NOrder order_id, NPassenger. Name) index is established

NOrder ducuments count is 3 millon .

I explain these query:

 1)select from NOrder where passengers contains(name = 'xxx')
  why this query not involved index .

 2)select from NOrder where 'xxx' in passengers.name
  this query involved indexeses 

this query cost 120sec .

thanks

I have tried with this structure

create class NPassenger
create property NPassenger.name String
create index NPassenger.name on NPassenger (name) NOTUNIQUE_HASH_INDEX

create class NOrder 
create property NOrder.order_id String
create property NOrder.passengers linklist NPassenger
create index NOrder.order_id on NOrder (order_id) UNIQUE_HASH_INDEX

insert into NPassenger(name) values ("xxx")  // 12:0
insert into NPassenger(name) values ("Alessandro")  //12:1

insert into NOrder(order_id,passengers) values ("order 1",[12:0])
insert into NOrder(order_id,passengers) values ("order 2",[12:1])

Query 1

explain select from NOrder where passengers contains(name = 'xxx')

在此处输入图片说明

Query 2

explain select from NOrder where 'xxx' in passengers.name

在此处输入图片说明

None of the two queries use the index because the class target is NOrder.

UPDATE

Now I have 50002 NOrder and 50002 NPassenger. If I execute the queries

explain select from NOrder where passengers contains(name = 'xxx')

and

explain select from NOrder where 'xxx' IN passengers.name'

I get

在此处输入图片说明

this is because no index on the name field is used (because the target class is the Norder class) and then the search is done on all 50002 records of the class Norder.

If I use the query

explain select from NPassenger where name = "xxx"

在此处输入图片说明

the index NPassenger.name is used because the target class is NPassenger

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM