简体   繁体   English

OrientDB中的嵌入式列表查询性能

[英]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. 也许这是一个关于OrientDB的非常简单的问题,因为我仅使用了几天。

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). 我的问题是,在OrientDB中我有大约一百万个文档(称为ClassA),每个文档都有一个字段(称为fieldA)。

fieldA's type is embedded list, and the item in the embedded list is string. fieldA的类型为嵌入列表,嵌入列表中的项目为字符串。

So, the data in OrientDB is something like this: 因此,OrientDB中的数据如下所示:

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

What I want to do is to query the document by fieldA. 我想做的是通过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: 因为数据库中有数百万条记录,所以我为fieldA创建了一个索引,创建该索引的脚本是这样的:

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. 从结果中可以看到,即使它使用索引[“ ClassA.fieldA”],但对于959211记录,查询持续160596毫秒(约16秒)。 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). 这太慢了(与MySQL相比,对于mysql来说,记录更大,因为MySQL不支持嵌入式列表,因此mysql的存储是每个fieldA在MySQL中都有一条记录,并且查询非常多快速,只需花费0.015秒)。

Am I did something wrong? 我做错什么了吗? Or the performance of embedded list query in OrientDB is that bat? 还是OrientDB中嵌入式列表查询的性能是最好的选择?

Can someone has a deep understanding of OrientDB and OrientDB index help me about this? 有人可以对OrientDB和OrientDB索引有深入的了解吗?

MySQL returns the cursor right after the query by paginating them, but when you fetch all the records results could be different. MySQL通过分页在查询之后立即返回游标,但是当您获取所有记录时,结果可能会有所不同。 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. 在OrientDB和MySQL上,或尝试获取所有记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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