我正在使用OrientDB Enterprise Server v2.1.13并遇到了一些我无法找到解释和解决方案的问题。
似乎自动复合SB-Tree索引工作不正确,并且没有索引新值(或者我误解了某些东西)。 A有以下边缘类:
CREATE CLASS ACTION EXTENDS E CLUSTERS 0 ABSTRACT
CREATE PROPERTY ACTION.out LINK
ALTER PROPERTY ACTION.out MANDATORY true
ALTER PROPERTY ACTION.out NOTNULL true
CREATE PROPERTY ACTION.in LINK
ALTER PROPERTY ACTION.in MANDATORY true
ALTER PROPERTY ACTION.in NOTNULL true
CREATE PROPERTY ACTION.action STRING
ALTER PROPERTY ACTION.action MANDATORY true
CREATE PROPERTY ACTION.status STRING
ALTER PROPERTY ACTION.status DEFAULT 'NEW'
CREATE INDEX ACTION.out_action_in ON ACTION (out, action, in) UNIQUE
CREATE CLASS LINK EXTENDS ACTION CLUSTERS 8
ALTER CLASS LINK CLUSTERSELECTION balanced
CREATE INDEX LINK.out_action_in ON LINK (out, action, in) UNIQUE
然后我们插入:
CREATE EDGE LINK FROM #12:0 TO #30:0 SET action = 'a';
我们可以选择并看到它已正确插入数据库:
orientdb {db=userdata}> SELECT FROM LINK WHERE action = 'a';
----+-----+------+------+-----+-----+------
# |@RID |@CLASS|action|out |in |status
----+-----+------+------+-----+-----+------
0 |#36:0|LINK |a |#12:0|#30:0|NEW
----+-----+------+------+-----+-----+------
现在让我们创建SB-Tree NOTUNIQUE索引(默认值):
CREATE INDEX LINK.action_status ON LINK (action, status) NOTUNIQUE
现在我们创建一个新记录:
CREATE EDGE LINK FROM #12:0 TO #30:0 SET action = 'b';
orientdb {db=userdata}> SELECT FROM LINK
----+-----+------+------+-----+-----+------
# |@RID |@CLASS|action|out |in |status
----+-----+------+------+-----+-----+------
0 |#36:0|LINK |a |#12:0|#30:0|NEW
1 |#37:8|LINK |b |#12:0|#30:0|NEW
----+-----+------+------+-----+-----+------
现在我们尝试选择'a'和'b'值:
orientdb {db=userdata}> SELECT FROM LINK WHERE action = 'a';
----+-----+------+------+-----+-----+------
# |@RID |@CLASS|action|out |in |status
----+-----+------+------+-----+-----+------
0 |#36:0|LINK |a |#12:0|#30:0|NEW
----+-----+------+------+-----+-----+------
1 item(s) found. Query executed in 0.001 sec(s).
orientdb {db=userdata}> SELECT FROM LINK WHERE action = 'b';
0 item(s) found. Query executed in 0.001 sec(s).
说明:
Profiled command '{fullySortedByIndex:false,compositeIndexUsed:1,involvedIndexes:[1],limit:-1,fetchingFromTargetElapsed:0,indexIsUsedInOrderBy:false,user:#5:0,elapsed:1.116033,resultType:collection,resultSize:0}' in 0,002000 sec(s):
{"@type":"d","@version":0,"fullySortedByIndex":false,"compositeIndexUsed":1,"involvedIndexes":["LINK.action_status"],"limit":-1,"fetchingFromTargetElapsed":0,"indexIsUsedInOrderBy":false,"user":"#5:0","elapsed":1.116033,"resultType":"collection","resultSize":0,"@fieldTypes":"compositeIndexUsed=l,involvedIndexes=e,fetchingFromTargetElapsed=l,user=x,elapsed=f"}
但是 - 如果你使用IN()选择它 - 它就在那里:
orientdb {db=userdata}> SELECT FROM LINK WHERE action in ['b'];
----+-----+------+------+-----+-----+------
# |@RID |@CLASS|action|out |in |status
----+-----+------+------+-----+-----+------
0 |#37:7|LINK |b |#12:0|#30:0|NEW
----+-----+------+------+-----+-----+------
1 item(s) found. Query executed in 0.002 sec(s).
说明:
Profiled command '{documentReads:1,current:#36:1,documentAnalyzedCompatibleClass:1,recordReads:1,limit:-1,fetchingFromTargetElapsed:0,evaluated:1,user:#5:0,elapsed:0.666479,resultType:collection,resultSize:1}' in 0,002000 sec(s):
{"@type":"d","@version":0,"documentReads":1,"current":"#36:1","documentAnalyzedCompatibleClass":1,"recordReads":1,"limit":-1,"fetchingFromTargetElapsed":0,"evaluated":1,"user":"#5:0","elapsed":0.666479,"resultType":"collection","resultSize":1,"@fieldTypes":"documentReads=l,current=x,documentAnalyzedCompatibleClass=l,recordReads=l,fetchingFromTargetElapsed=l,evaluated=l,user=x,elapsed=f"}
对此问题的任何建议?
答案 0 :(得分:0)
目前我的解决方法是使用哈希索引,这似乎在我的情况下正常工作。
DROP INDEX LINK.action_status;
CREATE INDEX LINK.action_status ON LINK (action, status) NOTUNIQUE_HASH_INDEX;
orientdb {db=userdata}> CREATE EDGE LINK FROM #12:0 TO #30:0 SET action = 'c';
Created edge '[LINK#38:4{action:c,out:#12:0,in:#30:0,status:NEW} v1]' in 0,003000 sec(s).
orientdb {db=userdata}> SELECT FROM LINK;
----+-----+------+------+-----+-----+------
# |@RID |@CLASS|action|out |in |status
----+-----+------+------+-----+-----+------
0 |#36:0|LINK |a |#12:0|#30:0|NEW
1 |#37:8|LINK |b |#12:0|#30:0|NEW
2 |#38:4|LINK |c |#12:0|#30:0|NEW
----+-----+------+------+-----+-----+------
3 item(s) found. Query executed in 0.002 sec(s).
orientdb {db=userdata}> SELECT FROM LINK WHERE action = 'c';
----+-----+------+------+-----+-----+------
# |@RID |@CLASS|action|out |in |status
----+-----+------+------+-----+-----+------
0 |#38:4|LINK |c |#12:0|#30:0|NEW
----+-----+------+------+-----+-----+------
1 item(s) found. Query executed in 0.002 sec(s).
orientdb {db=userdata}> SELECT FROM LINK WHERE action in ['c'];
----+-----+------+------+-----+-----+------
# |@RID |@CLASS|action|out |in |status
----+-----+------+------+-----+-----+------
0 |#38:4|LINK |c |#12:0|#30:0|NEW
----+-----+------+------+-----+-----+------
1 item(s) found. Query executed in 0.002 sec(s).