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

I am not very familiar with databases and the theories behind how they work. Is it any slower from a performance standpoint (inserting/updating/querying) to use Strings for Primary Keys than integers?

1 Answer

0 votes
by (40.3k points)

Yes, from a performance standpoint (i.e. inserting or querying or updating) using Strings for primary keys are slower than integers. But if it makes sense to use string for the primary key then you should probably use it. 

This all will depend on the size of the table you're making it for and the length of the string that is going to be the primary key (i.e. longer strings == harder to compare). 

One shouldn't necessarily use a string for a table that has millions of rows, but the amount of performance slowdown you'll be getting by using the string on smaller tables will be higher than by having an integer which doesn't mean anything in relation to the data.

Related questions

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

...