Perfectly ok - especially since you can add and subtract integer
to / from date
directly in Postgres.
However, int2
might not be better than a plain integer
. True, integer
occupies 4 bytes instead of 2, but many operations are optimized for integer
. Among other things, integer
is the default numeric type for numbers without decimal point. For int2
you often need to add an explicit cast to avoid errors.
Also, while we are talking about a single column, you will most probably gain nothing in regard to disk storage or RAM. Some closer understanding of storage mechanisms is needed here, in particular padding and data alignment.
If you have several int2
columns in a table (or even "many" as you mention) and / or know what you are doing, the odds for int2
get better.
Details:
Configuring PostgreSQL for read performance
Calculating and saving space in PostgreSQL
If in doubt, run a test and measure:
Measure the size of a PostgreSQL table row