creating userID (int) - Use AutoIncrement?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

uclabachelor

Senior member
Nov 9, 2009
448
0
71
For data you want to obscure, he's correct. AutoIncrement makes things predictable. If you don't want somebody scraping your site, then use GUIDs. If you want to make it easy to scrape then go ahead and use an autoincrement and put it right in the URL. There are reasons to do both.

If a page has data that should not and cannot be seen by anyone but an authenticated user, then this discussion is moot.

If a page is public and you want to prevent scraping, then there are a few ways I can think of off the top of my head to limit or prevent scraping that doesn't enforce a requirement on the database.

Dwell said:
Also if you're sharding you'll avoid hotspots by using UUIDs.

I don't see how using GUIDs over integer numbers can avoid creating hotspots. If I have 2 partitions, what's the difference between assigning the partitions A-M and N-Z versus odds and evens?
 

clamum

Lifer
Feb 13, 2003
26,255
403
126
In your case OP, it sounds like an auto-increment integer would work fine.

GUIDs can be used (SQL Server can generate them by calling NEWID()) but they require much more storage than a simple int and indexes would be slower on them. From SQLTeam.com:

The major advantage of using GUIDs is that they are unique across all space and time. This comes in handy if you're consolidating records from multiple SQL Servers into one table, as in a data warehousing situation. GUIDs are also used heavily by SQL Server replication to keep track of rows when they're spread out among multiple SQL Servers.

The main disadvantage to using GUIDs as key values is that they are BIG. At 16 bytes a pop, they are one of the largest datatypes in SQL Server. Indexes built on GUIDs are going to be larger and slower than indexes built on IDENTITY columns, which are usually ints (4 bytes).
 

TechBoyJK

Lifer
Oct 17, 2002
16,701
60
91
In your case OP, it sounds like an auto-increment integer would work fine.

GUIDs can be used (SQL Server can generate them by calling NEWID()) but they require much more storage than a simple int and indexes would be slower on them. From SQLTeam.com:

That's the winning point to this discussion, imho. I don't have any security needs to obfuscate the userID, and I have programmatic protections against abusing the url's (such as comparing userID to session.userID for authentication, etc, etc).

If I'm going to have 100million users (hypothetically), having GUID's as the primarykey and running indexes on that could be a game changer when compared to the smaller INT type.
 

clamum

Lifer
Feb 13, 2003
26,255
403
126
That's the winning point to this discussion, imho. I don't have any security needs to obfuscate the userID, and I have programmatic protections against abusing the url's (such as comparing userID to session.userID for authentication, etc, etc).

If I'm going to have 100million users (hypothetically), having GUID's as the primarykey and running indexes on that could be a game changer when compared to the smaller INT type.
Exactly. I try to follow the KISS principle as much as possible in development, and in your case here I'd say KISS means auto-inc.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |