2

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?

2
  • Have you found a solution?
    – snorbi
    Oct 27, 2014 at 17:24
  • Nope, gave up the OrientDB for a while now. MySQL seems to be a better database for me now. :D
    – guitarpoet
    Oct 30, 2014 at 13:03

1 Answer 1

0

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.

3
  • No, that's not that easy. The database has only 1 object for 'c' in fieldA.
    – guitarpoet
    Apr 23, 2014 at 5:49
  • So OrientDB profiler result says that it browsed 959,211 record: the index hasn't been used properly.
    – Lvca
    Apr 23, 2014 at 17:10
  • Yes, I agree with you, so this problem is just about that, did I use the index wrong? If I was wrong, how to use the index to make this query fast?
    – guitarpoet
    Apr 24, 2014 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.