2

In the official documentation (http://www.postgresql.org/docs/9.1/static/datatype-character.html), it states text field is variable unlimited length.

I wonder what is the default size of this field (or minimum size of the field)?

Erwin Brandstetter
186k28 gold badges463 silver badges636 bronze badges
asked Nov 1, 2013 at 6:07
1
  • 3
    No such things. Commented Nov 1, 2013 at 7:45

2 Answers 2

5

The default minimum size of a text column (representing a NULL value) depends on the rest of the row. In most cases it is absolutely free, if the NULL bitmap has room for another bit.

More about calculating the effective row size:

answered Nov 1, 2013 at 13:40
1

By default such a column will be NULL (essentially zero-length, though remember there is a difference between a zero-length string and a NULL) unless you specify a default constraint in the table definition, and it will grow as needed when you insert data.

If you are asking how much space it takes on disk then this will never be completely zero of course, but there are few times when the minimum size is truly significant (if you are storing millions of rows with very short or mostly NULL text fields it might be). Assuming postgres' storage engine uses a structure not dissimilar to MSSQL then if they are stored off-page (small values are likely to be stored in-page) there will be a page reference (8 bytes?) to find the start of the string - so you might consider that, plus space in NULL bitmap and any other flags such as in-or-off-page, as the minimum footprint of such a type.

answered Nov 1, 2013 at 9:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.