Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out a way to support Partitioning #1

Open
codekoenig opened this issue Nov 23, 2016 · 4 comments
Open

Figure out a way to support Partitioning #1

codekoenig opened this issue Nov 23, 2016 · 4 comments
Assignees
Milestone

Comments

@codekoenig
Copy link
Owner

In Identity, sometimes all we have is a UserId or UserName only, but querying for as User with those already requires to know the according PartitionKey. A generic, fast and convenient way to get a PartitionKey from either a UserId or a UserName, when the PartitionKey can really be anything, needs to be figured out (just for example: when creating a user with a PartitionKey, store a UserId-UserName-PartitionKey mapping in DocumentDb).

@codekoenig
Copy link
Owner Author

Ideas on how support for automatic partitioning could be implemented in an as flexible and unopinionated way as possible, please chime in.

@daveh101
Copy link

Hi, I'm not remotely thinking that I am a specialist in Identity, or CosmosDB, but I am certainly an interested party, but there could certainly be some big holes in my suggestion.

My understanding of partitions is that Cosmos automatically assigns the partitions in the background, keeping track of what partition keys are in what partition. Everything with the same partition key is guaranteed to be on the same partition.

I think the easiest way to do this is to have 3 documents. The main user document which will have the userId (or some guid/random string) as the partition key, and in general any other documents for that known user would have the same partition key, keeping all their documents on the same partition.

The other 2 documents are very small and are used to find the partition key for the main document. One would be for finding the user by the user name, and would have a partition key that is the user name. All this document really contains is the partition key for the main user document that work can then be performed from. The other one would basically be the same, but with the user id (or whatever other info is used to search for the user) instead of the user name.

Does that make sense? I appreciate that it will mean there are always 2 files to read when someone logs in, but don't think this would be too much overhead would it??

@dominikfoldi
Copy link

Do you have any progress on this? We would like to use this repository in our project with partitioned Cosmos DB, but with the current implementation we can't.

@daveh101 I think your idea is good because by querying by partitionkey is almost free in cosmosdb so you can get the partitionkey for almost free and then query for the user also for free.

@pcbl
Copy link

pcbl commented Mar 21, 2021

Hi Folks,

Is there any update on this topic? I see the thread is quite long out there so just wanted to ping if there`s any update on it...

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

No branches or pull requests

4 participants