Redis – Difference Between Range and Radius Queries

redis

While searching for easy and effective tools to improve performance of Data fetching for our application, we bumped into "Redis".

In documentation of redis, there is following specific mention of these two types or categories of queries:

It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries…

This was first time in area of database and data structures, I have read such thing. I dug out internet to know more, but found nothing useful.

What exactly are Range and Radius queries? What is the difference between the two? Any explanation with example will be useful.

Best Answer

Range stands for one-dimensional distance while radius is standing for two-dimensional one.

Let's the data is the timestamp. It is one-dimensional and you can define part of data "in range" or timestamp BETWEEN a AND b. If your data represents the plane of points x:y then you can define part of them as "points closer than radius Z to the given point" or (x-x1)^2 + (y-y1)^2 < Z^2.