Search Postgresql Archives

Re: Primary Key Performance with INTEGER vs. VARCHAR

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jul 21, 2007, at 5:49 AM, Siah wrote:
Designing my application, I was wondering if having my primary keys
(to be indexed) with VARCHAR brings performance down significantly? My
own test didn't show much difference. Thinking about it though, I'd
guess Integer Indexing should be much quicker and efficient.

Generally, anything dealing with a text/varchar field is going to be slower than on, say, an integer. But remember the first rule of performance tuning: don't. Do you *really* need to worry about the extra overhead of varchar vs int? Probably not.

What you *should* be thinking about is do you really want a varchar PK? Generally speaking, it's better to use a phantom PK (ie: a SERIAL), and put a UNIQUE constraint on the varchar in the appropriate table.
--
Jim Nasby                                            jim@xxxxxxxxx
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux