I'm in the process of creating a table and it made me wonder.
If I store, say cars that has a make (fx BMW, Audi ect.), will it make any difference on the query speed if I store the make as an int or varchar.
So is
SELECT * FROM table WHERE make = 5 AND ...;
Faster/slower than
SELECT * FROM table WHERE make = 'audi' AND ...;
or will the speed be more or less the same?
Int comparisons are faster than varchar comparisons, for the simple fact that ints take up much less space than varchars.
This holds true both for unindexed and indexed access. The fastest way to go is an indexed int column.
As I see you've tagged the question postgreql, you might be interested in the space usage of different date types:
int
fields occupy between 2 and 8 bytes, with 4 being usually more than enough ( -2147483648 to +2147483647 )