对 PartitionKey/RowKey 列表的 Azure 表存储查询非常慢 [英] Very Slow on Azure Table Storage Query on PartitionKey/RowKey List

查看:30
本文介绍了对 PartitionKey/RowKey 列表的 Azure 表存储查询非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GET/Product()?$filter=((PartitionKey%20eq%20'lIkfA81JpTmv')%20and%20(RowKey%20eq%20''))%20or%20((PartitionKey%20eq%20'lIGcEmrr7hWz')%20and%20(RowKey%20eq%20''))%20or%20((PartitionKey%20eq%20'lIAoy6PqeMVn')%20and%20(RowKey%20eq%20''))%20or%20((PartitionKey%20eq%20'lIjETAtuhYGM')%20and%20(RowKey%20eq%20''))%20or%20((PartitionKey%20eq%20'lIHa0znP5qAk')%20and%20(RowKey%20eq%20''))%20or%20((PartitionKey%20eq%20'lIOCaSXg9YE7')%20and%20(RowKey%20eq%20''))%20or%20((PartitionKey%20eq%20'lInRozGrMa7T')%20and%20(RowKey%20eq%20''))%20or%20((PartitionKey%20eq%20'lILEwwPPcBfe')%20and%20(RowKey%20eq%20''))%20or%20((PartitionKey%20eq%20'lJ14qZv1KFn4')%20and%20(RowKey%20eq%20''))%20or%20((PartitionKey%20eq%20'lIIohzupFLcV')%20and%20(RowKey%20eq%20''))....

对 Azure 表存储的非常标准的查询,以获取已知 PartitionKey 和 RowKey 的列表 (50).服务器的第一口需要 5 秒.有没有办法加快速度?

Very standard Query to Azure Table Storage for a List(50) of Known PartitionKey and RowKey. This will take 5 seconds for first bite from Server. Is there anyway to speed things up?

推荐答案

Or"查询未按照您预期的方式进行优化.像这样的查询会导致全表扫描.正如 Gaurav 所建议的那样,您确实需要将这些作为单独的查询(并行)执行以获得快速响应时间.

"Or" queries are not optimized the way you might expect them to be. A query like this results in a full table scan. As Gaurav suggested, you really need to do these as separate queries (in parallel) to get fast response times.

我也完全不同意 Astaykov 的说法,即您不应该费心进行优化,因为您的性能在 SLA 范围内.性能不是随机的,SLA 通常是一个上限.请花时间优化对性能敏感的查询.您应该能够轻松地在亚秒时间内始终如一地执行此类查找.

I also thoroughly disagree with Astaykov's statement that you shouldn't bother optimizing because your performance is within the SLA. The performance isn't random, and an SLA is generally an upper bound. Do take the time to optimize your performance-sensitive queries. You should easily be able to do this sort of lookup consistently in sub-second time.

不确定您使用的是哪种语言,但这里有一个快速的 Node.js 测试,它似乎通常从我家到 1 到 1.2 秒,但有时会接近 1.5 秒:

Not sure which language you're working in, but here's a quick Node.js test that seems to usually take between 1 and 1.2 seconds from my house, but occasionally closer to 1.5:

function timeParallelQueries(account, key) {
    var azure = require('azure'),
        Q = require('q'),
        _ = require('underscore');

    var tables = azure.createTableService(account, key);

    function convertToString(n) { return n + ''; }

    var start = null;

    Q.ncall(tables.createTableIfNotExists, tables, 'test')
    .then(function () {
        return Q.all(_.map(_.map(_.range(50), convertToString), function(key) {
            return Q.ncall(tables.insertOrReplaceEntity, tables, 'test', {PartitionKey: key, RowKey: key});
        }));
    })
    .then(function () {
        start = new Date();
        return Q.all(_.map(_.map(_.range(50), convertToString), function (key) {
            return Q.ncall(tables.queryEntity, tables, 'test', key, key);
        }));
    })
    .then(console.log)
    .then(function (results) {
        console.log('Took ' + (new Date() - start) + 'ms.');
    });
}

这篇关于对 PartitionKey/RowKey 列表的 Azure 表存储查询非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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