depth = 5 , 会快很多
select from (MATCH {class: repo_class_9a544097f789495e8ee4f5eb, where:(@rid='#338:0')}.both(){as: my_repo, while: ($depth < 5), where: ($depth =5)} RETURN $elements) where model_id in ['e5024d360b924e0c8de3c6a8', 'de90d618f7504723b677f196', '9bc4a41eb6364022b2f2c093', 'd1b11a713e8842b2b93fe397']
depth = 8, 就会很慢
select from (MATCH {class: repo_class_9a544097f789495e8ee4f5eb, where:(@rid='#338:0')}.both(){as: my_repo, while: ($depth < 8), where: ($depth =8)} RETURN $elements) where model_id in ['e5024d360b924e0c8de3c6a8', 'de90d618f7504723b677f196', '9bc4a41eb6364022b2f2c093', 'd1b11a713e8842b2b93fe397']
image.png image.pngMATCH {class: repo_class_9a544097f789495e8ee4f5eb, where:(@rid='#338:0')}.both(){as: my_repo, while: ($depth < 5), where: ($depth =5)} RETURN $elements
orientdb {db=cmdb_test}> MATCH {class: repo_class_9a544097f789495e8ee4f5eb, where:(@rid='#338:0')}.both().both(){class: repo_class_c73339db70cc4647b515eaca}.both().both(){class: repo_class_9e97b54a4a54472e9e913d4e}.both().both(){class: repo_class_59c0af57133442e7b34654a3}.both().both(){class: repo_class_e5024d360b924e0c8de3c6a8, as: my_repo} RETURN $elements
+----+------+---------+----+----+----+----+----+----+-----+------+--------+--------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|# |@RID |@CLASS |port|vip |role|env |user|path|frame|status|use_mode|database|server_id|version |manager_i|config_pa|update_ti|business_|operation|write_ip |read_ip |create_ti|model_id |id |baseInfo |out_repo_|in_repo_m|schema |
+----+------+---------+----+----+----+----+----+----+-----+------+--------+--------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|0 |#217:0|repo_c...|3316| | | | | |MHA | | SHARED | |133316 |5.6.24...| | | | | |10.252...|10.252...|2018-0...|e5024d...|caf38a...|mysql_...|[#137:...|[#134:...|common...|
...
|19 |#216:2|repo_c...|3316| | | | | | | | | | |MYSQL5.6 | | | | | | | |2018-0...|e5024d...|4f1ad0...|Router...|[#132:...|[#133:...| |
+----+------+---------+----+----+----+----+----+----+-----+------+--------+--------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
LIMIT EXCEEDED: resultset contains more items not displayed (limit=20)
20 item(s) found. Query executed in 0.122 sec(s).
image.png
这里涉及一个问题,数据太多的时候如何显示全部?总不能只显示20条吧...
用 pyorient client 可以获取全部数据:
from tornado.options import parse_command_line
import pyorient
cmdb_port = "2424"
cmdb_url = "db-vip"
db_username = "root"
db_password = "root"
db_name = "cmdb_test"
print "base info, cmdb_url: %s, cmdb_port: %s, db_name: %s, db_username: %s, db_password: %s" % (cmdb_url, cmdb_port,
db_name, db_username, db_password)
client = pyorient.OrientDB(cmdb_url, cmdb_port)
def test_cmd(sql_cmd):
client.db_open(db_name, db_username, db_password)
try:
ret = client.command(sql_cmd)
print 'ret', ret
print 'ret len', len(ret)
except Exception as e:
logging.exception("Test cmd failed, Exception:", e.args)
if __name__ == '__main__':
parse_command_line()
sql_cmd = "MATCH {class: repo_class_9a544097f789495e8ee4f5eb, where:(@rid='#338:0')}.both().both(){class: repo_class_c73339db70cc4647b515eaca}.both().both(){class: repo_class_9e97b54a4a54472e9e913d4e}.both().both(){class: repo_class_59c0af57133442e7b34654a3}.both().both(){as: my_repo} RETURN $elements"
test_cmd(sql_cmd)
网友评论