therecluse26 / PHP-Login

A login system built with PHP, MySQL, jQuery and Bootstrap
MIT License
836 stars 442 forks source link

int for id #200

Closed bydbest closed 6 years ago

bydbest commented 6 years ago

for me its working as expected but i can see that u are using 32 character unique value for id generation of members table but for very large users base it requires lot of space for indexing. wont be it much better if we use int auto increment instead of unique 32 character, i tried to modify but seems u have integrated tightly with foreign key and other restriction. is there an easy way to move to int id for members with auto increment and starting from 1 numeric as id for first users and increase by 1

therecluse26 commented 6 years ago

That's a debate I've had with myself for quite some time. There's a lot of advantages to GUIDs from a coding perspective that I found to outweigh the minimal impact that they would have on performance. I would actually say that the argument for global uniqueness would be stronger on very large user databases rather than on smaller ones, whereas int would maybe be better for smaller databases, but I can see both sides of that. I would think that if you have an absolutely massive users table, you could probably integrate some sort of advertising on your site to easily pay for the extra space at that scale ;)

I'll have to kick the idea around some more though. Another issue with swapping it at this point is like you said, changing all of the logic that handles it (such as the advantage that comes with GUID of not having to pull a new ID from the database upon creation or even check for uniqueness), as well as the complications that would arise from having to force all of our current users to migrate their databases to fit that schema. Good thoughts though! I like the feedback and I'll definitely keep thinking about that one.

On Fri, Jun 15, 2018 at 6:58 PM, bydbest notifications@github.com wrote:

for me its working as expected but i can see that u are using 32 character unique value for id generation of members table but for very large users base it requires lot of space for indexing. wont be it much better if we use int auto increment instead of unique 32 character, i tried to modify but seems u have integrated tightly with foreign key and other restriction. is there an easy way to move to int id for members with auto increment and starting from 1 numeric as id for first users and increase by 1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/therecluse26/PHP-Login/issues/200, or mute the thread https://github.com/notifications/unsubscribe-auth/AH24ApnXYXDAI7yZfj_ALOBgxZMdH6lnks5t9Dv5gaJpZM4UqPa_ .

bydbest commented 6 years ago

can u plz tell how we can safely change to int

therecluse26 commented 6 years ago

I'd have to dig into it more, but you'd have to replace the section that generates the GUID as well as alter the database table to be of the int datatype. I wouldn't recommend this though, so do at your own risk. Using GUIDs most likely isn't going to make any noticeable impact on performance at all for the vast majority of websites, even with a decent number of users. I've tested it with around 10000 dummy accounts on my local machine with no noticeable degradation in performance.