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

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

问题描述

GET /产品()?$过滤器=((PartitionKey%20eq%20'lIkfA81JpTmv')%20于是20%(RowKey%20eq%20''))
%20or%20((PartitionKey%20eq%20'lIGcEmrr7hWz')%20于是%20(RowKey%20eq%20''))
%20or%20((PartitionKey%20eq%20'lIAoy6PqeMVn')%20于是%20(RowKey%20eq%20''))
%20or%20((PartitionKey%20eq%20'lIjETAtuhYGM')%20于是%20(RowKey%20eq%20''))
%20or%20((PartitionKey%20eq%20'lIHa0znP5qAk')%20于是%20(RowKey%20eq%20''))
%20or%20((PartitionKey%20eq%20'lIOCaSXg9YE7')%20于是%20(RowKey%20eq%20''))
%20or%20((PartitionKey%20eq%20'lInRozGrMa7T')%20于是%20(RowKey%20eq%20''))
%20or%20((PartitionKey%20eq%20'lILEwwPPcBfe')%20于是%20(RowKey%20eq%20''))
%20or%20((PartitionKey%20eq%20'lJ14qZv1KFn4')%20于是%20(RowKey%20eq%20''))%
20or 20%((PartitionKey%20eq%20'lIIohzupFLcV')%20于是20%(RowKey%20eq%20'')).....

非常标准的查询天青表的存储而闻名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" 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.');
    });
}

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

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