views:

73

answers:

2

I'm at the stage in a project where I need to extend the user membership fields in a asp.net mvc website.

I have gone through these different thought processes.

  1. Using "username" to join users to records. Very bad idea due to a user wanting to change their username etc.

  2. Then I thought I could connect the guid of userId to the other tables.

  3. Then I thought that using guid might be bad if I needed to use the id as a simple in the future. So I was setting up a link table to joing guid to ints.

  4. Decided that i didn't need that so went back to using guid to link things together, which makes requests more simple.

  5. Read loads of discussions of performance being hideous when using guid as clustered index.

I'm now confused, does this mean that the default asp.net authentication is awful for performance?

I know one shouldn't think about performance too soon, but I do hope to end up with this app being very popular, so if I have to "roll my own" authentication provider, I guess maybe I should do it now.

Any links in the direction of actually doing this would be greatly appreciated as I have been abstracted from this due to asp.net membership stuff doing everything for me.

Thanks everyone.

+2  A: 

Just implement your own Membership provider and use an int identity(1,1) Primary Key if you're concerned about the performance of the default aspnet Membership provider's use of a GUID PK.

Writing your own Membership Provider is really straightforward and to be honest, if the GUID PK is the only thing that concerns you about the default implementation, then download the source for the built-in provider and change the code to use integers instead of GUIDs. This shouldn't take more than an hour max to do. To complete the picture, run aspnet_sql.exe on your database to get the Membership database and then alter the tables and sprocs to match the changes you make to the source.

Here's the MSDN documentation on implementing a Membership Provider

Russ Cam
Thanks so much, I think I may go with the guid for the moment, as long as I have done the right thing in terms of using Newsequentialid(). But thanks for the great link to exactly what I may need at some point in the future.
optician
I think it's actually a good idea to look through the source anyway, as it gives you an understanding of exactly how the black box of the default providers all fit together
Russ Cam
@Russ Cam - sorry to not give you the correct answer on this, but looking at the question, it was mainly about if it was necessary to switch, not how to switch if needed. Your advise is greatly appreciated though.
optician
+1  A: 

Guids are a worse choice than ints or bigints, this was discussed and documented inany places. Are they horrible? Not really. There are horror stories of apps using guids for every key and foreign key and what have you, but they are the exception.

The uniqueness of guids has it's advantages and when used judiciously they can get the job done without issues. I'd much rather use the default provider implementation using guids than roll your own. The skillset to roll your own correct and better than the default one is significant. I don't say this in a derogatory way, but if you need guidance on understanding the guid impact on erformance then you're probably not ready to roll your own.

Use the default one, test it, measure and then decide, my 2c.

Remus Rusanu
Thanks, yeah, I see there is a lot of default value in using the built in one, I just kinda wish there was a switch to set it to int if I needed to. But sounds like I could potentially mod the source if needed.
optician