0 votes
1 view
in SQL by (20.3k points)

Is email address a bad candidate for primary when compared to auto incrementing numbers?

Our web application needs the email address to be unique in the system. So, I thought of using email address as primary key. However my colleague suggests that string comparison will be slower than integer comparison.

Is it a valid reason to not use email as primary key?

We are using PostgreSQL.

1 Answer

0 votes
by (40.3k points)

String comparison is slower than int comparison. However, this doesn't matter if you merely retrieve a user from the information adversity the e-mail address. It will matter if you've got complicated queries with multiple joins.

If you store info regarding users in multiple tables, the foreign keys to the users table are the e-mail address. meaning that you just store the e-mail address multiple times.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...