From 7de1ef773ed9359db3b1bf8041e67c050ec8c564 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 11 Dec 2014 15:57:11 +0100 Subject: [PATCH] SORT: Don't sort Set elements if not needed. Related to #2094. --- src/sort.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sort.c b/src/sort.c index f813ff26..37248196 100644 --- a/src/sort.c +++ b/src/sort.c @@ -270,7 +270,9 @@ void sortCommand(redisClient *c) { * The other types (list, sorted set) will retain their native order * even if no sort order is requested, so they remain stable across * scripting and replication. */ - if ((dontsort && sortval->type == REDIS_SET)) + if (dontsort && + sortval->type == REDIS_SET && + (storekey || c->flags & REDIS_LUA_CLIENT)) { /* Force ALPHA sorting */ dontsort = 0;