I have four fields in my user table
reset_password_code CHAR(128)
reset_password_expiry DATETIME
email_verification_code CHAR(128)
email_verification_expiry DATETIME
Will it decrease database performance? Is there any best practice to do it?
I am not worried about space but time.
UPDATE:
If I change the CHAR to VARCHAR, will it solve the space issue?
In theory, more fields would mean more space AND more time to access. However, if you’re talking about database design, this is not going to be an issue.
In reality, you have to be concerned about the number of records and not the number of fields. This is because, as the number of records increase, the search time would also increase.
This is why we set a suitable field as a primary key. In cases where your search will be on different fields, you may find that you cannot have many primary keys. This is when you use indexes. That is, you should create an index based on the field you’ll use for searching. This is how the efficiency is gained.
In the past I’ve built MySQL + PHP applications where there were more than 20 million records. And getting around 10,000 records out of it using a search only took less than 10 seconds.
The secret is not in the number of fields, but in the way you create your index/primary keys.
So don’t worry about the 4 fields you have 🙂