【发布时间】:2017-04-14 10:10:25
【问题描述】:
节点版本:v7.4.0
node-redis 版本:v.2.6.2
redis_version:2.8.4
ubuntu 14.04 2GB RAM VPS 实例
我得到的迹象表明 node_redis hgetall 的性能不是应该的,但可能我做错了什么。我有一个包含 31669 个元素的排序集。元素是散列键,每个散列有 14 个字段,大约 256 个字节。检索哈希需要大约 64 秒,这似乎太慢了。 下面是函数的样子:
function getAllAnnotations()
{
var currentSeconds = Math.floor((new Date()).getTime() / 1000);
console.log('currentSeconds before zrange: ' + currentSeconds);
client.zrangebyscore("geoHashSortedSet", "-inf", "+inf", function(err, reply) {
multi = client.multi();
for (var uuid in reply) {
multi.hgetall(reply[uuid]);
}
multi.exec(function(err, replies) {
var currentSeconds = Math.floor((new Date()).getTime() / 1000);
console.log('currentSeconds after multi returns: ' + currentSeconds);
allAnnotations = replies;
});
});
}
这里的其他人是否同意这是较差的性能,我在上面的代码中做的任何事情是问题的一部分吗?
【问题讨论】:
-
你试过
client.batch()吗?您不仅要为批处理计时,还要为zrangebyscore计时。 -
我会尝试 client.batch()。是的,我知道我正在计时 zrangebyscore。可能我不应该包括它。谢谢。
标签: node.js redis node-redis