From: | Edson Richter <edsonrichter(at)hotmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Which is faster: char(14) or varchar(14) |
Date: | 2012-12-04 13:57:32 |
Message-ID: | BLU0-SMTP122F6505D417D06C8149403CF470@phx.gbl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Em 04/12/2012 11:50, Pavel Stehule escreveu:
> Hello
>
> 2012/12/4 Edson Richter <edsonrichter(at)hotmail(dot)com>:
>> 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.
>>
> There are no big differences between char and varchar - char can be
> little bit slower, because empty chars to limit are filled by space.
> So usually varchar is more effective (in PostgreSQL).
In this specific case, the full length (14) is mandatory... so seems
there is no loss or gain.
Also, I see all varchar(...) created are by default "storage = EXTENDED"
(from "Pg Admin"), while other datatypes (like numeric, smallint,
integer) are "storage = MAIN".
Can I have a gain using fixed length datatype in place of current
varchar (like "numeric (14,0)")?
Or changing to "char(14) check length(doc)=14" and "storage=MAIN"?
Sorry if there are many questions in one, but I'm in a brainstorm...
Thanks,
Edson
>
> Regards
>
> Pavel Stehule
>
>
>> Regards,
>>
>> Edson
>>
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2012-12-04 14:53:57 | Re: Which is faster: char(14) or varchar(14) |
Previous Message | Bruce Momjian | 2012-12-04 13:50:33 | Re: Which is faster: char(14) or varchar(14) |