HSQLDB Internals: Hibernate and Integer vs Long Ids

I create database objects in my Java application and try to rationalize between using Integer or Long as the class type of the id field. I use Hibernate as my ORM, which in turn maps this field to a column in the HSQLDB database.

My struggle is this: Long is obviously larger and will handle more records, but at a very low level, I know that in the past (32-bit systems) the level levels in the OS would be 32 bits wide. IE: A long read will take two passes ... is this the right way of thinking?

If I use Long today, will my HSQLDB queries be slower than if I were using Integer?

IE: HSQLDB must somehow use multiple read passes ... or use a large internal structure ... or add two Integer-sized columns too ... or is something else clearly imperfect? Or is it somehow controversial with today's 64-bit processing - which should process Long in one read (Long is 64 bits)?

+4
source share
1 answer

Use a long one. Even when using a database with memory, the performance impact will most likely not be significant compared to the rest of your application. However, it will be an incredible hassle to come back and change the application later if you start running out of identifiers.

+3
source

All Articles