gpt4 book ai didi

azure - Azure 表存储查询 PartitionKey/RowKey 列表的速度非常慢

转载 作者:行者123 更新时间:2023-12-02 08:10:28 25 4
gpt4 key购买 nike

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

对 Azure 表存储进行非常标准的查询,获取已知 PartitionKey 和 RowKey 的列表 (50)。服务器第一口需要 5 秒的时间。有什么办法可以加快速度吗?

最佳答案

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

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

编辑:

不确定您使用的是哪种语言,但这里有一个快速的 Node.js 测试,在我家看来通常需要 1 到 1.2 秒,但有时接近 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 - Azure 表存储查询 PartitionKey/RowKey 列表的速度非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11966450/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com