Skip to content

Redis: Is it still O(logN) to get top score member from sorted set? #2013

Closed

Description

@pankai

My code needs to frequently get the top score member from a sorted set of Redis.

The time complexity for zrangebyscore is O(logN): http://redis.io/commands/zrangebyscore.
Since I only want to get the top score one, will Redis optimize it to return top score member in O(1) time?

Activity

  1. changed the title [-]Redis: Is it still O(logN) to get top score item from sorted set?[/-] [+]Redis: Is it still O(logN) to get top score member from sorted set?[/+] on Sep 18, 2014
  2. mattsta commented on Sep 18, 2014

    @mattsta
    Contributor

    Have you noticed a real-world performance problem?

    If you need O(1) access to something that itself isn't O(1), the solution is to cache the result somewhere else for quick reading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions