Repository: redis/redis

Issue:
Time complexity of geohash
https://github.com/redis/redis/blob/2495b90a647f9f9987202efd29647f81f217b8ad/src/geo.c#L891C22-L891C31
```
void geohashCommand(client *c) {
    char *geoalphabet= "0123456789bcdefghjkmnpqrstuvwxyz";
    int j;

    /* Look up the requested zset */
    robj *zobj = lookupKeyRead(c->db, c->argv[1]);
    if (checkType(c, zobj, OBJ_ZSET)) return;

    /* Geohash elements one after the other, using a null bulk reply for
     * missing elements. */
    addReplyArrayLen(c,c->argc-2);
    for (j = 2; j < c->argc; j++) {
        double score;
        if (!zobj || zsetScore(zobj, c->argv[j]->ptr, &score) == C_ERR) {
            addReplyNull(c);
        }
        // ...
    }        
}
```
You can see that the geohash command uses zsetScore to query the score, and the internal is a hashtable query. Why does the document(refer: https://redis.io/commands/geohash) say "Time complexity: O(log(N)) for each member requested, where N is the number of elements in the sorted set."


Discussion:
yean, zsetScore is using the hashtable, that would be O(1).
do you want to raise a PR to fix it or should i take care of it?
please help me change it thank you
@forthcoming @enjoy-binbin sorted set uses skiplist as main datastructure. Redis Just uses hashtable just to control main key of sorted set (not its data). so O(Log(N)) is correct.
@clark-lt 
https://github.com/redis/redis/blob/unstable/src/t_zset.c#L1310
I still believe in my point of view
@forthcoming  Oh, I'm sorry.
I missed it uses hashtable for zsetScore. You're right. 
I'm sorry to make confusion.
in src/commands, there is a json file with commands in it, just modify it.
and there is a `commands.def` file, please also search it and modify it too. (or run `python utils\generate-command-code.py` to re-generate the `commands.def`)

Patch:
diff --git a/src/commands.def b/src/commands.def
index d51a6057a28..d1e6f3edd35 100644
--- a/src/commands.def
+++ b/src/commands.def
@@ -10635,9 +10635,9 @@ struct COMMAND_STRUCT redisCommandTable[] = {
 {MAKE_CMD("waitaof","Blocks until all of the preceding write commands sent by the connection are written to the append-only file of the master and/or replicas.","O(1)","7.2.0",CMD_DOC_NONE,NULL,NULL,"generic",COMMAND_GROUP_GENERIC,WAITAOF_History,0,WAITAOF_Tips,2,waitaofCommand,4,CMD_NOSCRIPT,ACL_CATEGORY_CONNECTION,WAITAOF_Keyspecs,0,NULL,3),.args=WAITAOF_Args},
 /* geo */
 {MAKE_CMD("geoadd","Adds one or more members to a geospatial index. The key is created if it doesn't exist.","O(log(N)) for each item added, where N is the number of elements in the sorted set.","3.2.0",CMD_DOC_NONE,NULL,NULL,"geo",COMMAND_GROUP_GEO,GEOADD_History,1,GEOADD_Tips,0,geoaddCommand,-5,CMD_WRITE|CMD_DENYOOM,ACL_CATEGORY_GEO,GEOADD_Keyspecs,1,NULL,4),.args=GEOADD_Args},
-{MAKE_CMD("geodist","Returns the distance between two members of a geospatial index.","O(log(N))","3.2.0",CMD_DOC_NONE,NULL,NULL,"geo",COMMAND_GROUP_GEO,GEODIST_History,0,GEODIST_Tips,0,geodistCommand,-4,CMD_READONLY,ACL_CATEGORY_GEO,GEODIST_Keyspecs,1,NULL,4),.args=GEODIST_Args},
-{MAKE_CMD("geohash","Returns members from a geospatial index as geohash strings.","O(log(N)) for each member requested, where N is the number of elements in the sorted set.","3.2.0",CMD_DOC_NONE,NULL,NULL,"geo",COMMAND_GROUP_GEO,GEOHASH_History,0,GEOHASH_Tips,0,geohashCommand,-2,CMD_READONLY,ACL_CATEGORY_GEO,GEOHASH_Keyspecs,1,NULL,2),.args=GEOHASH_Args},
-{MAKE_CMD("geopos","Returns the longitude and latitude of members from a geospatial index.","O(N) where N is the number of members requested.","3.2.0",CMD_DOC_NONE,NULL,NULL,"geo",COMMAND_GROUP_GEO,GEOPOS_History,0,GEOPOS_Tips,0,geoposCommand,-2,CMD_READONLY,ACL_CATEGORY_GEO,GEOPOS_Keyspecs,1,NULL,2),.args=GEOPOS_Args},
+{MAKE_CMD("geodist","Returns the distance between two members of a geospatial index.","O(1)","3.2.0",CMD_DOC_NONE,NULL,NULL,"geo",COMMAND_GROUP_GEO,GEODIST_History,0,GEODIST_Tips,0,geodistCommand,-4,CMD_READONLY,ACL_CATEGORY_GEO,GEODIST_Keyspecs,1,NULL,4),.args=GEODIST_Args},
+{MAKE_CMD("geohash","Returns members from a geospatial index as geohash strings.","O(1) for each member requested.","3.2.0",CMD_DOC_NONE,NULL,NULL,"geo",COMMAND_GROUP_GEO,GEOHASH_History,0,GEOHASH_Tips,0,geohashCommand,-2,CMD_READONLY,ACL_CATEGORY_GEO,GEOHASH_Keyspecs,1,NULL,2),.args=GEOHASH_Args},
+{MAKE_CMD("geopos","Returns the longitude and latitude of members from a geospatial index.","O(1) for each member requested.","3.2.0",CMD_DOC_NONE,NULL,NULL,"geo",COMMAND_GROUP_GEO,GEOPOS_History,0,GEOPOS_Tips,0,geoposCommand,-2,CMD_READONLY,ACL_CATEGORY_GEO,GEOPOS_Keyspecs,1,NULL,2),.args=GEOPOS_Args},
 {MAKE_CMD("georadius","Queries a geospatial index for members within a distance from a coordinate, optionally stores the result.","O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.","3.2.0",CMD_DOC_DEPRECATED,"`GEOSEARCH` and `GEOSEARCHSTORE` with the `BYRADIUS` argument","6.2.0","geo",COMMAND_GROUP_GEO,GEORADIUS_History,2,GEORADIUS_Tips,0,georadiusCommand,-6,CMD_WRITE|CMD_DENYOOM,ACL_CATEGORY_GEO,GEORADIUS_Keyspecs,3,georadiusGetKeys,11),.args=GEORADIUS_Args},
 {MAKE_CMD("georadiusbymember","Queries a geospatial index for members within a distance from a member, optionally stores the result.","O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.","3.2.0",CMD_DOC_DEPRECATED,"`GEOSEARCH` and `GEOSEARCHSTORE` with the `BYRADIUS` and `FROMMEMBER` arguments","6.2.0","geo",COMMAND_GROUP_GEO,GEORADIUSBYMEMBER_History,1,GEORADIUSBYMEMBER_Tips,0,georadiusbymemberCommand,-5,CMD_WRITE|CMD_DENYOOM,ACL_CATEGORY_GEO,GEORADIUSBYMEMBER_Keyspecs,3,georadiusGetKeys,10),.args=GEORADIUSBYMEMBER_Args},
 {MAKE_CMD("georadiusbymember_ro","Returns members from a geospatial index that are within a distance from a member.","O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.","3.2.10",CMD_DOC_DEPRECATED,"`GEOSEARCH` with the `BYRADIUS` and `FROMMEMBER` arguments","6.2.0","geo",COMMAND_GROUP_GEO,GEORADIUSBYMEMBER_RO_History,0,GEORADIUSBYMEMBER_RO_Tips,0,georadiusbymemberroCommand,-5,CMD_READONLY,ACL_CATEGORY_GEO,GEORADIUSBYMEMBER_RO_Keyspecs,1,NULL,9),.args=GEORADIUSBYMEMBER_RO_Args},
diff --git a/src/commands/geodist.json b/src/commands/geodist.json
index 97969d332c7..145ca718a87 100644
--- a/src/commands/geodist.json
+++ b/src/commands/geodist.json
@@ -1,7 +1,7 @@
 {
     "GEODIST": {
         "summary": "Returns the distance between two members of a geospatial index.",
-        "complexity": "O(log(N))",
+        "complexity": "O(1)",
         "group": "geo",
         "since": "3.2.0",
         "arity": -4,
diff --git a/src/commands/geohash.json b/src/commands/geohash.json
index 8f4d55a62b2..01402c4657a 100644
--- a/src/commands/geohash.json
+++ b/src/commands/geohash.json
@@ -1,7 +1,7 @@
 {
     "GEOHASH": {
         "summary": "Returns members from a geospatial index as geohash strings.",
-        "complexity": "O(log(N)) for each member requested, where N is the number of elements in the sorted set.",
+        "complexity": "O(1) for each member requested.",
         "group": "geo",
         "since": "3.2.0",
         "arity": -2,
diff --git a/src/commands/geopos.json b/src/commands/geopos.json
index 5473c1b76fa..408b6e6a39f 100644
--- a/src/commands/geopos.json
+++ b/src/commands/geopos.json
@@ -1,7 +1,7 @@
 {
     "GEOPOS": {
         "summary": "Returns the longitude and latitude of members from a geospatial index.",
-        "complexity": "O(N) where N is the number of members requested.",
+        "complexity": "O(1) for each member requested.",
         "group": "geo",
         "since": "3.2.0",
         "arity": -2,