pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
char(N), varchar(N), varchar, text
3+ messages / 2 participants
[nested] [flat]

* char(N), varchar(N), varchar, text
@ 2014-10-08 14:22  Emi Lu <emilu@encs.concordia.ca>
  0 siblings, 1 reply; 3+ messages in thread

From: Emi Lu @ 2014-10-08 14:22 UTC (permalink / raw)
  To: pgsql-performance

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <small>Good morning, <br>
      <br>
      For performance point of view, are there big differences between:
      char(N), varchar(N), varchar, text? <br>
    </small>
    <p><small>Some comments from google shows: <br>
        No difference, under the hood it's all varlena. Check this
        article from Depesz: <a
href="http://www.depesz.com/index.php/2010/03/02/charx-vs-varcharx-vs-varchar-vs-text/">http://www....;
        A couple of highlights:</small></p>
    <small>
    </small>
    <blockquote><small> </small>
      <p><small>To sum it all up:</small></p>
      <small> </small>
      <ul>
        <li><small>char(n) &#8211; takes too much space when dealing with
            values shorter than n, and can lead to subtle errors because
            of adding trailing spaces, plus it is problematic to change
            the limit</small></li>
        <li><small>varchar(n) &#8211; it's problematic to change the limit in
            live environment</small></li>
        <li><small>varchar &#8211; just like text</small></li>
        <li><small>text &#8211; for me a winner &#8211; over (n) data types because
            it lacks their problems, and over varchar &#8211; because it has
            distinct name</small></li>
      </ul>
      <small>
        So, can I assume no big performance differences? <br>
        Thanks alot!<br>
        Emi<br>
      </small></blockquote>
  </body>
</html>




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: char(N), varchar(N), varchar, text
@ 2014-10-08 14:30  Andrew Dunstan <andrew@dunslane.net>
  parent: Emi Lu <emilu@encs.concordia.ca>
  0 siblings, 1 reply; 3+ messages in thread

From: Andrew Dunstan @ 2014-10-08 14:30 UTC (permalink / raw)
  To: emilu@encs.concordia.ca; +Cc: pgsql-performance


On 10/08/2014 10:22 AM, Emi Lu wrote:
> Good morning,
>
> For performance point of view, are there big differences between: 
> char(N), varchar(N), varchar, text?
>
> Some comments from google shows:
> No difference, under the hood it's all varlena. Check this article 
> from Depesz: 
> http://www.depesz.com/index.php/2010/03/02/charx-vs-varcharx-vs-varchar-vs-text/
> A couple of highlights:
>
>     To sum it all up:
>
>       * char(n) – takes too much space when dealing with values
>         shorter than n, and can lead to subtle errors because of
>         adding trailing spaces, plus it is problematic to change the limit
>       * varchar(n) – it's problematic to change the limit in live
>         environment
>       * varchar – just like text
>       * text – for me a winner – over (n) data types because it lacks
>         their problems, and over varchar – because it has distinct name
>
>     So, can I assume no big performance differences?
>     Thanks alot!
>     Emi
>


Why do you need to ask if you already have the answer? Depesz is right.

cheers

andrew


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: char(N), varchar(N), varchar, text
@ 2014-10-08 14:42  Emi Lu <emilu@encs.concordia.ca>
  parent: Andrew Dunstan <andrew@dunslane.net>
  0 siblings, 0 replies; 3+ messages in thread

From: Emi Lu @ 2014-10-08 14:42 UTC (permalink / raw)
  To: Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-performance


>
>>
>> For performance point of view, are there big differences between: 
>> char(N), varchar(N), varchar, text?
>>
>> Some comments from google shows:
>> No difference, under the hood it's all varlena. Check this article 
>> from Depesz: 
>> http://www.depesz.com/index.php/2010/03/02/charx-vs-varcharx-vs-varchar-vs-text/
>> A couple of highlights:
>>
>>     To sum it all up:
>>
>>       * char(n) – takes too much space when dealing with values
>>         shorter than n, and can lead to subtle errors because of
>>         adding trailing spaces, plus it is problematic to change the 
>> limit
>>       * varchar(n) – it's problematic to change the limit in live
>>         environment
>>       * varchar – just like text
>>       * text – for me a winner – over (n) data types because it lacks
>>         their problems, and over varchar – because it has distinct name
>>
>>     So, can I assume no big performance differences?
>>     Thanks alot!
>>     Emi
>>
>
>
> Why do you need to ask if you already have the answer? Depesz is right.
Good to hear this. Well, sorry I saw the time is:/2010/03 (might changes 
for diff/newer versions).

Thank you for the confirmation.
Emi



-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2014-10-08 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-10-08 14:22 char(N), varchar(N), varchar, text Emi Lu <emilu@encs.concordia.ca>
2014-10-08 14:30 ` Andrew Dunstan <andrew@dunslane.net>
2014-10-08 14:42   ` Emi Lu <emilu@encs.concordia.ca>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox