【问题标题】:is this query using indexing in titan?这个查询是在 Titan 中使用索引吗?
【发布时间】:2017-01-18 02:53:04
【问题描述】:

对于 Titan db 上的以下 gremlin 脚本:

g.V(1).out().has("age",gt(10))

如何在查询条件上使用titan索引:has("age",gt(10))来加快查询速度?

【问题讨论】:

    标签: indexing graph-databases titan


    【解决方案1】:

    如果您在上传数据之前创建索引(最好的方法是您不必重新索引现有数据),那么 Titan 将在回答您的查询时自动使用该索引(下面的注释 1):

    以下代码取自Titan docs

    graph.tx().rollback()  //Never create new indexes while a transaction is active
    mgmt = graph.openManagement()
    name = mgmt.getPropertyKey('age')
    mgmt.buildIndex('ageIndex', Vertex.class).addKey(age).buildMixedIndex("<indexingbackendname>")
    mgmt.commit()
    

    1:Titan’s query optimizer attempts to pick the most efficient index for any given traversal.

    如果您在那些 Titan 文档中阅读“以顶点为中心的索引”,它有一个示例,其中创建的相关索引是为了加快第二个 has 子句(即使它是边缘索引——相同的主体)。

    【讨论】:

    • 为这个正确答案添加一点:如果您不需要检查范围,即不需要gt(x),那么您可以使用不需要的更简单的Composite Indices一个索引后端。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-19
    • 2019-10-03
    • 2011-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-31
    相关资源
    最近更新 更多