简体   繁体   中英

Embedded List Query Performance In OrientDB

Maybe this is a very simple question about OrientDB, because I'm just using it for only a few days.

My question is, I have about a million documents(let's called it ClassA) in the OrientDB, and every document has a field(let's called it fieldA).

fieldA's type is embedded list, and the item in the embedded list is string.

So, the data in OrientDB is something like this:

[
    {
        fieldA: ['a','b','c']
    },
    {
        fieldA: ['c','d','e']
    },
]

What I want to do is to query the document by fieldA.

So the query is something like this:

select from ClassA where 'c' in fieldA

Because, there are millions of records in the database, so I created an Index for fieldA, the script that created the index is like this:

create index ClassA.fieldA not unique

But when I explain the select query, I got this:

{
    "@type":"d","@version":0,
     "involvedIndexes":["ClassA.fieldA"],
     "current":"#11:960477",
     "fetchingFromTargetElapsed":160596,
     "documentReads":959211,
     "documentAnalyzedCompatibleClass":959211,
     "recordReads":959211,
     "elapsed":160596.25,
     "resultType":"collection",
     "resultSize":1,
     "@fieldTypes":"involvedIndexes=e,fetchingFromTargetElapsed=l,documentReads=l,documentAnalyzedCompatibleClass=l,recordReads=l,elapsed=f"
 }

As you can see in the result, even if it used the Index ["ClassA.fieldA"], but for 959211 records, the query last for 160596 ms, about 16 seconds. That is too slow(compare to MySQL, for mysql, the records is even larger, because MySQL didn't support for embedded list, so the storage for mysql is that for every fieldA, has a record in MySQL, and the query is very fast, only cost 0.015 seconds).

Am I did something wrong? Or the performance of embedded list query in OrientDB is that bat?

Can someone has a deep understanding of OrientDB and OrientDB index help me about this?

MySQL returns the cursor right after the query by paginating them, but when you fetch all the records results could be different. Please try to do a

select count(*) from ClassA where 'c' in fieldA

On both OrientDB and MySQL or try to fetch all the records.

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