Reputation: 11
Do you know which table srtucture is better :
table user
id INT pk autoincrement
name VARCHAR(255)
email VARCHAR(255)
statut TINYINT(4)
The statut can only hold 2 states : 1/2
OR
table user
id INT pk autoincrement
name VARCHAR(255)
email VARCHAR(255)
statut VARCHAR(45)
The statut can only hold 2 states : active/inactive
I'm looking for the fastest way to do select statements such as
SELECT id, name, email
FROM user
WHERE statut=:statut
I read somewhere that "integer" types are generally processed faster
than "text" types
but for some other reasons I would prefer to store the statut
with the VARCHAR
type.
Is there a way to use statut with VARCHAR
type AND that it runs faster ?
Or is the first structure definitively the fastest ?
Upvotes: 1
Views: 54
Reputation: 8910
You could use ENUM
if you're absolutely sure that you'll only ever need to store 2 values in that column. Combines the user-friendliness of text with the performance and space-efficiency of integers.
Upvotes: 2