Re: PostgreSQL CHARACTER VARYING vs CHARACTER VARYING (Length)

From: Paul Carlucci <paul(dot)carlucci(at)gmail(dot)com>
To: Rajin Raj <rajin(dot)raj(at)opsveda(dot)com>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: PostgreSQL CHARACTER VARYING vs CHARACTER VARYING (Length)
Date: 2020-04-28 16:24:23
Message-ID: CAKhGwmB_C4a1XVrzYsr3CFmUxegZyvsC=7QtzkW6TP27J5G31w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-hackers

PG the text, character varying, character varying(length), character column
types are all the same thing with each column type inheriting the
properties from the parent type. With each successive type further
properties are added but they're all basically just "text" with some
additional metadata. If you're coming from other database engines or just
general programming languages where text and fixed length string fields are
handled differently then the above can seem a bit different form what
you're used to. Heck, I can think of one engine where if you have a text
column you have to query the table for the blob identifier and then issue a
separate call to retrieve it. Here in PG it's literally all the same,
handled the same, performs the same. Use what limiters make sense for your
application.

On Tue, Apr 28, 2020 at 5:22 AM Rajin Raj <rajin(dot)raj(at)opsveda(dot)com> wrote:

> Is there any impact of using the character varying without providing the
> length while creating tables?
> I have created two tables and inserted 1M records. But I don't see any
> difference in pg_class. (size, relpage)
>
> create table test_1(name varchar);
> create table test_2(name varchar(50));
>
> insert into test_1 ... 10M records
> insert into test_2 ... 10M records
>
> vacuum (full,analyze) db_size_test_1;
> vacuum (full,analyze) db_size_test_2;
>
> Which option is recommended?
>
> *Regards,*
> *Rajin *
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ron 2020-04-28 16:39:52 Re: PostgreSQL CHARACTER VARYING vs CHARACTER VARYING (Length)
Previous Message Holger Jakobs 2020-04-28 15:10:31 Re: PostgreSQL CHARACTER VARYING vs CHARACTER VARYING (Length)

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2020-04-28 16:29:41 Re: [HACKERS] Restricting maximum keep segments by repslots
Previous Message Peter Geoghegan 2020-04-28 16:17:11 Re: Fixes for two separate bugs in nbtree VACUUM's page deletion