mysql索引更新耗时_数据库-Titan索引更新花费的时间太长

即使在空数据库上,在Titan 1.0中创建索引也要花费几分钟.时间似乎很准确,这表明有不必要的延迟.

我的问题是:如何缩短或消除Titan重新编制索引所需的时间?从概念上讲,由于无需进行任何工作,因此时间应最短,当然不应为4分钟.

(注:我之前曾指出过一个解决方案,该解决方案只是让Titan等待整个延迟而不会超时.这是错误的解决方案-我想完全消除延迟.)

我用来从头开始设置数据库的代码是:

graph = ... a local cassandra instance ...

graph.tx().rollback()

// 1. Check if the index already exists

mgmt = graph.openManagement()

i = mgmt.getGraphIndex('byIdent')

if(! i) {

// 1a. If the index does not exist, add it

idKey = mgmt.getPropertyKey('ident')

idKey = idKey ? idKey : mgmt.makePropertyKey('ident').dataType(String.class).make()

mgmt.buildIndex('byIdent', Vertex.class).addKey(idKey).buildCompositeIndex()

mgmt.commit()

graph.tx().commit()

mgmt = graph.openManagement()

idKey = mgmt.getPropertyKey('ident')

idx = mgmt.getGraphIndex('byIdent')

// 1b. Wait for index availability

if ( idx.getIndexStatus(idKey).equals(SchemaStatus.INSTALLED) ) {

mgmt.awaitGraphIndexStatus(graph, 'byIdent').status(SchemaStatus.REGISTERED).call()

}

// 1c. Now reindex, even though the DB is usually empty.

mgmt.updateIndex(mgmt.getGraphIndex('byIdent'), SchemaAction.REINDEX).get()

mgmt.commit()

mgmt.awaitGraphIndexStatus(graph, 'byIdent').status(SchemaStatus.ENABLED).call()

} else { mgmt.commit() }

它似乎是阻塞直到超时的updateIndex … REINDEX调用.这是已知问题还是workformewon’tfix?难道我做错了什么?

编辑:禁用REINDEX,如注释中所讨论的,实际上并不是解决方法,因为该索引似乎没有变为活动状态.我现在看到:

WARN com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx - Query requires iterating over all vertices [(myindexedkey = somevalue)]. For better performance, use indexes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值