Post
Topic
Board Service Announcements (Altcoins)
Re: Just-Dice.com : now with added CLAMs : Play or Invest
by
RHavar
on 05/03/2017, 18:32:11 UTC
Database rows are typically a fixed length. Why use 8 bytes per betid if you think they will always fit into 4 bytes. When you're storing 2 billion of them it makes a difference.

You sure?

Using postgres:
Quote
CREATE TABLE miniBets(
   id   int,  -- this is a 32 bit number
   user_id  int,
   payout  float,
   profit  float
);

INSERT INTO minibets VALUES(1, 1, 23.0, 23.0);

CREATE TABLE bigBets(
   id   bigint,   -- this is a 64 bit number
   user_id  bigint,
   payout  float,
   profit  float
);
INSERT INTO bigBets VALUES(1, 1, 23.0, 23.0);



SELECT pg_relation_size('miniBets'), pg_relation_size('bigBets')

returns:
[8192, 8192]


AKA an int32 and int64 end up using the space, due to alignment.   I would assume the same is true with other databases, assuming you're using a 64 bit machine .. which I can't imagine you're not.  32 bits is for barbarians Tongue No, but seriously I almost never use 32 bits numbers.