Proposal for Byte savings in VarBit structure

Started by Gokulakannan Somasundaramalmost 16 years ago3 messages
#1Gokulakannan Somasundaram
gokul007@gmail.com

Hi,
I was looking at the VarBit data structure and found out that instead of
storing the number of bits in four bytes, we can save the number of bits
that are valid in the last byte. Since we already store the number of bytes
in Varlena Header, we can calculate the number of valid bits by doing the
small math. ( (No. of bytes-1) * 8 + valid bits in the last byte).
This would save atleast 8 bytes for someone, who is using the varbit data
type using less than 24 bits.

Waiting for comments.

Thanks,
Gokul.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Gokulakannan Somasundaram (#1)
Re: Proposal for Byte savings in VarBit structure

Gokulakannan Somasundaram <gokul007@gmail.com> writes:

I was looking at the VarBit data structure and found out that instead of
storing the number of bits in four bytes, we can save the number of bits
that are valid in the last byte. Since we already store the number of bytes
in Varlena Header, we can calculate the number of valid bits by doing the
small math. ( (No. of bytes-1) * 8 + valid bits in the last byte).
This would save atleast 8 bytes for someone, who is using the varbit data
type using less than 24 bits.

This might be worth considering in a release cycle where we were going
to break on-disk data compatibility for some other reason. But I can
hardly imagine wanting to do it by itself. Marginal space savings for
the "bit" types just isn't that exciting.

Maybe we should start a special section of TODO for "things we might do
next time we break data compatibility".

regards, tom lane

#3Gokulakannan Somasundaram
gokul007@gmail.com
In reply to: Tom Lane (#2)
Re: Proposal for Byte savings in VarBit structure

This might be worth considering in a release cycle where we were going
to break on-disk data compatibility for some other reason. But I can
hardly imagine wanting to do it by itself. Marginal space savings for
the "bit" types just isn't that exciting.

Maybe we should start a special section of TODO for "things we might do
next time we break data compatibility".

Thanks Tom. So when we say breaking data compatibility, we mean the next
release where we will recommend pg_dump/restore right?

Thanks,
Gokul.