Gremlin图查询将始终在其自己的地址空间中执行操作吗? [英] will Gremlin graph queries always perform operations in it's own address space?

查看:104
本文介绍了Gremlin图查询将始终在其自己的地址空间中执行操作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

诚然,我的大多数数据库经验是关系型的.该领域的宗旨之一是避免在网络上移动数据.这可以通过使用类似的东西来体现:

admittedly, most of my database experience is relational. one of the tenets in that space is to avoid moving data over the network. this manifests by using something like:

select * from person order by last_name limit 10

大概会在数据库引擎中进行排序和限制,而不是使用类似的方法:

which will presumably order and limit within the database engine vs using something like:

select * from person

,然后订购并排在客户的前10名,如果有100万人的记录,可能会造成灾难性的后果.

and subsequently ordering and taking the top 10 at the client which could have disastrous effects if there are a million person records.

因此,如果我做类似的事情,请使用Gremlin(来自Groovy):

so, with Gremlin (from Groovy), if i do something like:

g.V().has('@class', 'Person').order{println('!'); it.a.last_name <=> it.b.last_name}[0..9]

我看到打印了!,所以我假设这会将所有Person记录都放在订单和限制步骤之前的客户地址空间中,这不是预期的效果.

i am seeing the ! printed, so i am assuming that this bringing all Person records into the address space of my client prior to the order and limit steps which is not the desired effect.

我完全在数据库引擎中处理查询的选项是否因产品而异(例如,针对orient-db可能以SQL风格提交查询),或者我缺少Gremlin的某些信息?

do my options for processing queries entirely in the database engine become product specific (e.g. for orient-db perhaps submit the query in their flavor of SQL), or is there something about Gremlin that i am missing?

推荐答案

如果希望实现者的查询优化器加入,则需要使用尽可能多的Gremlin步骤,并避免对图形进行纯Groovy/内存中处理遍历.

If you want the implementer's query optimizer to kick in, you need to use as many Gremlin steps as possible and avoid pure Groovy/in-memory processing of your graph traversals.

您最有可能正在寻找类似这样的东西(从TinkerPop v3.2.0开始):

You're most likely looking for something like this (as of TinkerPop v3.2.0):

g.V().has('@class', 'Person').order().by('last_name', incr).limit(10)

如果您发现自己使用了lambda,那么通常可以通过纯Gremlin步骤完成此操作.偏爱Gremlin越过lambda.

If you find yourself using lambdas, chances are often high that this could be done with pure Gremlin steps. Favor Gremlin steps over lambdas.

请参阅TinkerPop v3.2.0文档:

See TinkerPop v3.2.0 documentation:

  • Order By step
  • Limit step

这篇关于Gremlin图查询将始终在其自己的地址空间中执行操作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆