How can I structure a leaderboard aggregation query that scales? #8923
-
Howdy! I'm trying to create a leaderboard that shows members ranked by a specific tracked metric. For example, the number of leads they referred into a system. This is the query I'm running:
But I need it to accomplish a few things:
Any idea how to adjust this query (even if it means running multiple aggregations in one request) so that it achieves the items above at scale? Found something similar with MongoDB, but trying to find a way to do it with Hasura / PostgreSQL: I don't want to pull an array of 100.000 elements to the client and then run a find and stuff like that because it's not exactly scalable. Cheers! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @altechzilla We did try to attempt what you are trying to solve here. Here's the github repository, https://github.com/dventimihasura/hasura-projects/tree/master/leaderboard-1 where we have curated list of queries in README.md file One of our team members has curated README.md file with all sorts of use cases that you can find them here - https://github.com/dventimihasura/hasura-projects/tree/master/leaderboard-1#what We've covered enough use cases with query examples. I hope this helps. Feel free to point out any questions or concerns, thanks! |
Beta Was this translation helpful? Give feedback.
Hey @altechzilla
We did try to attempt what you are trying to solve here.
Here's the github repository, https://github.com/dventimihasura/hasura-projects/tree/master/leaderboard-1 where we have curated list of queries in README.md file
One of our team members has curated README.md file with all sorts of use cases that you can find them here - https://github.com/dventimihasura/hasura-projects/tree/master/leaderboard-1#what
We've covered enough use cases with query examples. I hope this helps.
Feel free to point out any questions or concerns, thanks!