Search Postgresql Archives

size cost for null fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a table with lots and lots of rows (into the millions), and I want to add some information to it.  The new data consists of a VARCHAR and a BYTEA, and it will almost always be null -- let's say only one row in 10,000 will have non-null values.  I'm trying to decide whether to add the new data as columns in the existing table, or a side table linked by FK.

Looking at the Database Page Layout page <http://www.postgresql.org/docs/8.1/static/storage-page-layout.html>, it seems to me that I'll pay the minimum storage cost for these two fields (4 bytes for the VARCHAR, 4 bytes for the BYTEA) in every row, regardless of whether they're null.  When the fields are null, there'll be bits set for them in the null mask, but the alignment and size of the row won't change -- everything else will be placed as if there were zero-length values in the two fields.

Do I have this right?  If so, the side table sounds like the right choice....

    Vance

---------------------------(end of broadcast)---------------------------TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux