Re: Which is faster: char(14) or varchar(14)

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Edson Richter <edsonrichter(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Which is faster: char(14) or varchar(14)
Date: 2012-12-04 13:50:33
Message-ID: 20121204135033.GA30887@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Dec 4, 2012 at 11:44:20AM -0200, Edson Richter wrote:
> I think I already know the answer (char(14)), but I would like to
> confirm: which is faster?
>
> In Brazil, company id has 14 digits (12 identifiers, 2 control
> digits). By today, application use varchar(14) for these, but I
> intend to optimize insert/update/delete and search, and I'm
> considering to change it to char(14).
>
> Will it give ANY gain? I do use equality and like operators for search.

You need to test it but I doubt there would be any measurable
difference. If it will always be 14, I would use char(14), and perhaps
use a CHECK constraint to make sure it is always 14 with spaces.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Edson Richter 2012-12-04 13:57:32 Re: Which is faster: char(14) or varchar(14)
Previous Message Edson Richter 2012-12-04 13:44:20 Which is faster: char(14) or varchar(14)