Cosmos DB-Gremlin-订购时查询性能降低

时间:2019-04-29 09:42:52

标签: azure-cosmosdb gremlin

我希望有人可以帮助我。我已经设置了一个简单的测试来测试基本图的查询性能。我已包含以下代码。基本上,我要做的是创建30000个顶点,然后在其中一个顶点上创建20000条边。

public async Task<bool> runTests(Models.Person person)
    {
        try
        {
            var gremlinServer = new GremlinServer(_hostname, _port, enableSsl: true,
                                               username: "/dbs/" + _dataBaseId + "/colls/" + _collectionId,
                                               password: _authKey);

            using (var gremlinClient = new GremlinClient(gremlinServer, new GraphSON2Reader(), new GraphSON2Writer(), GremlinClient.GraphSON2MimeType))
            {
                await gremlinClient.SubmitAsync<dynamic>("g.E().drop()");
                await gremlinClient.SubmitAsync<dynamic>("g.V().drop()");

                var counter = 30000;
                while (counter != 0)
                {
                    await gremlinClient.SubmitAsync<dynamic>("g.addV('partition" + counter + "').property('id', 'partition" + counter + "').property('profilePicture', '" + person.ProfilePicture + "').property('name', 'Person " + counter + "').property('partitionKey', 'partition" + counter + "')");
                    counter--;
                }

                var counter = 20000;
                while (counter != 0)
                {
                    int num = counter + 1;
                    var personToLink = "partition" + num;
                    await gremlinClient.SubmitAsync<dynamic>("g.V('partition1').addE('friendsWith').to(g.V('partition" + num + "'))");
                    counter--;
                }

                var searchResults = await gremlinClient.SubmitAsync<dynamic>("g.V().hasId('partition1').out('friendsWith').order().by('name', incr).valueMap('name', 'profilePicture').range(0,2)");

                return true;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

当我运行以下查询结果时,会迅速返回:

 g.V().hasId('partition1').out('friendsWith').valueMap('name', 'profilePicture').range(0,2)

但是,一旦添加了order子句,查询就会花很多时间。一分钟完成:

g.V().hasId('partition1').out('friendsWith').order().by('name', incr).valueMap('name', 'profilePicture').range(0,2)

有没有一种方法可以索引图形来加快这种查询速度?

我还有另一个问题,我已将吞吐量设置为5000 RU,但是当我运行非常快速的查询时,我得到以下信息:

Data Explorer Query Stats Result

这个值应该代表什么(RU?),为什么那么高呢?

当我尝试运行一个简单查询时:

g.V().hasId('partition1').out('friendsWith').hasId('partition20001') 

即使这样简单的查询,我也会收到“请求率很高”的信息。更令人担忧的是,当我将吞吐量提高到5000 RU时,我确实得到了一个结果,但它的确很慢,大约需要5到6秒钟来完成,这应该是一个非常简单的查询。

0 个答案:

没有答案
相关问题