Re: Efficiency question: VARCHAR with empty string vs NULL

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: Efficiency question: VARCHAR with empty string vs NULL
Дата
в 15:01:39
Msg-id
13510.1022266454@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
Performance issues with compaq server "Samuel J. Sutjiono" <ssutjiono@wc-group.com>
Re: Performance issues with compaq server Denis Gasparin <denis@edistar.com>
Re: Performance issues with compaq server Curt Sampson <cjs@cynic.net>
Re: Performance issues with compaq server postgres@vrane.com
Re: Performance issues with compaq server Martijn van Oosterhout <kleptog@svana.org>
Re: Performance issues with compaq server Holger Marzen <holger@marzen.de>
MacOS X Shared Buffers (SHMMAX)? "Command Prompt, Inc." <pgsql-general@commandprompt.com>
Re: MacOS X Shared Buffers (SHMMAX)? Tom Lane <tgl@sss.pgh.pa.us>
Re: MacOS X Shared Buffers (SHMMAX)? Steve Lane <slane@fmpro.com>
Re: MacOS X Shared Buffers (SHMMAX)? "Command Prompt, Inc." <pgsql-general@commandprompt.com>
Re: MacOS X Shared Buffers (SHMMAX)? Tom Lane <tgl@sss.pgh.pa.us>
Re: MacOS X Shared Buffers (SHMMAX)? "Nigel J. Andrews" <nandrews@investsystems.co.uk>
Re: MacOS X Shared Buffers (SHMMAX)? Tom Lane <tgl@sss.pgh.pa.us>
Efficiency question: VARCHAR with empty string vs NULL Doug Fields <dfields-pg-general@pexicom.com>
Re: Efficiency question: VARCHAR with empty string vs NULL Tom Lane <tgl@sss.pgh.pa.us>
Re: Efficiency question: VARCHAR with empty string Doug Fields <dfields-pg-general@pexicom.com>
Re: MacOS X Shared Buffers (SHMMAX)? Gregory Seidman <gss+pg@cs.brown.edu>
Re: MacOS X Shared Buffers (SHMMAX)? "Command Prompt, Inc." <pgsql-general@commandprompt.com>
Doug Fields  writes:
> Is there a performance difference with VARCHAR elements of value NULL and 
> zero-length string?

These are not semantically equivalent (if you think they are, you've
been using Oracle too long).  You will almost certainly regret it
if you try recoding your app to make them equivalent.  An example:

regression=# select 'foo'::varchar || ''::varchar;
 ?column?
----------
 foo
(1 row)

regression=# select 'foo'::varchar || null::varchar;
 ?column?
----------

(1 row)


But to answer your question, NULLs might save a couple bytes if there
are multiple NULLs per row.  I think that replacing a single empty
varchar with a NULL would net out to no change (you lose the 4-byte
varchar length word, but have to store a null-values bitmap instead),
depending on alignment issues and how many columns there are in the
table.

			regards, tom lane
В списке pgsql-general по дате отправления
От: Neil Conway
Дата:
От: Neil Conway
Дата:
Сообщение: Re: Case Insensitive Data Type
FAQ