Answer the question
In order to leave comments, you need to log in
Does it make sense to use SMALLINT instead of INT (PostgreSQL)?
What is the real benefit of such a replacement, if I am sure that the size of SMALLINT is enough for me?
Answer the question
In order to leave comments, you need to log in
int is always 4 bytes, smallint is always 2 bytes.
Less bytes are occupied by data - it means that more data will enter the same amount of memory on a piece of iron, and less data will need to be run through disks. Less disk work is always a plus in DBMS performance.
At the same time, the data takes up less space in both tables and indexes.
But this is if you have the order of integer data, and not just a few million rows. What is saving ten megabytes of data on a machine with several tens of gigabytes of memory?
Otherwise, the use of appropriate types is a courtesy, a manifestation of professionalism and an extra way not to accidentally shoot yourself in the foot (by mistake, writing down something completely strange will no longer work).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question