How can we improve Azure Cosmos DB?

Support cross-document joins

I have a many-to-many scenario that requires something like document-to-document joins.

In my app, users can "like" posts. That's three "tables" or entity sets. One each for users, likes and posts. I can't put the likes inside of either the users or the posts entities as sub-documents because there could be thousands of them. Even with 256KB documents I'd run out of room pretty quickly. I need a way to quickly get the top 100 posts that a user liked (and continue to paginate from there). I also need to go the other way. I need to get all the users who liked a particular post. Again, I need to show the top 100 users and continue to paginate from there.

Both of those scenarios require some kind of document-to-document join.

A cross-collection join would also be handy but I think I could survive without it for now.

1,410 votes
Vote
Sign in
(thinking…)
Password icon
Signed in as (Sign out)
You have left! (?) (thinking…)
che shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

For applications that require cross document join, please consider the Gremlin API: https://docs.microsoft.com/en-us/azure/cosmos-db/create-graph-dotnet, which has primitives for joins, traversals, and other graph operations.

We are evaluating expanding the SQL grammar to support graph functionality, which will provide the ability to perform cross-document JOINs. Please upvote this item to help us prioritize this work.

24 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • Anonymous commented  ·   ·  Flag as inappropriate

    "A cross-collection join would also be handy but I think I could survive without it for now."

    BEST JOKE EVER.

  • Anonymous commented  ·   ·  Flag as inappropriate

    Hi Azure Cosmos DB Team, any update expanding the SQL grammar for performing cross-document JOINs?

  • Ben commented  ·   ·  Flag as inappropriate

    Btw, what does 'Unplanned' mean for this feature? That MS is NOT going to implement this feature? You really shouldn't 'Unplan' top 10 features your devs want/need. And the Gremlin answer is not a good one. :-/

  • Ben commented  ·   ·  Flag as inappropriate

    Not having this feature makes using this service difficult at best and limits its utility so much. And I do not want to have to use the Gremlin API as someone else suggested. For me, I prefer SQL and that is what I expect to use. Its frustrating the MS acts like Cosmos DB is the future, but you cannot even perform these simple types of cross-document joins. Sigh.

  • william lee commented  ·   ·  Flag as inappropriate

    It's painful to do this without it. I will save me from having same data in multiple documents

  • Fengyang commented  ·   ·  Flag as inappropriate

    Stored procedures can only execute on primary replica, so it would be slow if I just want to read with joins.

  • Rick Stephens commented  ·   ·  Flag as inappropriate

    If you need to join documents together in this manner, you are using the platform wrong. These are documents, not SQL tables.

    You need to review CQRS/Denormalization techniques.

  • Anonymous commented  ·   ·  Flag as inappropriate

    I was asking for the same , in mongodb we have a driver (mongoose autopopulate) that do it automatically for you.

    Is as useful as I never imagined.

    You don't have to worry about normalize just put the unique id in the field that you want to "point" to a external document and that's it!.

    You can have like a nested architecture with normalized data.

← Previous 1

Feedback and Knowledge Base