Re: bytes en tabla

From: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
To: Alejandro Carrillo <fasterzip(at)yahoo(dot)es>
Cc: SQL Ayuda Postgre <pgsql-es-ayuda(at)postgresql(dot)org>, Herrera Alvaro <alvherre(at)alvh(dot)no-ip(dot)org>
Subject: Re: bytes en tabla
Date: 2012-06-22 00:52:09
Message-ID: CAJKUy5hxe74_2ag9j2_MFaSeyL3C_fxasaT3YMVMo48S4y-pmQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

2012/6/21 Alejandro Carrillo <fasterzip(at)yahoo(dot)es>:
> Hola
>
> ¿Cuando uno crea en una tabla un campo de varchar(1000) y inserta datos, el
> peso en bytes de la tabla no son iguales a la longitud de datos insertados
> (suele ser menor)? ¿Porque sucede esto?
>

http://www.postgresql.org/docs/9.1/static/datatype-character.html
"""
The storage requirement for a short string (up to 126 bytes) is 1 byte
plus the actual string, which includes the space padding in the case
of character. Longer strings have 4 bytes of overhead instead of 1.
Long strings are compressed by the system automatically, so the
physical requirement on disk might be less. Very long values are also
stored in background tables so that they do not interfere with rapid
access to shorter column values. In any case, the longest possible
character string that can be stored is about 1 GB. (The maximum value
that will be allowed for n in the data type declaration is less than
that. It wouldn't be useful to change this because with multibyte
character encodings the number of characters and bytes can be quite
different. If you desire to store long strings with no specific upper
limit, use text or character varying without a length specifier,
rather than making up an arbitrary length limit.)
"""

--
Jaime Casanova         www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alvaro Herrera 2012-06-22 01:34:45 Re: Re: [pgsql-es-ayuda] Creación de Indices
Previous Message sTyler 2012-06-21 23:44:07 Poblema con campo tipo "lo"