Alex Rivera | Logout

Performance difference between int4 and int8 in PostgreSQL on 64 bit server

Asked 2011-07-09T05:52:04.413
9

Assuming PostgreSQL is running on a 64 bit server, what is the performance difference between an int4 (32 bit) and int8 (64 bit) column? The manual states that int4 is more efficient than int8, but if the underlying server is 64 bit, is there a practical performance difference (in terms of (1) cpu, (2) memory and (3) storage)?

Edit
Report

1 Answer

3

In terms of storage and memory, the answer is obvious: An INT8 is twice as large as an INT4, therefore it uses twice the storage and twice the memory.

In terms of computational (CPU) performance, I suspect it makes no difference at all on a 64-bit machine, and in some cases INT4 may be more efficient on a 32-bit machine. Although unless you're doing complex math on these INTs (and not just using them as a serial, etc), the computational differences are probably zero, or very nearly zero.

And once you start doing complex things with your INTs, it's not really a database performance question any more anyway.

answered 2011-07-09T06:05:00.807

Your Answer