How can I get random data with DQL

I want to get randomized data from a graph database.

Type Person
{
    name
}

Can you please guide if there is an efficient DQL query to fetch random 100 person
from the database?

Second Question (nice to have feature): Pagination with randomized data.
I want to fetch 100 randomized people from the database.
Then, I want to fetch another randomized data chunk as a second page which does not contain any record from the previous fetch. (Skip option with randomized data)

1 Like

There’s no random feature in Dgraph. Also, that’s the second time after a while (2 years more or less) someone is asking this. I think the ticket still open.

@MichelDiz
This is a very common scenario in graph systems.
Although it can be implemented externally using another data store like Redis, it would be nice to have feature in Dgraph itself.
I like the idea to stick to the Dgraph as a single source of truth.

Feature request is here:

2 Likes

So this was the third request. @hardik maybe we should consider this. A random function isn’t that a big thing.

3 years old request.

2 Likes

There’s been more than 3. I decided to make that thread the main feature request thread.

1 Like