按批次批量添加顶点和边缘 - Amazon Neptune
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

按批次批量添加顶点和边缘

对 Neptune 数据库的每个查询都在单个事务的范围内运行,除非您使用会话。这意味着,如果您需要使用 gremlin 查询插入大量数据,请将它们以 50-100 个的批大小打包到一起,通过减少为每个负载创建的事务数来改善性能。

例如,如下所示添加 5 个顶点到数据库:

// Create a GraphTraversalSource for the remote connection final GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster)); // Add 5 vertices in a single query g.addV("Person").property(T.id, "P1") .addV("Person").property(T.id, "P2") .addV("Person").property(T.id, "P3") .addV("Person").property(T.id, "P4") .addV("Person").property(T.id, "P5").iterate();